1

私はpdfboxとitexpdfを使用して、非常に単純な請求書をpdf形式で作成しています。

Javaの外部のerpシステムで生の請求書テキストファイルを作成しているので、テキストファイルを(pdf)テンプレートと組み合わせて実行する必要があるのは1つだけです。(それは問題ではありません。;))

正常に動作していますが、PDFでインデントエラーが見つかりました。テーブルのヘッダーの後、インデントが正しくありません(先頭の空白が1つ削除されています)。

私が間違っているのは何ですか?

これがコードで、サンプル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();

SampleInvoice

4

1 に答える 1

1

解決しました!

itextpdf 5.0.6から5.4.0に更新しました

于 2013-02-28T12:39:44.440 に答える