Unable to open generated PDF in Adobe Reader

2,098 views
Skip to first unread message

Juraj

unread,
Oct 26, 2009, 7:42:43 AM10/26/09
to dompdf
Hi,

I am unable to open generated PDF in Adobe Reader 9. It says: .. could
not open because it is either not a supported file type or because the
file has been damaged.

However, I can open the file in Document Viewer on Ubuntu without
problems.

Any thoughts?

Cheers
Juraj

Paul Waring

unread,
Oct 26, 2009, 7:44:04 AM10/26/09
to dom...@googlegroups.com
Juraj wrote:
> I am unable to open generated PDF in Adobe Reader 9. It says: .. could
> not open because it is either not a supported file type or because the
> file has been damaged.
>
> However, I can open the file in Document Viewer on Ubuntu without
> problems.

Can you post the source which you are using to generate the PDF
somewhere - e.g. pastebin.com? Otherwise it's quite difficult to track
down what might be causing the problem.

Cheers

Paul

--
Paul Waring
http://www.pwaring.com

Juraj

unread,
Oct 26, 2009, 10:49:36 AM10/26/09
to dompdf
On Oct 26, 11:44 am, Paul Waring <p...@xk7.net> wrote:
> Juraj wrote:
> > I am unable to open generated PDF in Adobe Reader 9. It says: .. could
> > not open because it is either not a supported file type or because the
> > file has been damaged.
>
> > However, I can open the file in Document Viewer on Ubuntu without
> > problems.
>
> Can you post the source which you are using to generate the PDF
> somewhere - e.g. pastebin.com? Otherwise it's quite difficult to track
> down what might be causing the problem.
>

Hi Paul,

Controlelr code:
http://pastebin.com/m2222aaac

Template is just HTML, inline CSS and one external image (<img/> plus
this:
<script type="text/php">
$font = Font_Metrics::get_font("verdana", "bold");
$pdf->page_text(500, 10, "MyHeader", $font, 9, array(0,0,0));
</script>

I could send over a sample PDF that's not working.

Thanks
Juraj

Ryan Masten

unread,
Oct 26, 2009, 12:26:38 PM10/26/09
to dompdf
You mention that you can open it fine in Document Viewer on Ubuntu.
What OS are you trying the Acrobat reader?

BrianS

unread,
Oct 26, 2009, 1:35:47 PM10/26/09
to dompdf
On Oct 26, 10:49 am, Juraj <ju...@jurajsplayground.com> wrote:
> On Oct 26, 11:44 am, Paul Waring <p...@xk7.net> wrote:
>
> > Juraj wrote:
> > > I am unable to open generated PDF in Adobe Reader 9. It says: .. could
> > > not open because it is either not a supported file type or because the
> > > file has been damaged.
>
> > > However, I can open the file in Document Viewer on Ubuntu without
> > > problems.
>
> > Can you post the source which you are using to generate the PDF
> > somewhere - e.g. pastebin.com? Otherwise it's quite difficult to track
> > down what might be causing the problem.
>
> Hi Paul,
>
> Controlelr code:http://pastebin.com/m2222aaac
>
> Template is just HTML, inline CSS and one external image (<img/>)

Your PHP looks fine. Can you provide the actual HTML code as well? If
not that's fine, but you should check it with a validator to ensure no
structural problems are present.

> plus this:
> <script type="text/php">
> $font = Font_Metrics::get_font("verdana", "bold");
> $pdf->page_text(500, 10, "MyHeader", $font, 9, array(0,0,0));
> </script>

Have you successfully loaded verdana into your DOMPDF installation
using load_font.php? If not then this is probably where you're running
into trouble. You can test this by using

$font = Font_Metrics::get_font(null);

which will return the default font.

> I could send over a sample PDF that's not working.

A sample PDF might help, but usually the source HTML document can
provide better leads as to the source of the problem.

Finally ... Which version of PHP are you using? Which version of
DOMPDF?

Juraj

unread,
Oct 26, 2009, 1:52:48 PM10/26/09
to dompdf
On Oct 26, 4:26 pm, Ryan Masten <ryan.mas...@gmail.com> wrote:
> You mention that you can open it fine in Document Viewer on Ubuntu.
> What OS are you trying the Acrobat reader?

Windows XP Pro
Message has been deleted

Yves

unread,
Oct 26, 2009, 5:14:35 PM10/26/09
to dompdf
I have a similar problem: http://pastebin.com/m68ea15a9
HTML is compliant XHTML 1.0 dompdf is version 0.5.1
PDF gets created, but Adobe Acrobat says it corrupted (running WinXP).
Any hints on how to deal with that?
Yves

BrianS

unread,
Oct 26, 2009, 6:34:30 PM10/26/09
to dompdf
On Oct 26, 5:14 pm, Yves <y...@yvesonline.de> wrote:
> I have a similar problem:http://pastebin.com/m68ea15a9
> HTML is compliant XHTML 1.0 dompdf is version 0.5.1
> PDF gets created, but Adobe Acrobat says it corrupted (running WinXP).
> Any hints on how to deal with that?
> Yves

I was able to render your document, though I did have to work around
one issue: if you have PHP short_open_tags set to "on" PHP may throw
and error when attempting to render the document. I'm not sure if this
is the source of your problems, but here are a few work-arounds you
can try:

- if you don't need to run inline script set DOMPDF_ENABLE_PHP to
false; when this setting is enabled DOMPDF performs an initial pass
that executes any regular PHP code prior to rendering the document
- if your scripts do not rely on short open tags turn this setting off
in your php.ini; using the ini_set() function does not appear to work
in (limited) testing
- load your HTML document into a variable and use string replacement
to remove the XML declaration before passing this variable to DOMPDF

That being said, I did not have access to any of the images or CSS for
your file since relative URLs are used. If you want me to fully test
your document and can share the domain on which this page is hosted
I'll update the HTML to point to your domain to retrieve these assets.
-b

Yves

unread,
Oct 27, 2009, 11:56:49 AM10/27/09
to dompdf
thanks for the quick reply...
- setting DOMPDF_ENABLE_PHP to false did not work for me
- short_open_tag is already set to false in php.ini
- removing the XML <?xml version="1.0" encoding="iso-8859-1" ?>
declaration did not work for me either.
I would definitely like to share the whole document and domain with
you but my employer does not allow this.
Is there a log which dompdf writes where I can analyze what is
happening? What else can I do? I think there must be a way because you
could work it out to render the page.
Yves

BrianS

unread,
Oct 27, 2009, 3:32:17 PM10/27/09
to dompdf
DOMPDF will report errors the same as any other PHP code. If you have
display_errors set to off then you will not see them on screen. If you
have log_errors enabled then any problems encountered should show up
in your PHP error.log. Still, I wouldn't expect the PDF to generate at
all if DOMPDF was encountering problems serious enough to cause error.

Two things you might try:
1) remove the reference to your CSS file(s) and see if the results are
better; if so then you know something about your CSS is causing
problems
2) set $_dompdf_show_warnings = true; this will display any
warnings ... but typically the warnings aren't from problems that rise
to the level of corrupting the PDF output

If you're using v0.5.1 you can't turn on debugging ($_dompdf_debug) on
systems that use more recent versions of PHP (I can't remember the
exact version). The latest DOMPDF alpha, however, rectifies this
problem. But honestly, I doubt you'll get much from the debugging
output. Your best bet is to try the two steps above.

Good luck.
-b

Juraj

unread,
Nov 12, 2009, 5:21:50 AM11/12/09
to dompdf
Hi,

Been working on a different project and now got back to this.

On Oct 26, 5:35 pm, BrianS <eclecticg...@gmail.com> wrote:
>
> Your PHP looks fine. Can you provide the actual HTML code as well? If
> not that's fine, but you should check it with a validator to ensure no
> structural problems are present.

Sample HTML, hello world example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Company Report</title>

</head>
<body>
Hello World!

</body>
</html>

>
> > plus this:
> > <script type="text/php">
> > $font = Font_Metrics::get_font("verdana", "bold");
> > $pdf->page_text(500, 10, "MyHeader", $font, 9, array(0,0,0));
> > </script>
>
> Have you successfully loaded verdana into your DOMPDF installation
> using load_font.php? If not then this is probably where you're running
> into trouble. You can test this by using
>
>   $font = Font_Metrics::get_font(null);
>
> which will return the default font.

The above with "null" works but still generates a PDF that cannot be
opened in Adobe Reader.

> Finally ... Which version of PHP are you using? Which version of
> DOMPDF?

dompdf v0.5.1, PHP 5.2.10-2ubuntu6.1

Any ideas? I briefly tried the latest dompdf version but that resulted
in the same problem.

Juraj

unread,
Nov 12, 2009, 6:03:35 AM11/12/09
to dompdf
Please disregard this problem. I just found out that there was some
HTML being printed before the actual PDF, i.e. output buffer captured
HTML, then streamed PDF and served it as one file.

Thank you all for your help.

Juraj

BrianS

unread,
Nov 12, 2009, 1:31:13 PM11/12/09
to dompdf
Excellent, thank you for the update. This is something we'll have to
keep in mind if the problem crops up in the future. If it proves to
consistently be the source of the problems we'll have to add a FAQ
entry.

Juraj

unread,
Nov 16, 2009, 7:04:34 AM11/16/09
to dompdf
I've noticed that dompdf/cpdf checks if headers have been sent prior
to streaming it.

In my case, however, application captures everything into a buffer so
check for headers was not effective, perhaps buffer can be either
cleaned or exception should be thrown if there is anything in the
buffer before dompdf streams raw PDF data.

Regards.
Juraj

Heather V.

unread,
Nov 24, 2009, 12:05:54 AM11/24/09
to dom...@googlegroups.com
I still haven't been able to figure out why mine won't generate. Too bad. This seemed like such a nice program.

psychoactive

unread,
Nov 24, 2009, 11:24:56 AM11/24/09
to dompdf
you're just gonna give up like that?

what is the problem that you are having? is the document being
generated and it wont open in reader? or is it not generating the
document at all?

trust me, we'll get it working. it's not that hard...

Heather V.

unread,
Nov 24, 2009, 11:40:40 AM11/24/09
to dom...@googlegroups.com
(hahaha) I didn't give up on it. I had to scratch it because I was overdue on a project.

I would DEFINITELY like to get it working!

The error I'm receiving is the following:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 76272445 bytes) in C:\..\roster.php on line 135

Line 135:
$html .= $row_getMem["address"]. ' ' . $row_getMem["apt_suite"] . '<br />';

There are 88 records with the use of 9 fields in the database table that I'm trying to generation as a roster (name, address, phone, email, etc.).

So what would be the first step that I should take to fix this problem?

BTW, thanks for being diligent in assisting me with this problem, again.

toad78

psychoactive

unread,
Nov 24, 2009, 1:51:59 PM11/24/09
to dompdf
oh yes, that was you... well... i said before... your max allowed
memory size is 128mb, i don't know where that setting is (adobe, php
or dompdf) but that is the problem... did you already adjust that?

On Nov 24, 8:40 am, "Heather V." <toa...@gmail.com> wrote:
> (hahaha) I didn't give up on it. I had to scratch it because I was overdue on a project.
> I would DEFINITELY like to get it working!
> The error I'm receiving is the following:Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 76272445 bytes) inC:\..\roster.phpon line135Line 135:

psychoactive

unread,
Nov 24, 2009, 4:26:34 PM11/24/09
to dompdf
not adobe, I meant apache.

here is what i have, i think i only changed it in php.ini

php.ini - memory_limit = 700

BrianS

unread,
Nov 24, 2009, 8:48:51 PM11/24/09
to dompdf
On Nov 24, 11:40 am, "Heather V." <toa...@gmail.com> wrote:
> (hahaha) I didn't give up on it. I had to scratch it because I was overdue on a project.
> I would DEFINITELY like to get it working!
> The error I'm receiving is the following:Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 76272445 bytes) inC:\..\roster.phpon line135Line 135:
> $html .= $row_getMem["address"]. ' ' . $row_getMem["apt_suite"] . '<br />';
> There are 88 records with the use of 9 fields in the database table that I'm trying to generation as a roster (name, address, phone, email, etc.).
> So what would be the first step that I should take to fix this problem?

Are you sure this is a problem with DOMPDF? The line you're
referencing appears to possibly be occurring before you even pass the
data to DOMPDF. Without more information the only way I can see DOMPDF
causing your problem is if you are generating some HTML, rendering
with DOMPDF, generating more html, rendering with DOMPDF, etc ...

If the problem is in DOMPDF, the first thing I would do is to try the
0.6.0 alpha 2 release. It addresses a lot of issues from the 0.5.1
release. Next would be to up memory and execution time limits.
Finally, you might have to modify your HTML (tables, for example, can
eat up a lot of memory).

Heather V.

unread,
Nov 25, 2009, 11:21:24 AM11/25/09
to dom...@googlegroups.com
I've upgraded to 0.6.x, received same error message.

I've upped the memory_limit in php.ini to 700M and memory_execution_time to 300

Results:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 76272445 bytes) in C:\..\roster.php on line 135

Code (thanks to Bastien's help):
<?php require_once('../../..'); ?>
<?php require_once('../../../');

if (!function_exists("GetSQLValueString")) {
  function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
    switch ($theType) {
      case "text":
        $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
        break;   
      case "long":
      case "int":
        $theValue = ($theValue != "") ? intval($theValue) : "NULL";
        break;
      case "double":
        $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
        break;
      case "date":
        $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
        break;
      case "defined":
        $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
        break;
    }
    return $theValue;
  }
}

mysql_select_db($database_user, $user);
$query_getMem = "SELECT members_info.fname, members_info.lname, members_info.address, members_info.apt_suite, members_info.city, members_info.`state`, members_info.zip, members_info.phone, members_info.email FROM members_info ORDER BY lname";
$getMem = mysql_query($query_getMem, $user) or die(mysql_error());
$row_getMem = mysql_fetch_assoc($getMem);
$totalRows_getMem = mysql_num_rows($getMem);

$html ='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">

        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <style type="text/css">
        <!--
        body {
        margin: 1em;
        }
       
        .tablecen {
        margin: 0px auto;
        }
       
        td {
        text-align: left;
        }
       
        .caps {
            text-transform: capitalize;
            }
        h1 {
            font: bold 18px Georgia, "Times New Roman", Times, serif;
            text-align: center;
        }
        -->
        </style>
        </head>
        <body>';

// define the starting year
$startYear = 2009;
// calculate the current year
$thisYear = date("Y");

if ($startYear==$thisYear) {
// if both are the same, just show the starting year
$html .= $startYear;
}
else {
// if they"re different, show both
$html .= "$startYear-$thisYear";
}


$html .= '</h1>
          <table class="tablecen" width="800" >
          <tr>';

$getMem_endRow    = 0;
$getMem_columns   = 3; // number of columns
$getMem_hloopRow1 = 0; // first row flag

do {
    if($getMem_endRow == 0  && $getMem_hloopRow1++ != 0){ $html .= "<tr>"; }

    $html .= '<td><p><span class="caps">'. $row_getMem["fname"] . ' ' . $row_getMem["lname"];
    $html .= '<br />'.

    $html .= $row_getMem["address"]. ' ' . $row_getMem["apt_suite"] . '<br />';
    $html .= $row_getMem["city"]. '</span> <span style="text-transform: uppercase;">' . $row_getMem["state"] .'</span> ' . $row_getMem["zip"] . '<br />';
   
    if (!empty($row_getMem["phone"])) { $html .=  $row_getMem["phone"] . "<br />"; }
   
    $html .= urls2linksComplex($row_getMem["email"]) . '</p></td>';
    $getMem_endRow++;
    if($getMem_endRow >= $getMem_columns) {
        $html .= '</tr>';
        $getMem_endRow = 0;
    }
} while ($row_getMem = mysql_fetch_assoc($getMem));

if($getMem_endRow != 0) {
    while ($getMem_endRow < $getMem_columns) {
        echo("<td>&nbsp;</td>");
       $getMem_endRow++;
    }
    $html .= "</tr>";
}

$html .= '</table>
          </body>
          </html>';

mysql_free_result($getMem);

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("roster.pdf");
?>

BrianS wrote:
Are you sure this is a problem with DOMPDF? The line you're
referencing appears to possibly be occurring before you even pass the
data to DOMPDF. Without more information the only way I can see DOMPDF
causing your problem is if you are generating some HTML, rendering
with DOMPDF, generating more html, rendering with DOMPDF, etc ...

If the problem is in DOMPDF, the first thing I would do is to try the
0.6.0 alpha 2 release. It addresses a lot of issues from the 0.5.1
release. Next would be to up memory and execution time limits.
Finally, you might have to modify your HTML (tables, for example, can
eat up a lot of memory).

--

You received this message because you are subscribed to the Google Groups "dompdf" group.
To post to this group, send email to dom...@googlegroups.com.
To unsubscribe from this group, send email to dompdf+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dompdf?hl=en.



  

psychoactive

unread,
Nov 25, 2009, 11:26:23 AM11/25/09
to dompdf
If you upped your memory limit to 700, then why is it still 128?

Are you sure you are looking in the right place??

Allowed memory size of 134217728 bytes = 128mb, so the memory limit
has not been increased. this might be dumb, but did you restart the
apache server after you made the change in your php.ini

On Nov 25, 8:21 am, "Heather V." <toa...@gmail.com> wrote:
> I've upgraded to 0.6.x, received same error message.
> I've upped the memory_limit in php.ini to 700M and memory_execution_time to 300
> Results:Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 76272445 bytes) inC:\..\roster.phpon line135Code (thanks to Bastien's help):
> BrianS wrote:On Nov 24, 11:40 am, "Heather V."<toa...@gmail.com>wrote:(hahaha) I didn't give up on it. I had to scratch it because I was overdue on a project. I would DEFINITELY like to get it working! The error I'm receiving is the following:Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 76272445 bytes) inC:\..\roster.phpon line135Line 135: $html .= $row_getMem["address"]. ' ' . $row_getMem["apt_suite"] . '<br />'; There are 88 records with the use of 9 fields in the database table that I'm trying to generation as a roster (name, address, phone, email, etc.). So what would be the first step that I should take to fix this problem?Are you sure this is a problem with DOMPDF? The line you're referencing appears to possibly be occurring before you even pass the data to DOMPDF. Without more information the only way I can see DOMPDF causing your problem is if you are generating some HTML, rendering with DOMPDF, generating more html, rendering with DOMPDF, etc ... If the problem is in DOMPDF, the first thing I would do is to try the 0.6.0 alpha 2 release. It addresses a lot of issues from the 0.5.1 release. Next would be to up memory and execution time limits. Finally, you might have to modify your HTML (tables, for example, can eat up a lot of memory). -- You received this message because you are subscribed to the Google Groups "dompdf" group. To post to this group, send email todo...@googlegroups.com. To unsubscribe from this group, send email todompdf+u...@googlegroups.com. For more options, visit this group at...
>
> read more »

BrianS

unread,
Nov 25, 2009, 2:12:10 PM11/25/09
to dompdf
On Nov 25, 11:26 am, psychoactive <psychoact...@gmail.com> wrote:
> If you upped your memory limit to 700, then why is it still 128?
>
> Are you sure you are looking in the right place??
>
> Allowed memory size of 134217728 bytes = 128mb, so the memory limit
> has not been increased.  this might be dumb, but did you restart the
> apache server after you made the change in your php.ini

This seems like a good question to start with. The allowed memory size
reported in the error should equal your setting when divided by 1024
twice.

That being said, it does seem like you're running out of memory before
you even get to the DOMPDF functions. if you're already running out of
memory you'll probably have even more trouble once DOMPDF starts
processing the file. To test if DOMPDF is even part of the problem you
can take out the DOMPDF stuff and run everything else and see what
happens. You can echo out the $html variable to see what it contains.
It seems unlikely, but perhaps one of the fields in the database just
has a ridiculous amount of data?

psychoactive

unread,
Nov 25, 2009, 2:46:51 PM11/25/09
to dompdf
another thing, i've had infinite loops in inline php cause similar
errors.

Heather V.

unread,
Nov 25, 2009, 10:20:47 PM11/25/09
to dom...@googlegroups.com
DOH!

Restarted and received error:
Error: Fatal error: Allowed memory size of 734003200 bytes exhausted (tried to allocate 610180865 bytes) in C:\...\roster.php on line 135

Heather V.

unread,
Nov 25, 2009, 10:23:44 PM11/25/09
to dom...@googlegroups.com
Before I considered using DOMPDF, I used to just query the info. on a .php page, without any problems. But when my client requested .pdf conversion, I thought I'd try to use DOMPDF. Obviously I've encountered problems.

Heather V.

unread,
Nov 25, 2009, 10:24:37 PM11/25/09
to dom...@googlegroups.com
Please clarify for us stupid folks (talking about myself).

BrianS

unread,
Nov 25, 2009, 11:27:05 PM11/25/09
to dompdf
On Nov 25, 10:23 pm, "Heather V." <toa...@gmail.com> wrote:
> Before I considered using DOMPDF, I used to just query the info. on a .php page, without any problems. But when my client requested .pdf conversion, I thought I'd try to use DOMPDF. Obviously I've encountered problems.
> BrianS wrote:reported in the error should equal your setting when divided by 1024 twice. That being said, it does seem like you're running out of memory before you even get to the DOMPDF functions. if you're already running out of memory you'll probably have even more trouble once DOMPDF starts processing the file. To test if DOMPDF is even part of the problem you can take out the DOMPDF stuff and run everything else and see what happens. You can echo out the $html variable to see what it contains. It seems unlikely, but perhaps one of the fields in the database just has a ridiculous amount of data?

I understand, but you're running into an error before you even load
DOMPDF. Could you try my suggestion to make sure there's not something
else going on? Also, take out the reference to dompdf_config.inc.php
to see if something about referencing that file might be causing the
problem.

Lucca Mordente

unread,
Dec 14, 2009, 12:53:05 PM12/14/09
to dompdf
Try just to get rid of all outputs (direct html, echo, print) inside
the php file which generates the pdf.


On 26 out, 09:42, Juraj <ju...@jurajsplayground.com> wrote:
> Hi,
>
> I am unable to open generated PDF in Adobe Reader 9. It says: .. could
> not open because it is either not a supported file type or because the
> file has been damaged.
>
> However, I can open the file in Document Viewer on Ubuntu without
> problems.
>
> Any thoughts?
>
> Cheers
> Juraj
Reply all
Reply to author
Forward
0 new messages