我正在使用 更新可编辑 PDF 的值。我想返回流,而不是保存。我保存了它,它工作正常。现在我想返回而不是保存它。PDFBoxbyte[]
public static void main(String[] args) throws IOException
{
String formTemplate = "myFormPdf.pdf";
try (PDDocument pdfDocument = PDDocument.load(new File(formTemplate)))
{
PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
if (acroForm != null)
{
PDTextField field = (PDTextField) acroForm.getField( "sampleField" );
field.setValue("Text Entry");
}
pdfDocument.save("updatedPdf.pdf"); // instead of this I need STREAM
}
}
我试过了,但它无法序列化它。SerializationUtils.serialize
Failed to serialize object of type: class org.apache.pdfbox.pdfmodel.PDDcoumemt
萧十郎
相关分类