This is almost certainly a dumb question as I have very little iText
experience, but I've been through the list archives and miscellaneous
websites and can't figure it out. There's a sample PDF at
http://mrozekma.com/itext.pdf that won't display text I stamp on it.
It's some property of the pages rather than the entire document; the
first page is a page I added manually with PdfStamper.insertPage, and
that page has the "This is a test" text I'm trying to add to both pages,
but the second page that was part of the original document shows
nothing. Unless I'm checking wrong, there doesn't appear to be a crop
box or any odd rotations, the usual things that cause text to not show
up when it should. Here's the code I'm running (I changed the text
matrix Y from 300 to 350 so rerunning it shows two lines of text on the
first page):
final PdfReader reader = new PdfReader("/tmp/itext.pdf");
final FileOutputStream os = new
FileOutputStream("/tmp/out.pdf");
final PdfStamper stamper = new PdfStamper(reader, os);
final BaseFont font =
BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI,
BaseFont.EMBEDDED);
// This was used to create the first page in the current
itext.pdf:
// stamper.insertPage(1, PageSize.LETTER);
PdfContentByte content = null;
for(int page = 1; page <= reader.getNumberOfPages(); page++) {
content.beginText();
content.setFontAndSize(font, 10);
content.setColorFill(Color.RED);
content.setTextMatrix(50, 350);
content.showText("This is a test");
content.endText();
}
stamper.close();
os.close();
I've been using iText in a project I'm working on and this is the first
document I've had a problem with; I can't figure out what's different
about this particular one. Thanks for any ideas
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/