Java 我创建的PDF中丢失的空间(pdfbox和itextpdf)

Java 我创建的PDF中丢失的空间(pdfbox和itextpdf),java,indentation,pdfbox,itextpdf,Java,Indentation,Pdfbox,Itextpdf,我正在使用pdfbox和itextpdf以pdf格式创建非常简单的发票 我们正在java之外的erp系统中创建原始发票文本文件,所以我唯一要做的就是将文本文件与(pdf)模板结合起来。(这不是问题所在 它工作正常-但我现在在pdf中发现了一个缩进错误:在表的标题之后,缩进出现错误(一个前导空格被删除) 我做错了什么 这就是生成示例pdf的代码: final File outputFile = this.createTmpFile(); final Document document = new

我正在使用pdfbox和itextpdf以pdf格式创建非常简单的发票

我们正在java之外的erp系统中创建原始发票文本文件,所以我唯一要做的就是将文本文件与(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();

已解决


我们从itextpdf5.0.6更新为5.4.0已解决


我们从itextpdf5.0.6更新到了5.4.0

听起来像是这个问题的重复:(这个问题在最近的版本中得到了解决;您应该提到您正在使用的iText版本)是的,可能是相同的原因。版本是itextpdf 5.0.6-我切换到5.4.0,现在工作正常。但我认为,去年创建了大约一百万个PDF,我们必须看到过去的错误对齐。听起来像是这个问题的重复:(这个问题在最近的版本中得到了解决;你应该提到你正在使用哪个版本的iText)是的,这可能是相同的原因。版本是itextpdf 5.0.6-我切换到5.4.0,现在工作正常。但我认为,在过去的一年里,我们创造了大约100万个PDF文件——我们必须看到过去的错误排列。