Skip to content

Commit

Permalink
PDFBOX-5887: add page getter/setter
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1921333 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Oct 15, 2024
1 parent 530c3f7 commit fbf4fdc
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

0 comments on commit fbf4fdc

Please sign in to comment.