From fbf4fdc988d3b0012a737745dd2c105d93552edf Mon Sep 17 00:00:00 2001 From: Tilman Hausherr Date: Tue, 15 Oct 2024 14:04:19 +0000 Subject: [PATCH] PDFBOX-5887: add page getter/setter git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1921333 13f79535-47bb-0310-9956-ffa450edef68 --- .../logicalstructure/PDObjectReference.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) 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); + } }