Author: tilman
Date: Tue Oct 15 14:04:26 2024
New Revision: 1921335

URL: http://svn.apache.org/viewvc?rev=1921335&view=rev
Log:
PDFBOX-5887: add page getter/setter

Modified:
    
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDObjectReference.java

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDObjectReference.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDObjectReference.java?rev=1921335&r1=1921334&r2=1921335&view=diff
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDObjectReference.java
 (original)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDObjectReference.java
 Tue Oct 15 14:04:26 2024
@@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
+import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.graphics.PDXObject;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
@@ -146,4 +147,30 @@ public class PDObjectReference implement
         this.getCOSObject().setItem(COSName.OBJ, xobject);
     }
 
+    /**
+     * Get the page on which the object shall be rendered.
+     *
+     * @return the referenced page or null.
+     */
+    public PDPage getPage()
+    {
+        COSDictionary pageDict = 
this.getCOSObject().getCOSDictionary(COSName.PG);
+        if (pageDict != null)
+        {
+            return new PDPage(pageDict);
+        }
+        return null;
+    }
+
+    /**
+     * Sets the page on which the object shall be rendered. This is optional 
and overrides the /PG
+     * entry in the structure element containing the object reference; shall 
be used if the
+     * structure element contained no such entry.
+     *
+     * @param page
+     */
+    public void setPage(PDPage page)
+    {
+        this.getCOSObject().setItem(COSName.PG, page);
+    }
 }


Reply via email to