単一ページの pdf テンプレート ファイルを作成しました。次に、pdfbox を使用して、「n」ページの PDF を作成します (レポートのサイズによって異なります)。これらのページのすべての「n」をテンプレートpdfファイルのページにしたい。すべての「n」ページをそのページのコピーにする最良の方法は何ですか? これが私の現在のコードです:
PDDocument document = null;
try {
document = PDDocument.load(WestfieldClientReportApp.class.getResource("/com/dramble/resources/template.pdf"));
} catch (IOException ex) {
Logger.getLogger(WestfieldClientReportView.class.getName()).log(Level.SEVERE, null, ex);
}
PDPage templatepage = (PDPage) document.getDocumentCatalog().getAllPages().get(0);
int n = 0;
while (n < numPages) {
n++;
document.importPage(templatepage);
}
問題は、結果セットが大きい場合です。PDF を開くと、11 ページとして表示されます。最初の 2 ページは見栄えがしますが、3 ページ目にスクロールすると、Acrobat エラーが発生します。テンプレート ページはそこにあるように見えますが、レポート データはありません。問題はおそらく上記のコードにあると思います。何か案は?ありがとう。