Hi Lorena, That error is from the Java compiler. You need to learn how to use exceptions in Java: http://docs.oracle.com/javase/tutorial/essential/exceptions/ <http://docs.oracle.com/javase/tutorial/essential/exceptions/>
These sorts of questions aren’t really suitable for the PDFBox mailing list. Thanks, -- John > On 14 Jan 2015, at 09:01, Lorena Leishman <[email protected]> > wrote: > > When I tried to run this code I get: unreported exception > COSVisitorException; must be caught or declare to be thrownpdf.Document. > save(FilledForm); 1 error. Do you know why? > > package org.apache.pdfbox.examples.acroforms;import java.io.File; > import java.io.IOException; > import org.apache.pdfbox.pdmodel.PDDocument; > import org.apache.pdfbox.exceptions.*; > import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;import > org.apache.pdfbox.pdmodel.interactive.form.PDField; > import org.apache.pdfbox.pdmodel.interactive.form.PDTextbox; > > > public class FillTestField { > public static void main(String[] args) throws IOException { String > formTemplate = "Users/Dad/Desktop/TCRM/game plan 12-16.pdf"; String > filledForm = "Users/Dad/JavaTest/game plan 12-16.pdf"; // load > the document PDDocument pdfDocument = PDDocument > .load(new File(formTemplate),null); > // get the document catalog PDAcroForm acroForm = > pdfDocument.getDocumentCatalog().getAcroForm(); // as there might not > be an AcroForm entry a null check is necessary if (acroForm != null) > { // Retrieve an individual field and set it's value. > PDTextbox field = (PDTextbox) acroForm.getField( "Goal" ); > field.setValue("Text Entry"); // If a field is nested > within the form tree a fully qualified name // might be provided > to access the field. field = (PDTextbox) acroForm.getField( > "fieldsContainer.nestedSampleField" ); field.setValue("Text > Entry"); } > // Save and close the filled out form. > pdfDocument.save(filledForm); pdfDocument.close(); > } > }

