/** * This will takes the values from the fdf document and import them into the * PDF document. * * @param pdfDocument The document to put the fdf data into. * @param fdfDocument The FDF document to get the data from. * * @throws IOException If there is an error setting the data in the field. */ public void importFDF( PDDocument pdfDocument, FDFDocument fdfDocument ) throws IOException { PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); if (acroForm == null) { return; } acroForm.setCacheFields( true ); acroForm.importFDF( fdfDocument ); //TODO this can be removed when we create appearance streams acroForm.setNeedAppearances(true); }
PDAcroForm form = docCatalog.getAcroForm(); form.setNeedAppearances(true);
PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); acroForm.setNeedAppearances(false);
File myFile = new File("myFile.pdf"); PDDocument pdDoc = PDDocument.load(myFile); PDDocumentCatalog pdCatalog = pdDoc.getDocumentCatalog(); PDAcroForm pdAcroForm = pdCatalog.getAcroForm(); // set the NeedAppearances flag to false pdAcroForm.setNeedAppearances(false); field.setValue("new-value"); pdAcroForm.flatten(); pdDoc.save("myFlattenedFile.pdf"); pdDoc.close();
/** * This will takes the values from the fdf document and import them into the * PDF document. * * @param pdfDocument The document to put the fdf data into. * @param fdfDocument The FDF document to get the data from. * * @throws IOException If there is an error setting the data in the field. */ public void importFDF( PDDocument pdfDocument, FDFDocument fdfDocument ) throws IOException { PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); if (acroForm == null) { return; } acroForm.setCacheFields( true ); acroForm.importFDF( fdfDocument ); //TODO this can be removed when we create appearance streams acroForm.setNeedAppearances(true); }
PDAcroForm acro = new PDAcroForm(writer); acro.setNeedAppearances(Boolean.TRUE); acro.setDefaultResources(resources);
PDAcroForm acro = new PDAcroForm(writer); acro.setNeedAppearances(Boolean.TRUE); acro.setDefaultResources(resources);