On 10/05/2012 2:00, [email protected] wrote:
It would seem that I should probably be using PdfStamper somehow (even
though I think that will result in a different approach to increasing
the page size.
That's possible, but you'll have to do more Math.
However, unless I have mis-read this many times now, I thought the
whole idea to
writer.getImportedPage()
was to retain interactive features by letting the writer use the reader?
No, as explained in table 6.1, using PdfWriter + PdfImportedPage throws
away all interactive features.
Or is that only when using PdfCopy/SmartCopy?
Yes, that's what table 6.2 tells you.
You have read "iText in Action", but you're missing one important concept.
In PDF, you have content and you have annotations.
You'll find the content of a page as a (series of) stream(s) in the page
dictionary. There's the /Contents entry, and also the XObjects under
/Resources.
You'll find the annotations as a series of dictionaries in the page
dictionary. Look for the /Annots entry.
Currently, you are only copying (and scaling) the content.
You are ignoring all the interactive features (links, annotations, field
widgets,...).
I have never understood why people want to enlarge a PDF (PDFs are
usually vector based and size doesn't really matter), but suppose that
you would like to scale the document, then:
- you have to change the CTM used to draw the content (you already found
out how to do that; iText is a great help because there are plenty of
convenience method that do the math for you, unless you want to use
PdfStamper),
- recalculate all the rectangle values of the annotations (iText won't
help you here; you'll need to do all the Math yourself).
Knowing this, please open your PDF using iText RUPS, and have a look
inside. You'll find annotations with entries named /Rect (the rectangle
defining the position of the interactive feature) looking like this [100
100 300 120]: that's a rectangle with a lower left corner x = 100, y =
100 and an upper right corner x = 300, y = 120. Note that Y-coordinate
of the lower corner has a smaller value than the Y-coordinate of the
upper corner.
If you want to enlarge a PDF document INCLUDING all interactive
features, you should copy the content (you're already doing that), but
ALSO the annotations (so far you've ignored them). When you copy the
annotations, you need to change the coordinates of the annotations using
Algebra (matrix multiplication).
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php