I need help

36 views
Skip to first unread message

armando ferreira

unread,
Oct 19, 2011, 9:13:34 PM10/19/11
to dompdf-dev
Hi,
I have a big problem, I have a serious problem with making my pdf, I
followed all the stepsand when I try to create PDF results in the
following error:
Acrobat could not open 'exemplo-01-1.pdf' because it is either not a
supported file type or because the file has been damaged (for example,
it was sent as an email attachment and wasn't correctly decoded).

To create an Adobe PDF document, go to the source application. Then
print the document to Adobe PDF.

BrianS

unread,
Oct 19, 2011, 10:33:10 PM10/19/11
to dompd...@googlegroups.com
What version of dompdf are you using? The most likely cause for this type of problem is due to a PHP errors being captured in the PDF file stream due to output buffering. The easiest way to check for this is to save the PDF locally and open in a normal text editor. The PHP errors will be at the top of the file, followed by the contents o the PDF. Change the PHP setting display_errors to false to prevent this type of issue.

Also please note that since this is a general support question you should use the support group <https://groups.google.com/forum/#!forum/dompdf>. This group is intended to discuss development of the project.

armando ferreira

unread,
Oct 20, 2011, 9:24:46 AM10/20/11
to dompdf-dev

The version is 0.62 Beta.
sorry but I am a new user php. What is the file that I go to change
PHP setting display_errorsto false?

this is the file I need to convert to php:



<?
require_once("dompdf/dompdf_config.inc.php");

$sq="SELECT tbl_encomenda.id_encomenda, tbl_encomenda.data,
tbl_encomenda.estado, tbl_encomenda.total, tbl_encomenda.subTotal,
tbl_encomenda.pesoTotal, tbl_encomenda.taxasTotal,
tbl_encomenda.cliente_id, tbl_clientes.id_cliente, tbl_clientes.nome,
tbl_clientes.sobrenome, tbl_clientes.morada, tbl_clientes.cidade,
tbl_clientes.pais, tbl_clientes.cod, tbl_clientes.postal,
tbl_clientes.cnt_fixo, tbl_clientes.cnt_movel, tbl_clientes.email FROM
tbl_encomenda JOIN tbl_clientes WHERE tbl_clientes.id_cliente =
tbl_encomenda.cliente_id AND tbl_encomenda.id_encomenda =".
$_GET['id']." ORDER BY tbl_encomenda.data ASC";
$result = mysql_query($sq)
or die ("Não foi possível realizar a consulta.");
$row=mysql_fetch_array($result);
ini_set("memory_limit", "10M");
?>


<?php
$html='<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"/>
<link href="css/pdf.css" rel="stylesheet" type="text/css" />
</head>
<body>';


$html.='
<table width="100%" border="0" cellspacing="6" cellpadding="0">
<tr>
<th width="15%" scope="col"><img src="img/logotipo.jpg"
width="174" height="152" style="width:auto;"/></th>
<th width="85%" scope="col" class="conteudo">Exmo(a) Sr.(a) '.
$row['nome'].' '.$row['sobrenome'].'<br />
Agradecemos desde j&aacute; a sua perfer&ecirc;ncia na compra
dos nossos produtos. Serve o presente documento como comprovativo da
sua compra</th>
</tr>
<tr>
<td colspan="2" class="contactos">Infotrilhos - Informática e
Turismo, Lda. - Av. das Forças Armadas, Lt 64 R\C Dto.- 5300-440
Bragança <br>Telf.: 273 332167 / Fax.: 273 332168 | E-mail:
dvia...@infotrilhos.com</br></td>
</tr>
</table>
<div id="titulo">ELEMENTOS DO CLIENTE</div>
<div style="clear: both;"></div>
<div id="espaco"></div>
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td class="item">Nome:</th>
<td colspan="5" class="conteudo">'.$row['nome'].' '.
$row['sobrenome'].'</th>
</tr>
<tr>
<td class="item">Morada:</td>
<td colspan="5" class="conteudo">'.$row['morada'].'</td>
</tr>
<tr>
<td class="item">Localidade:</td>
<td class="conteudo">'.$row['cidade'].'</td>
<td class="item">Pais:</td>
<td class="conteudo">'.$row['pais'].'</td>
<td class="item">Cód. Postal:</td>
<td class="conteudo">'.$row['cod'].'-'.$row['postal'].'</td>
</tr>
<tr>
<td class="item">E-mail:</td>
<td class="conteudo">'.$row['email'].'</td>
<td class="item">Telefone:</td>
<td class="conteudo">'.$row['cnt_fixo'].'</td>
<td class="item">Telem&oacute;vel:</td>
<td class="conteudo">'.$row['cnt_movel'].'</td>
</tr>
</table>
<div style="clear: both;"></div>
<div id="espaco"></div>
<div id="titulo">ELEMENTOS DE ENCOMENDA</div>
<div style="clear: both;"></div>
<div id="espaco"></div>';

$dir1="produtos/img_pro/";
$sql = mysql_query("SELECT tbl_encomenda.id_encomenda,
tbl_encomenda.entrega, tbl_produto.id_produto, tbl_produto.produto,
tbl_produto.preco, tbl_produto.peso, tbl_imagem_produto.produto_id,
tbl_imagem_produto.imagem1, tbl_encopro.encomenda_id,
tbl_encopro.produto_id, tbl_encopro.peso_proT, tbl_encopro.preco_proT,
tbl_encopro.quantidade_proT FROM tbl_encomenda, tbl_produto,
tbl_encopro, tbl_imagem_produto WHERE tbl_encomenda.id_encomenda =
tbl_encopro.encomenda_id AND tbl_encopro.produto_id =
tbl_produto.id_produto AND tbl_produto.id_produto =
tbl_imagem_produto.produto_id AND tbl_encomenda.id_encomenda =".
$_GET['id']." ORDER BY tbl_produto.produto ASC");
while ($row1 = mysql_fetch_array($sql)) {

$html.='
<table width="100%" border="0" cellspacing="6" cellpadding="0">
<tr>
<td rowspan="3" scope="col" width="10%"><img src="'.$dir1.''.
$row1['imagem1'].'" alt="'.$row1['produto'].'" width="40" height="45"
style="width:auto;"/></th>
<td scope="col" class="itemp">Descritivo:</th>
<td colspan="5" class="conteudop">'.$row1['produto'].'</th>
</tr>
<tr>
<td class="itemp" width="13%">Quantidade:</td>
<td class="conteudop" width="14%">'.$row1['quantidade_proT'].'</
td>
<td class="itemp" width="13%">Pre&ccedil;o/Unit.:</td>
<td class="conteudop" width="14%">'.$row1['preco'].' EUR</td>
<td class="itemp" width="13%">Pre&ccedil;o Total:</td>
<td class="conteudop" width="14%">'.$row1['preco_proT'].' EUR</td>
</tr>
<tr>
<td class="itemp">Entrega Tipo:</td>
<td class="conteudop">'.$row1['entrega'].'</td>
<td class="itemp">Peso/Unit.:</td>
<td class="conteudop">'.$row1['peso'].' Kg</td>
<td class="itemp">Peso/Qnts.:</td>
<td class="conteudop">'.$row1['peso_proT'].' Kg</td>
</tr>
</table>
<div id="barra"></div>';
}

echo'
<div style="clear: both;"></div>
<div style="clear: both;"></div>';

$dir2="universo/actividades/";
$sql2 = mysql_query("SELECT tbl_encomenda.id_encomenda,
tbl_actividade.id_actividade, tbl_actividade.entidade,
tbl_actividade.preco, tbl_imagem_produto.actividade_id,
tbl_imagem_produto.imagem1, tbl_encoact.encomenda_id,
tbl_encoact.actividade_id, tbl_encoact.preco_actT,
tbl_encoact.data_entrada, tbl_encoact.data_saida, tbl_encoact.dias
FROM tbl_encomenda, tbl_actividade, tbl_encoact, tbl_imagem_produto
WHERE tbl_encomenda.id_encomenda = tbl_encoact.encomenda_id AND
tbl_encoact.actividade_id = tbl_actividade.id_actividade AND
tbl_actividade.id_actividade = tbl_imagem_produto.actividade_id AND
tbl_encomenda.id_encomenda =".$_GET['id']." ORDER BY
tbl_actividade.entidade ASC");
while ($row2 = mysql_fetch_array($sql2)) {
$html.='
<table width="100%" border="0" cellspacing="6" cellpadding="0">
<tr>
<td rowspan="3" scope="col" width="10%"><img src="'.$dir2.''.
$row2['imagem1'].'" alt="'.$row2['entidade'].'" width="70"
height="45" style="width:auto;"/></th>
<td scope="col" class="itemp">Descritivo:</th>
<td colspan="5" scope="col" class="conteudop">'.
$row2['entidade'].'</th>
</tr>
<tr>
<td class="itemp" width="15%">Data Entrada:</td>
<td class="conteudop" width="18%">'.$row2['data_entrada'].'</td>
<td class="itemp" width="15%">Data Sa&iacute;da:</td>
<td class="conteudop" width="18%">'.$row2['data_saida'].'</td>
<td class="itemp" width="15%">Dias:</td>
<td class="conteudop" width="18%">'.$row2['dias'].' dia(s)</td>
</tr>
<tr>
<td class="itemp">Pre&ccedil;o/dia:</td>
<td class="conteudop">'.$row2['preco'].' EUR</td>
<td class="itemp">Valor Total:</td>
<td class="conteudop">'.$row2['preco_actT'].' EUR</td>
</tr>
</table>
<div id="barra"></div>
';
}


$html.='
<table width="100%" border="0" cellspacing="6" cellpadding="0">
<tr>
<td rowspan="5" scope="col" width="10%"></td>
<td scope="col" class="item"></th>
<td colspan="5" class="conteudo"></th>
</tr>
<tr>
<td class="item" width="15%"></td>
<td class="conteudo" width="18%"></td>
<td class="item" width="15%"></td>
<td class="conteudo" width="18%"></td>
<td class="itemp" width="14%">SubTotal:</td>
<td class="conteudop" width="16%">'.$row['subTotal'].' EUR</td>
</tr>
<tr>
<td class="item"></td>
<td class="conteudo"></td>
<td class="item"></td>
<td class="conteudo"></td>
<td class="itemp">Peso Total:</td>
<td class="conteudop">'.$row['pesoTotal'].' Kg</td>
</tr>
<tr>
<td class="item"></td>
<td class="conteudo"></td>
<td class="item"></td>
<td class="conteudo"></td>
<td class="itemp">Taxas Transp.:</td>
<td class="conteudop">'.$row['taxasTotal'].' EUR</td>
</tr>
<tr>
<td class="item"></td>
<td class="conteudo"></td>
<td class="item"></td>
<td class="conteudo"></td>
<td class="itemp">Total:</td>
<td class="conteudop">'.$row['total'].' EUR</td>
</tr>
</table>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('letter', 'landscape');
$dompdf->render();
$dompdf->stream("exemplo-01.pdf");
?>

BrianS

unread,
Oct 20, 2011, 10:41:40 AM10/20/11
to dompd...@googlegroups.com
On Thursday, October 20, 2011 9:24:46 AM UTC-4, armando ferreira wrote:

The version is 0.62 Beta.
sorry but I am a new user php. What is the file that I go to change
PHP setting display_errorsto false?

No worries. Typically you would do this in your php.ini so that it affects all files on your site. The drawback is that you don't see errors in the browser, but typically you wouldn't want to have those shown to the general public. That's what error logging is for.

So back to the question at hand. You can place this code in the file you're using to convert your document. Are you doing this via dompdf.php or have you written your own script? Since you're just getting started you may want to continue to display errors, but turn off output buffering:

ini_set(output_buffering, 0);

armando ferreira

unread,
Oct 20, 2011, 12:16:26 PM10/20/11
to dompd...@googlegroups.com

Brian
I tried your code, but the error remains.
I do not know what to do. I have already installed fonts, I have reviewed all the code and nothing...



What can I do?

BrianS

unread,
Oct 20, 2011, 10:59:29 PM10/20/11
to dompd...@googlegroups.com
post your PDF here so someone can take a look at it
Reply all
Reply to author
Forward
0 new messages