"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

PDAcroForm.java  (pdfbox-2.0.23-src):PDAcroForm.java  (pdfbox-2.0.24-src)
skipping to change at line 244 skipping to change at line 244
LOG.warn("Flatten for a dynamix XFA form is not supported"); LOG.warn("Flatten for a dynamix XFA form is not supported");
return; return;
} }
// refresh the appearances if set // refresh the appearances if set
if (refreshAppearances) if (refreshAppearances)
{ {
refreshAppearances(fields); refreshAppearances(fields);
} }
// the content stream to write to
PDPageContentStream contentStream;
// get the widgets per page // get the widgets per page
Map<COSDictionary,Set<COSDictionary>> pagesWidgetsMap = buildPagesWidget sMap(fields); Map<COSDictionary,Set<COSDictionary>> pagesWidgetsMap = buildPagesWidget sMap(fields);
// preserve all non widget annotations // preserve all non widget annotations
for (PDPage page : document.getPages()) for (PDPage page : document.getPages())
{ {
Set<COSDictionary> widgetsForPageMap = pagesWidgetsMap.get(page.getC OSObject()); Set<COSDictionary> widgetsForPageMap = pagesWidgetsMap.get(page.getC OSObject());
// indicates if the original content stream // indicates if the original content stream
// has been wrapped in a q...Q pair. // has been wrapped in a q...Q pair.
skipping to change at line 269 skipping to change at line 266
List<PDAnnotation> annotations = new ArrayList<PDAnnotation>(); List<PDAnnotation> annotations = new ArrayList<PDAnnotation>();
for (PDAnnotation annotation: page.getAnnotations()) for (PDAnnotation annotation: page.getAnnotations())
{ {
if (widgetsForPageMap == null || !widgetsForPageMap.contains(ann otation.getCOSObject())) if (widgetsForPageMap == null || !widgetsForPageMap.contains(ann otation.getCOSObject()))
{ {
annotations.add(annotation); annotations.add(annotation);
} }
else if (isVisibleAnnotation(annotation)) else if (isVisibleAnnotation(annotation))
{ {
contentStream = new PDPageContentStream(document, page, Appe PDPageContentStream contentStream = new PDPageContentStream(
ndMode.APPEND, true, !isContentStreamWrapped); document, page, AppendMode.APPEND, true, !isContentS
isContentStreamWrapped = true; treamWrapped);
try
PDAppearanceStream appearanceStream = annotation.getNormalAp {
pearanceStream(); isContentStreamWrapped = true;
PDFormXObject fieldObject = new PDFormXObject(appearanceStre PDAppearanceStream appearanceStream = annotation.getNorm
am.getCOSObject()); alAppearanceStream();
contentStream.saveGraphicsState(); PDFormXObject fieldObject = new PDFormXObject(appearance
Stream.getCOSObject());
// see https://stackoverflow.com/a/54091766/1729265 for an e
xplanation contentStream.saveGraphicsState();
// of the steps required
// this will transform the appearance stream form object int // see https://stackoverflow.com/a/54091766/1729265 for
o the rectangle of the an explanation
// annotation bbox and map the coordinate systems // of the steps required
Matrix transformationMatrix = resolveTransformationMatrix(an // this will transform the appearance stream form object
notation, appearanceStream); into the rectangle of the
contentStream.transform(transformationMatrix); // annotation bbox and map the coordinate systems
contentStream.drawForm(fieldObject); Matrix transformationMatrix = resolveTransformationMatri
contentStream.restoreGraphicsState(); x(annotation, appearanceStream);
contentStream.close(); contentStream.transform(transformationMatrix);
contentStream.drawForm(fieldObject);
contentStream.restoreGraphicsState();
}
finally
{
contentStream.close();
}
} }
} }
page.setAnnotations(annotations); page.setAnnotations(annotations);
} }
// remove the fields // remove the fields
removeFields(fields); removeFields(fields);
// remove XFA for hybrid forms // remove XFA for hybrid forms
dictionary.removeItem(COSName.XFA); dictionary.removeItem(COSName.XFA);
 End of changes. 2 change blocks. 
27 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)