File tree Expand file tree Collapse file tree
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -152,24 +152,32 @@ public void importFDF(FDFDocument fdf) throws IOException
152152 public FDFDocument exportFDF () throws IOException
153153 {
154154 FDFDocument fdf = new FDFDocument ();
155- FDFCatalog catalog = fdf .getCatalog ();
156- FDFDictionary fdfDict = new FDFDictionary ();
157- catalog .setFDF (fdfDict );
158-
159- List <PDField > fields = getFields ();
160- List <FDFField > fdfFields = new ArrayList <>(fields .size ());
161- for (PDField field : fields )
155+ try
162156 {
163- fdfFields .add (field .exportFDF ());
164- }
157+ FDFCatalog catalog = fdf .getCatalog ();
158+ FDFDictionary fdfDict = new FDFDictionary ();
159+ catalog .setFDF (fdfDict );
160+
161+ List <PDField > fields = getFields ();
162+ List <FDFField > fdfFields = new ArrayList <>(fields .size ());
163+ for (PDField field : fields )
164+ {
165+ fdfFields .add (field .exportFDF ());
166+ }
165167
166- fdfDict .setID (document .getDocument ().getDocumentID ());
168+ fdfDict .setID (document .getDocument ().getDocumentID ());
167169
168- if (!fdfFields .isEmpty ())
170+ if (!fdfFields .isEmpty ())
171+ {
172+ fdfDict .setFields (fdfFields );
173+ }
174+ return fdf ;
175+ }
176+ catch (Exception e )
169177 {
170- fdfDict .setFields (fdfFields );
178+ fdf .close ();
179+ throw e ;
171180 }
172- return fdf ;
173181 }
174182
175183 /**
You can’t perform that action at this time.
0 commit comments