Reputation: 1552
I'm using pdfbox & itextpdf to create very simple invoices in pdf format.
We're creating raw invoice text files in an erp system outside of java - so the only thing i have to do combining the textfile with a (pdf) template. (Thats not the problem. ;) )
It's working fine - but I found now an indentation error in the pdf: After the header of the table, the indentation goes wrong (one leading whitespace is removed).
What I'm doing wrong?
Thats the code, producing the sample pdf:
final File outputFile = this.createTmpFile();
final Document document = new Document(PageSize.A4);
PdfWriter.getInstance(document, new FileOutputStream(outputFile));
document.open();
final StringBuffer testText = new StringBuffer();
testText.append(" 21.12.2012\n");
testText.append("\n");
testText.append("\n");
testText.append("\n");
testText.append("Invoice\n");
testText.append("\n");
testText.append("\n");
testText.append("Amount Description CUR Price\n");
testText.append("===========================================================================\n");
testText.append("\n");
testText.append(" 1 Order #E41141454 from 01.01.2012: EUR 21,21\n");
testText.append(" nice text, nice text, nice text, nice text,\n");
testText.append(" nice text, nice text, nice text, nice text,\n");
testText.append("\n");
testText.append(" Status: online\n");
final Paragraph para = new Paragraph();
para.setFont(new Font(FontFamily.COURIER, 8.6f));
para.setAlignment(Element.ALIGN_UNDEFINED);
para.setLeading(1.2f, 1.2f);
final String t = testText.toString();
para.add(t);
document.add(para);
document.close();
Upvotes: 1
Views: 824