Ethan King wrote:
> This question has kind of been addressed in the past but not as directly 
> as some would hope.  I am looking to use iTextSharp to do 
> something similar to the Bates numbering function in Adobe Acrobat 8. 
>  
> Basically I would like the shrink the contents of a PDF page to allow a 
> margin above and below the original content that I can then put 
> additional information in. 
>  
> So for example I might want to put the word "CONFIDENTIAL" at the bottom 
> of each page in a PDF but I don't want it to appear over the top any 
> original content.  So I would like to "shrink" the content so that I can 
> fit the word "CONFIDENTIAL" below it.
>  
> Any help that someone might be able to give me would be greatly appreciated.

There's more than one way to do this, but every solution has its
downside.

1. You could create a new Document and PdfWriter to produce
a PDF file with the desired page size.
Then create a PdfReader that reads the existing PDF file.
Ask the PdfReader for the number of pages and get every
page as a PdfImportedPage in a loop. Wrap the PdfImportedPage
in an Image object, scale (shrink) the image object, and add
it to the new document with the desired offset, along with
the extra content above or under the image.

Downside: PdfImportedPage works like a photocopy machine:
it copies the content (as it would appear on paper), but
it doesn't copy the interactive features (hyperlinks, form
fields,...). If you have such features in your PDF, you
will have to do a lot of extra work retrieving them from
the original document, transforming the coordinates and
adding the features to the new document.

2. How important is the actual page size to you?
If you don't mind Adobe reader to resize the document,
then you may keep the content as is, but change the
page boundaries. In this case, you'll need PdfReader
and PdfStamper. With PdfReader, you'll loop over all
the pages and change the page boundaries; then with
PdfStamper, you add the new content so that it's outside
the original boundaries, but inside the new ones.

Downside: the PDF document won't have a standard page size
anymore. I'm not sure if there's a way to work around this.

br,
Bruno

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to