Automatically bring up the print dialog when PDF-document opened

4,663 views
Skip to first unread message

Sergey R

unread,
Sep 13, 2010, 6:53:37 AM9/13/10
to dompdf
We should generate a pdf that automatically bring up the print dialog
when opened.
Does dompdf allow to do it? Please let us know if any ways are exists
for solving this issue.

Thanks.

Sergey R.

BrianS

unread,
Sep 13, 2010, 3:20:18 PM9/13/10
to dompdf
DOMPDF 0.6.0 will support PDF JavaScript. According to the API there
is a Doc.print() method. I don't generally use JavaScript in my PDF
documents, so I couldn't say how exactly you would set this up.
Perhaps you can just add to the end of your HTML document the
following (inside the closing body tag):

<script type="text/javascript">
this.print(true)
</script>

But I don't know that this will work. Perhaps someone more familiar
with PDF/JS can provide a little more guidance.

Here the Adobe reference for Acrobat 8:
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf#page=326

Sergey R

unread,
Sep 14, 2010, 7:44:32 AM9/14/10
to dompdf
Thanks for answer. Yes, I using DOMPDF 0.6.0 beta1.
But when I put into html before </body> next:

<script type="text/javascript">
this.print();
</script>

But when I open pdf-document then I got the error:
"There was an error openton this document. The file is damaged and
could not be repaired."

Please help to solve this problem.

Thanks.

Sergey R.

On 13 сен, 22:20, BrianS <eclecticg...@gmail.com> wrote:
> DOMPDF 0.6.0 will support PDF JavaScript. According to the API there
> is a Doc.print() method. I don't generally use JavaScript in my PDF
> documents, so I couldn't say how exactly you would set this up.
> Perhaps you can just add to the end of your HTML document the
> following (inside the closing body tag):
>
> <script type="text/javascript">
> this.print(true)
> </script>
>
> But I don't know that this will work. Perhaps someone more familiar
> with PDF/JS can provide a little more guidance.
>
> Here the Adobe reference for Acrobat 8:http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_...

Fabien Ménager

unread,
Sep 14, 2010, 8:08:19 AM9/14/10
to dompdf
Hello, does the JavaScript example provided with dompdf 0.6 work on
your server ?

Sergey R

unread,
Sep 14, 2010, 9:16:53 AM9/14/10
to dompdf
No, it does not work.

Sergey R

unread,
Sep 14, 2010, 9:47:00 AM9/14/10
to dompdf
Hello! I solved the problem. It was the bug in DOMPDF. Bug was in file
lib\class.pdf.php on line 1413.
The string
$res .= "\n".$id." 0 obj\n".'<< ';
should be replaced
$res = "\n".$id." 0 obj\n".'<< ';

Thanks for all for help.

Sergey R.

Fabien Ménager

unread,
Sep 14, 2010, 11:48:35 AM9/14/10
to dompdf
ok, this is already fixed in the SVN trunk ;)
That's why I couldn't reproduce it
Reply all
Reply to author
Forward
0 new messages