David Woosley wrote:

I have the following Java code in my JSP.  I'm attempting to open a source
template and write a small block of text on it.

You weren't subscribed when you posted your question.
It was held by the list server at SourceForge and it seems
that this service was constipated: today I received over 200
mails dating from december (I removed all the SPAM mails
so that they don't reach the list).

 As best I understand iText,
this seems like a very simple thing to accomplish, as follows:

// START OF CODE ===============================

PdfReader reader = new PdfReader("source.pdf");
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream("target.pdf"));
Don't do this:

PdfWriter writer = stamper.getWriter();
PdfContentByte contentByte = writer.getDirectContent();
Do this instead:
PdfContentByte contentByte = stamper.getUnderContent(pagenumber);
or
PdfContentByte contentByte = stamper.getOverContent(pagenumber);

Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9);
Phrase phrase = new Phrase("Hello",font);
ColumnText columnText = new ColumnText(contentByte);
columnText.setSimpleColumn(100f, 100f, 300f, 300f);
columnText.setAlignment(Element.ALIGN_JUSTIFIED);
columnText.addText(phrase);

// At this point, none of the above objects are null
// and everything looks great, until we hit this line ...

int status = columnText.go(false); // KABOOM!

// END OF CODE ===================================

I get a null exception.  If I simulate writing with columnText.go(true),
then I don't get the error.  Help?  Any suggestions?




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to