Closed MathieuDerelle closed 5 years ago
Hi @MathieuDerelle ,
Thank you for opening this issue.
AFAIK, copy by reference is the default mode in Ruby, so I don't really see this as surprising behavior. However, I agree that the code in inject_page
and the copy
method might be seen as misleading (copy
is the same as dup
, but it makes sure that the page resources aren't PDF bound).
If you do need to copy a page by value, consider creating a new page and pasting the content of the existing page as an overlay one the ew page.
I didn't try this, so I'm not sure it would solve your issue, but look at:
org_page = pdf1.pages[idx]
target_page = pdf2.new_page(org_page.mediabox)
target_page << org_page
Note that this approach might (and probably will) consume more memory, as some resources need to be copied.
Let me know how it goes.
Kindly, Bo.
I was copying pages from one PDF to two others, rotating pages on the fly and came up with this unexpected behavior :
the rotation was applied twice, which means that the pages were still linked by reference
but the code of
inject_page
seems to indicate that objects should not be passed by referenceI tried
but the above code raised
I ended up going for :
but how to apply different rotations for the two different output PDF ?