This represents a page node in a pdf document.
Method from org.apache.pdfbox.pdmodel.PDPageNode Detail: |
public PDRectangle findCropBox() {
PDRectangle retval = getCropBox();
PDPageNode parent = getParent();
if( retval == null && parent != null )
{
retval = findParentCropBox( parent );
}
//default value for cropbox is the media box
if( retval == null )
{
retval = findMediaBox();
}
return retval;
}
This will find the CropBox for this page by looking up the hierarchy until
it finds them. |
public PDRectangle findMediaBox() {
PDRectangle retval = getMediaBox();
PDPageNode parent = getParent();
if( retval == null && parent != null )
{
retval = parent.findMediaBox();
}
return retval;
}
This will find the MediaBox for this page by looking up the hierarchy until
it finds them. |
public PDResources findResources() {
PDResources retval = getResources();
PDPageNode parent = getParent();
if( retval == null && parent != null )
{
retval = parent.findResources();
}
return retval;
}
This will find the resources for this page by looking up the hierarchy until
it finds them. |
public int findRotation() {
int retval = 0;
Integer rotation = getRotation();
if( rotation != null )
{
retval = rotation.intValue();
}
else
{
PDPageNode parent = getParent();
if( parent != null )
{
retval = parent.findRotation();
}
}
return retval;
}
This will find the rotation for this page by looking up the hierarchy until
it finds them. |
public void getAllKids(List result) {
getAllKids(result, page, true);
}
This will return all kids of this node as PDPage. |
public COSBase getCOSObject() {
return page;
}
|
public long getCount() {
return ((COSNumber)page.getDictionaryObject( COSName.COUNT )).intValue();
}
This will get the count of descendent page objects. |
public PDRectangle getCropBox() {
PDRectangle retval = null;
COSArray array = (COSArray)page.getDictionaryObject( COSName.CROP_BOX );
if( array != null )
{
retval = new PDRectangle( array );
}
return retval;
}
This will get the CropBox at this page and not look up the hierarchy.
This attribute is inheritable, and findCropBox() should probably used.
This will return null if no CropBox is available at this level. |
public COSDictionary getDictionary() {
return page;
}
This will get the underlying dictionary that this class acts on. |
public List getKids() {
List actuals = new ArrayList();
COSArray kids = getAllKids(actuals, page, false);
return new COSArrayList( actuals, kids );
}
This will return all kids of this node, either PDPageNode or PDPage. |
public PDRectangle getMediaBox() {
PDRectangle retval = null;
COSArray array = (COSArray)page.getDictionaryObject( COSName.MEDIA_BOX );
if( array != null )
{
retval = new PDRectangle( array );
}
return retval;
}
This will get the MediaBox at this page and not look up the hierarchy.
This attribute is inheritable, and findMediaBox() should probably used.
This will return null if no MediaBox are available at this level. |
public PDPageNode getParent() {
PDPageNode parent = null;
COSDictionary parentDic = (COSDictionary)page.getDictionaryObject( "Parent", "P" );
if( parentDic != null )
{
parent = new PDPageNode( parentDic );
}
return parent;
}
This is the parent page node. |
public PDResources getResources() {
PDResources retval = null;
COSDictionary resources = (COSDictionary)page.getDictionaryObject( COSName.RESOURCES );
if( resources != null )
{
retval = new PDResources( resources );
}
return retval;
}
This will get the resources at this page node and not look up the hierarchy.
This attribute is inheritable, and findResources() should probably used.
This will return null if no resources are available at this level. |
public Integer getRotation() {
Integer retval = null;
COSNumber value = (COSNumber)page.getDictionaryObject( COSName.ROTATE );
if( value != null )
{
retval = new Integer( value.intValue() );
}
return retval;
}
A value representing the rotation. This will be null if not set at this level
The number of degrees by which the page should
be rotated clockwise when displayed or printed. The value must be a multiple
of 90.
This will get the rotation at this page and not look up the hierarchy.
This attribute is inheritable, and findRotation() should probably used.
This will return null if no rotation is available at this level. |
public void setCropBox(PDRectangle cropBox) {
if( cropBox == null )
{
page.removeItem( COSName.CROP_BOX );
}
else
{
page.setItem( COSName.CROP_BOX, cropBox.getCOSArray() );
}
}
This will set the CropBox for this page. |
public void setMediaBox(PDRectangle mediaBox) {
if( mediaBox == null )
{
page.removeItem( COSName.MEDIA_BOX );
}
else
{
page.setItem( COSName.MEDIA_BOX , mediaBox.getCOSArray() );
}
}
This will set the mediaBox for this page. |
public void setParent(PDPageNode parent) {
page.setItem( COSName.PARENT, parent.getDictionary() );
}
This will set the parent of this page. |
public void setResources(PDResources resources) {
if( resources == null )
{
page.removeItem( COSName.RESOURCES );
}
else
{
page.setItem( COSName.RESOURCES, resources.getCOSDictionary() );
}
}
This will set the resources for this page. |
public void setRotation(int rotation) {
page.setInt( COSName.ROTATE, rotation );
}
This will set the rotation for this page. |
public long updateCount() {
long totalCount = 0;
List kids = getKids();
Iterator kidIter = kids.iterator();
while( kidIter.hasNext() )
{
Object next = kidIter.next();
if( next instanceof PDPage )
{
totalCount++;
}
else
{
PDPageNode node = (PDPageNode)next;
totalCount += node.updateCount();
}
}
page.setLong( COSName.COUNT, totalCount );
return totalCount;
}
This will update the count attribute of the page node. This only needs to
be called if you add or remove pages. The PDDocument will call this for you
when you use the PDDocumnet persistence methods. So, basically most clients
will never need to call this. |