Insert a PDF object in between

2,129 views
Skip to first unread message

Dixon MD

unread,
May 16, 2012, 7:16:59 AM5/16/12
to dom...@googlegroups.com
I want to know can we add a PDF page in between the HTML pages.

<html>
<body>

some html pages

-----------------------------------------
insert a already created PDF
-----------------------------------------

some html pages

</body>
</html>


BrianS

unread,
May 16, 2012, 9:10:38 PM5/16/12
to dom...@googlegroups.com
That is certainly possible. The PDF can be included either via iframe or the object element. It's been a while since I've done anything like this, but in the past iframe was the more reliable method. There are lots of pages out there discussing the topic. Some of them even have methods that work for users who don't have a PDF reader. A could links:

Dixon MD

unread,
May 16, 2012, 11:55:03 PM5/16/12
to dom...@googlegroups.com

Actually I need to embed the PDF file in the dompdf generator.

<?php

$html =
'<html>

<body>

some html pages

-----------------------------------------
insert a already created PDF
-----------------------------------------

some html pages

</body>
</html>'

$dompdf = new DOMPDF();
$dompdf->load_html($html);

$dompdf->render();
$dompdf->stream("hello_world.pdf");

?>

BrianS

unread,
May 17, 2012, 5:58:34 PM5/17/12
to dom...@googlegroups.com
That's a different story all-together. There's not really a way to do that using dompdf alone. You would need to first render the HTML to PDF (maybe in two parts), then combine them using another tool like pdftk (system binary) or PDF Merger. I haven't tried PDF Merger, but pdftk works like a champ.

Dixon MD

unread,
May 22, 2012, 12:23:20 AM5/22/12
to dom...@googlegroups.com
Thank you...

mtbinary

unread,
May 22, 2012, 4:07:34 PM5/22/12
to dompdf
I need some related help. I am merging the PDF I create with dompdf
with an existing PDF using an old version of PDFLib.

My problem is that my output from dompdf is reducing my page content
to 'fit' 8.5 x 11 and is adding header and footer content in the same
manner it would if I was printing my html page to a printer.

What I want is to set my pixels (in a table or div for instance) to
612w x 792h and create a pdf of my table at exactly that size. Can
anyone tell me how to bypass the addition of the page margins and
convert only my table at its original size? I'm stumped.

mtbinary

unread,
May 22, 2012, 4:18:24 PM5/22/12
to dom...@googlegroups.com
This is a second attempt to post my question. Not sure where the first went?!?!

I am trying to merge two PDFs. I use dompdf to convert my html to a PDF and then use PDFlib to marry the two pdfs.

My problem is that when I create my pdf with dompdf, the output is reduced to fit on the page as well as adding a header and footer, much like it would if I sent the page to print. What I would like to achieve is an output of only my table that is sent to 612px by 792px without the size reduction or the additions of headers or footers.

Any ideas? I can't seem to find anything that solves the issue.

BrianS

unread,
Jun 2, 2012, 9:51:13 PM6/2/12
to dom...@googlegroups.com
So you need your content to fill an entire standard 8.5" x 11" page? dompdf by default includes margins around the edge of the page. You can ensure that this margin is zero through your stylesheet (e.g. @page, body {margin: 0px; padding: 0px;}). Then if you specify the height/width of your content to fill the page it should do so.
Reply all
Reply to author
Forward
0 new messages