Different paper size and orientation in different page

932 views
Skip to first unread message

yk

unread,
Nov 9, 2011, 6:21:09 PM11/9/11
to dompdf
Thanks for this great and easy-to-use's pdf generator.

About the subject, I know it has been asked recently, so I won't ask
if it's possible to do it. ;)
I'm currently in need to create a different page size in the same pdf.
I'll be looking for this feature to be added in the near future.

In the meantime, I've created a quick hack that make this task
possible.
I've tested it using a very simple html, so errors are expected.

Though it's not a clean solution (messy codes, poor workflow, and
all), I'm excited to share my work and see some feedbacks.

Hopefully, it could help someone who are looking to accomplish this
same task.

http://www.mediafire.com/?g9lkzx3gl170nyb

Best regards,

~yk~

BrianS

unread,
Nov 9, 2011, 8:43:53 PM11/9/11
to dom...@googlegroups.com
Very nice! Glad to see a contribution like this.

We really haven't had a chance to look into what it would take, but ideally this is something that would be supported by the PDF backend. CPDF doesn't currently support modifying the layout after instantiation, so it will require a bit of work to update. In the meantime your "add-on" might prove useful for people.

Thanks again,
-b

Craig Francis

unread,
Mar 26, 2013, 4:11:01 PM3/26/13
to dom...@googlegroups.com
Hi Yakub Kristianto,

Just to say thanks for your code example, its really helped me out in changing the page size/orientation.

But also wanted to add that I have noticed a couple of issues... if you introduce a new font on page 2 or later, or start using custom (ttf) fonts (they are made up of several objects)... also I think there is an issue with two or more images with the same dimensions.

I've tried two different approaches... one extending your work, by re-indexing the font and image objects (and the references to them), which kind of works (attached)... I've also thought about updating cpdf so newDocument() can be called multiple times (but I started having issues with dompdf on this route).

I've started commenting on the issue on GitHub, but not found a way to add code to this yet:


Anyway, thanks again,
Craig
dompdf_pages.php
Message has been deleted

Craig Francis

unread,
Mar 28, 2013, 10:25:05 AM3/28/13
to dom...@googlegroups.com
Have also found a small issue with Adobe Reader, so have decided to put changes on GitHub:



For reference, I had just kept the first "pages" object, then appended the additional "page" objects from the other pdf's on to it (I think in the same way as the original solution), but according to the spec, its better to add a new parent "pages" object, and add the individual "pages" objects under that with a link back up to the parent (ref page 705).


As in pages->pages->page.

So I submit a v2... which requires a slight change to cpdf in how it produces the "pages" object output... as it currently does not consider the idea of it having a parent, or that the top level "pages" will need to count the total number of "page" objects under it (not the number of immediate children).
Reply all
Reply to author
Forward
0 new messages