[
https://issues.apache.org/jira/browse/PDFBOX-4636?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tilman Hausherr updated PDFBOX-4636:
------------------------------------
Description:
I get this when attempting to flatten the attached file (which is an "improved"
version of the file from the linked issue)
{{26.08.2019 18:41:00.354 WARN [main]
org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm:853 - There has been a
widget with a missing page reference. Please report to the PDFBox project}}
The intention is to "preserve all non widget annotations". This code
reproduces the problem:
{code:java}
PDDocument doc = PDDocument.load(new File("PDFBOX-4636.pdf"));
List<PDAnnotation> annotations = doc.getPage(0).getAnnotations();
PDColor red = new PDColor(new float[] { 1, 0, 0 }, PDDeviceRGB.INSTANCE);
PDColor blue = new PDColor(new float[] { 0, 0, 1 }, PDDeviceRGB.INSTANCE);
PDAnnotationCircle circleAnnotation = new PDAnnotationCircle();
circleAnnotation.setContents("Circle Annotation");
circleAnnotation.setInteriorColor(red);
circleAnnotation.setColor(blue);
circleAnnotation.setRectangle(new PDRectangle(100, 700, 100, 50));
circleAnnotation.setPage(doc.getPage(0));
circleAnnotation.constructAppearances();
annotations.add(circleAnnotation);
doc.save("PDFBOX-4636-annotated.pdf");
doc.getDocumentCatalog().getAcroForm().flatten();
doc.save("PDFBOX-4636-flattened-bad.pdf");
doc.close();
doc = PDDocument.load(new File("PDFBOX-4636-annotatedAP.pdf")); //
PDFBOX-4636-annotated.pdf opened with Adobe and saved
doc.getDocumentCatalog().getAcroForm().flatten();
doc.save("PDFBOX-4636-flattened-good.pdf");
doc.close();
{code}
what should have happened: result file PDFBOX-4636-flattened-good.pdf has 1
annotation.
what happened instead: result file has PDFBOX-4636-flattened-bad.pdf no
annotation, because the circle annotation has been flattened as well.
was:
I get this when attempting to flatten the attached file (which is an "improved"
version of the file from the linked issue)
{{26.08.2019 18:41:00.354 WARN [main]
org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm:853 - There has been a
widget with a missing page reference. Please report to the PDFBox project}}
The intention is to "preserve all non widget annotations". This code
reproduces the problem:
{code:java}
PDDocument doc = PDDocument.load(new File("PDFBOX-4636.pdf"));
List<PDAnnotation> annotations = doc.getPage(0).getAnnotations();
PDColor red = new PDColor(new float[] { 1, 0, 0 }, PDDeviceRGB.INSTANCE);
PDColor blue = new PDColor(new float[] { 0, 0, 1 }, PDDeviceRGB.INSTANCE);
PDAnnotationCircle circleAnnotation = new PDAnnotationCircle();
circleAnnotation.setContents("Circle Annotation");
circleAnnotation.setInteriorColor(red);
circleAnnotation.setColor(blue);
circleAnnotation.setRectangle(new PDRectangle(100, 700, 100, 50));
circleAnnotation.setPage(doc.getPage(0));
circleAnnotation.constructAppearances();
annotations.add(circleAnnotation);
doc.save("PDFBOX-4636-annotated.pdf");
annotations.add(circleAnnotation);
doc.getDocumentCatalog().getAcroForm().flatten();
doc.save("PDFBOX-4636-flattened-bad.pdf");
doc.close();
doc = PDDocument.load(new File("PDFBOX-4636-annotatedAP.pdf")); //
PDFBOX-4636-annotated.pdf opened with Adobe and saved
doc.getDocumentCatalog().getAcroForm().flatten();
doc.save("PDFBOX-4636-flattened-good.pdf");
doc.close();
{code}
what should have happened: result file PDFBOX-4636-flattened-good.pdf has 1
annotation.
what happened instead: result file has PDFBOX-4636-flattened-bad.pdf no
annotation, because the circle annotation has been flattened as well.
> "There has been a widget with a missing page reference" and non widget
> annotation gets flattened
> ------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-4636
> URL: https://issues.apache.org/jira/browse/PDFBOX-4636
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Affects Versions: 2.0.16
> Reporter: Tilman Hausherr
> Assignee: Tilman Hausherr
> Priority: Major
> Fix For: 2.0.17, 3.0.0 PDFBox
>
> Attachments: PDFBOX-4636.pdf
>
>
> I get this when attempting to flatten the attached file (which is an
> "improved" version of the file from the linked issue)
> {{26.08.2019 18:41:00.354 WARN [main]
> org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm:853 - There has been a
> widget with a missing page reference. Please report to the PDFBox project}}
> The intention is to "preserve all non widget annotations". This code
> reproduces the problem:
> {code:java}
> PDDocument doc = PDDocument.load(new File("PDFBOX-4636.pdf"));
> List<PDAnnotation> annotations = doc.getPage(0).getAnnotations();
> PDColor red = new PDColor(new float[] { 1, 0, 0 }, PDDeviceRGB.INSTANCE);
> PDColor blue = new PDColor(new float[] { 0, 0, 1 }, PDDeviceRGB.INSTANCE);
> PDAnnotationCircle circleAnnotation = new PDAnnotationCircle();
> circleAnnotation.setContents("Circle Annotation");
> circleAnnotation.setInteriorColor(red);
> circleAnnotation.setColor(blue);
> circleAnnotation.setRectangle(new PDRectangle(100, 700, 100, 50));
> circleAnnotation.setPage(doc.getPage(0));
> circleAnnotation.constructAppearances();
> annotations.add(circleAnnotation);
> doc.save("PDFBOX-4636-annotated.pdf");
> doc.getDocumentCatalog().getAcroForm().flatten();
> doc.save("PDFBOX-4636-flattened-bad.pdf");
> doc.close();
> doc = PDDocument.load(new File("PDFBOX-4636-annotatedAP.pdf")); //
> PDFBOX-4636-annotated.pdf opened with Adobe and saved
> doc.getDocumentCatalog().getAcroForm().flatten();
> doc.save("PDFBOX-4636-flattened-good.pdf");
> doc.close();
> {code}
> what should have happened: result file PDFBOX-4636-flattened-good.pdf has 1
> annotation.
> what happened instead: result file has PDFBOX-4636-flattened-bad.pdf no
> annotation, because the circle annotation has been flattened as well.
--
This message was sent by Atlassian Jira
(v8.3.2#803003)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]