1
我使用PDFBOX & itextpdf创建PDF格式很简单发票。失落的空间在我创建的PDF(PDFBOX&itextpdf)
我们在ERP系统中创建的原始发票文本文件中的Java之外的 - 所以我唯一要做的文本文件用(PDF)模板相结合。 (那不是问题;))
它的工作很好 - 但我现在发现在PDF的压痕错误:在表的标题后,压痕出错(一个前导空格被删除)。
我在做什么错了?
那是代码,生产样品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();
听起来这个问题的重复:http://stackoverflow.com/questions/14981437/itextsharp-trims-leading-space-和原因,未对准的柱(这是在最近的版本解决的问题,您应该提到你正在使用的iText的版本) – 2013-02-27 17:45:11
是的,它可以是相同的原因。该版本是5.0.6 itextpdf - 我切换到5.4.0,现在工作得很好。但我认为,创建了一轮,去年大约有一百万PDF文件 - 我们必须看到,在过去的不对正。 – Mirko 2013-02-28 12:38:48