diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDObjectReference.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDObjectReference.java index 6e93de8dad1..a018c8705b2 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDObjectReference.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDObjectReference.java @@ -24,6 +24,7 @@ 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 void setReferencedObject(PDXObject xobject) 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); + } }