Author: ssteiner
Date: Tue May  5 07:34:02 2020
New Revision: 1877369

URL: http://svn.apache.org/viewvc?rev=1877369&view=rev
Log:
FOP-2933: PDF to PDF checkbox missing

Added:
    xmlgraphics/fop-pdf-images/trunk/test/resources/accessibleradiobuttons.pdf  
 (with props)
Modified:
    
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
    
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java

Modified: 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java?rev=1877369&r1=1877368&r2=1877369&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PDFBoxAdapter.java
 Tue May  5 07:34:02 2020
@@ -710,6 +710,7 @@ public class PDFBoxAdapter {
 
                 PDFObject clonedAnnot = (PDFObject) 
cloneForNewDocument(annot1, annot1, exclude);
                 if (clonedAnnot instanceof PDFDictionary) {
+                    cloneAnnotParent(annot1, (PDFDictionary) clonedAnnot, 
exclude);
                     clonedAnnot.setParent(targetPage);
                     PDFBoxAdapterUtil.updateAnnotationLink((PDFDictionary) 
clonedAnnot);
                 }
@@ -719,6 +720,17 @@ public class PDFBoxAdapter {
         return fields;
     }
 
+    private void cloneAnnotParent(Object annot1, PDFDictionary clonedAnnot, 
Collection<COSName> exclude)
+        throws IOException {
+        if (annot1 instanceof COSObject) {
+            COSDictionary dictionary = (COSDictionary) ((COSObject) 
annot1).getObject();
+            COSBase parent = dictionary.getItem(COSName.PARENT);
+            if (parent != null) {
+                clonedAnnot.put(COSName.PARENT.getName(), 
cloneForNewDocument(parent, parent, exclude));
+            }
+        }
+    }
+
     private COSDictionary getField(COSObject fieldObject, Set<COSObject> 
fields) {
         COSDictionary field = (COSDictionary) fieldObject.getObject();
         COSObject parent;

Modified: 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java?rev=1877369&r1=1877368&r2=1877369&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
 Tue May  5 07:34:02 2020
@@ -120,6 +120,7 @@ public class PDFBoxAdapterTestCase {
     private static final String SMASK = "test/resources/smask.pdf";
     private static final String TYPE0TT = "test/resources/type0tt.pdf";
     private static final String TYPE0CFF = "test/resources/type0cff.pdf";
+    private static final String ACCESSIBLERADIOBUTTONS = 
"test/resources/accessibleradiobuttons.pdf";
 
     private static PDFPage getPDFPage(PDFDocument doc) {
         final Rectangle2D r = new Rectangle2D.Double();
@@ -277,6 +278,27 @@ public class PDFBoxAdapterTestCase {
         doc.close();
     }
 
+
+    @Test
+    public void testAnnot3() throws Exception {
+        PDFDocument pdfdoc = new PDFDocument("");
+        PDFPage pdfpage = getPDFPage(pdfdoc);
+        pdfpage.setDocument(pdfdoc);
+        pdfpage.setObjectNumber(1);
+        PDFBoxAdapter adapter = new PDFBoxAdapter(pdfpage, new HashMap(), new 
HashMap<Integer, PDFArray>());
+        PDDocument doc = PDDocument.load(new File(ACCESSIBLERADIOBUTTONS));
+        PDPage page = doc.getPage(0);
+        AffineTransform at = new AffineTransform();
+        Rectangle r = new Rectangle(0, 1650, 842000, 595000);
+        adapter.createStreamFromPDFBoxPage(doc, page, "key", at, null, r);
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        pdfdoc.output(os);
+        String out = os.toString("UTF-8");
+        Assert.assertTrue(out.contains("/Parent "));
+        Assert.assertTrue(out.contains("/Kids "));
+        doc.close();
+    }
+
     @Test
     public void testLink() throws Exception {
         PDFDocument pdfdoc = new PDFDocument("");

Added: 
xmlgraphics/fop-pdf-images/trunk/test/resources/accessibleradiobuttons.pdf
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/test/resources/accessibleradiobuttons.pdf?rev=1877369&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
xmlgraphics/fop-pdf-images/trunk/test/resources/accessibleradiobuttons.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org

Reply via email to