Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Add content to an existing PDF document

Anthony Maguire

2007-06-25

Replies:

Hi,

I'm new to using iText and while it looks like its the application i need to use, one thing i just can't find anywhere is what is the best way to add content to an existing document. I assume this is a question every newbie asks and i thought the answer would be on the FAQ, but i haven't found it there, or the parts of the mailing list that i've gone through.

As it stands i'm getting a handle on the PDFStamper and the PDFContentByte object of the document i want to change. After that i'm basically just writing text to designated coordinates, and through trial and error finding out the right coordinates. But it there a better way than this, should i be overlaying a table and writing to the table and it cells. One of the problems i've noticed is that i need some text to be RIGHT justified and to do that, i create a Chunk object with the text, getWidthPoint and write to the point i want to write to minus the result of the getWidthPoint. Problem is here, if i change fonts, then the alignment is off.

Also i need to write some texts to the document, does wrapping work automatically or do i need to figure out how long each line is and only right out the amount less than the width of the document?

Sorry if this email is long-winded, and i can only imagine one that has been answered many times before, but i can't find the necessary threads. I have also bought the iText in Action book, but it doesn't say definitely what can and cannot be done. And the document i'm writing to is an AcroForm document.

Thanks in advance,
Anthony Maguire
Oakton
ph: (03) 9617 0200
fax: (03) 9621 1951
Mobile: 0416 766 931
www.oakton.com.au <https://melb.oakton.com.au/exchweb/bin/redir.asp?URL=http://www.oakton.com.au>

IMPORTANT
1.  This email and any attachments are confidential. Any unauthorised dissemination or other use of these materials is prohibited. If received in error, please contact us and delete all copies.
2.  Before opening or using attachments, check them for viruses and defects. Our liability is limited to resupplying any affected attachments.
3.  Protecting your privacy is important to us. Our privacy statement and further information is available at www.oakton.com.au.

-------------------------------------------------------------------------
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@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.