pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1864896 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationLink.java
Date Sat, 10 Aug 2019 17:39:14 GMT
Author: tilman
Date: Sat Aug 10 17:39:14 2019
New Revision: 1864896

URL: http://svn.apache.org/viewvc?rev=1864896&view=rev
Log:
PDFBOX-4628: support "OnActivation/Action/URI"

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationLink.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationLink.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationLink.java?rev=1864896&r1=1864895&r2=1864896&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationLink.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationLink.java
Sat Aug 10 17:39:14 2019
@@ -18,15 +18,29 @@ package org.apache.pdfbox.pdmodel.fdf;
 
 import java.io.IOException;
 
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.interactive.action.PDActionURI;
+
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 /**
  * This represents a Polygon FDF annotation.
  */
 public class FDFAnnotationLink extends FDFAnnotation
 {
+    private static final Log LOG = LogFactory.getLog(FDFAnnotationLink.class);
+
     /**
      * COS Model value for SubType entry.
      */
@@ -37,7 +51,6 @@ public class FDFAnnotationLink extends F
      */
     public FDFAnnotationLink()
     {
-        super();
         annot.setName(COSName.SUBTYPE, SUBTYPE);
     }
 
@@ -62,5 +75,28 @@ public class FDFAnnotationLink extends F
     {
         super(element);
         annot.setName(COSName.SUBTYPE, SUBTYPE);
+        XPath xpath = XPathFactory.newInstance().newXPath();
+
+        try
+        {
+            NodeList uri = (NodeList) xpath.evaluate("OnActivation/Action/URI", element,
+                    XPathConstants.NODESET);
+            if (uri.getLength() > 0)
+            {
+                Node namedItem = uri.item(0).getAttributes().getNamedItem("Name");
+                if (namedItem != null && namedItem.getNodeValue() != null)
+                {
+                    PDActionURI actionURI = new PDActionURI();
+                    actionURI.setURI(namedItem.getNodeValue());
+                    annot.setItem(COSName.A, actionURI);
+                }
+            }
+            // GoTo is more tricky, because because page destination needs page tree
+            // to convert number into PDPage object
+        }
+        catch (XPathExpressionException e)
+        {
+            LOG.debug("Error while evaluating XPath expression", e);
+        }
     }
 }



Mime
View raw message