私は、既存のpdfを別のものにコピーしてから書き込むことを試みています。ここ がByteOutputStreamに既存のPDFファイルをコピーするために私のコードです:Pdfcopy空白を返すpdf
documentPDF.open()
for(int i=0;i<nbPages;){
copy.addPage(copy.getImportedPage(reader, ++i))
}
documentPDF.close()
copy.close()
PdfReader reader= new PdfReader("DocDeBase30.pdf");
reader.selectPages("1-5")
def documentPDF =new Document()
ByteArrayOutputStream baos = new ByteArrayOutputStream()
PdfCopy copy = new PdfCopy(documentPDF, baos)
documentPDF.open()
for(int i=0;i<nbPages;){
copy.addPage(copy.getImportedPage(reader, ++i))
}
documentPDF.close()
copy.close()
reader.close();
return baos
それから私は、この手順を使用して私の見解にPDFファイルをレンダリングしています:
結果が返されたBAOある response.setContentType("application/pdf")
response.setHeader('Content-disposition', "attachment; filename=intercalaire.pdf")
response.outputStream << result
response.outputStream.flush()
result.close()
。
ファイルは私のブラウザに正しく開いていますが、空白で、コピーされたものはありません。
ByteArrayOutputStreamを使用する代わりに物理パスを使用していますが、物理パスがオプションではないため、アプリケーションで動的ドキュメントを使用する必要があります。
事前に
THX
多分あなたはここで説明されているようにバイトを削っています:http://itext.2136553.n4.nabble.com/Blank-PDF-after-it-is-transfered-through-SMTP-td2228773 html PDFを見ることなく、この問題についてあなたに伝えることはほとんどありません。ページが存在してもページの内容が空の場合、サーバーはプレーンテキストを提供するように構成されており、バイナリデータを処理することはできません。 –