Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] How to write new line with PdfTemplate

Henry Doan

2006-06-19

Replies:

I am trying to write multiple line with PdfTemplate but everytime i write a
new line with PdfTemplate.newlineShowText() it write over the previous line.

Here is my code: Thanks in advance

 PdfReader reader = new PdfReader("e:/Webs/walton/Hello World 7.pdf");

 PdfStamper stamper = new PdfStamper(reader, baos);

 PdfContentByte cb = stamper.getUnderContent(1);

 // PdfTemplate
       PdfTemplate template = cb.createTemplate(500,500);

 template.beginText();
       BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
       template.setFontAndSize(bf, 7);
     template.setLeading(2);
       template.showText("SOME TEXT HERE\n");
     template.newlineShowText("asfasdfdfadfASDFADF");
       template.endText();
 //                X   Y
 cb.addTemplate(template, 100, 800);

 stamper.close();
 reader.close();

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
©2008 junlu.com - Jax Systems, LLC, U.S.A.