Re: dompdf cut the html in two pages after setting custom page size

1,760 views
Skip to first unread message

BrianS

unread,
Apr 15, 2013, 11:16:39 AM4/15/13
to dom...@googlegroups.com
It would help to see the full HTML document (or at least a sample). Other than splitting into two pages does the layout appear correct?


On Monday, April 15, 2013 4:15:48 AM UTC-4, Shail paras wrote:
hi..
i am using dompdf to convert html to pdf. it is working fine as my expectation. but it is cutting html in two page. i don't understand why it is this happening.
i have used custom page size for it... actually i have created a grid with lots of boxes (i have used 'div' tag to make this.)..in a container<br>container size in 12" X 12" (inches).
And i have converted it in points(pt) by multiplying 72.
there is my code:

    ob_start();   
    echo "<style>@page { margin:0in 0in 0in 0in; }</style>";
    echo $content;
    $contents = ob_get_clean();
    $dompdf = new DOMPDF();
    $dompdf->load_html($contents);
    $dompdf->set_paper(array(0,0,12*72,12*72), 'portrait');
    $pdf = $dompdf->output();
    $dompdf->stream("sample.pdf");

$content is my variable in which i have put my all html contents.
I don't understand why it is happening ... Am i missing something here or any changes require in dompdf lib files...
Any help or any idea to do that..
Thanks in advance.


Shail paras

unread,
Apr 15, 2013, 1:51:04 PM4/15/13
to dom...@googlegroups.com
Thanks BrianS for reply..
i have attached full html sample and also some php script which i have used to convert html to pdf.
and there is no issue about layout.
Please check and let me know what i am missing here.
Thanks in advance.
htmlcontent.html
sample.pdf
sample.php

BrianS

unread,
Apr 16, 2013, 2:47:48 PM4/16/13
to dom...@googlegroups.com
This looks like buggy behavior. If you take everything out of the container div then you get a multi-page PDF that is definitely not correct. This is possibly a bug around white space and paging, though I can't be sure without further testing.

You can achieve the correct appearance by positioning your outer DIV absolutely, ignoring width and height, and specifying the edge positions. The following appears to work: <div style="border: 0.042in solid transparent; text-align: center; position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; background: none repeat scroll 0% 0% #ffffff;" class="canvasbox">

Shail paras

unread,
Apr 16, 2013, 3:44:46 PM4/16/13
to dom...@googlegroups.com
Thanks Brians..
I have already tried this trick before but won't worked for me..
Now. i guess this is happening because white space and commented line ... and now i have just removed all white space and commented lines by using some regex.. and now it is working fine.
Thanks again... 

BrianS

unread,
Apr 17, 2013, 5:59:22 PM4/17/13
to dom...@googlegroups.com
Thanks for the update. I'll make a test case so we can investigate further.
Reply all
Reply to author
Forward
0 new messages