Frank Fischer wrote:
Hi Bruno
Thanks for you're answer.
I tried to solve it using ColumnText but this somehow doesn't work - when
opening the resulting pdf i get two errors "Illegal operation 'm' inside a
text object" and "Illegal operation 'ET' outside text object". Also the pdf
page looks quite stange. A lot of elements are missing.
That's a very common error. It's easy to solve; see below:
The code i use:
PdfContentByte cb = writer.getDirectContent();
// some other cb drawing here
// cb.beginText();
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252,
BaseFont.NOT_EMBEDDED);
String absender = tenant_company + ", " + tenant_street + " " +
tenant_streetnumber + ", " + tenant_zip + " " + tenant_city;
com.lowagie.text.Font font_absender = new com.lowagie.text.Font(bf, 11,
com.lowagie.text.Font.UNDERLINE);
Phrase absender_phrase = new Phrase(11, "Test2", font_absender);
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(absender_phrase, 60, 150, 100, 250 , 0,
Element.ALIGN_LEFT);
ct.go();
// cb.endText();
// some other cb drawing here
When removing this part of the code, the pdf page is perfectly generated, so
there must be something wrong in the lines above, but i have no idea what i
could be. Maybe you see where i've done a mistake?
You have mixed 'manual text positioning' with 'ColumnText functionality'.
beginText and endText put the markers BT and ET inside your PDF.
'm' is an operator corresponding with moveTo.
Note that Paulo's answer gave you a means to do all the ColumnText stuff
in one line:
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, absender_phrase, 60,
150, 0);
replaces:
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(absender_phrase, 60, 150, 100, 250 , 0,
Element.ALIGN_LEFT);
ct.go();
br,
Bruno
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions