/** * A dictionary containing any resources required by the page. */ @Override public PDResources getResources() { if (pageResources == null) { COSBase base = PDPageTree.getInheritableAttribute(page, COSName.RESOURCES); // note: it's an error for resources to not be present if (base instanceof COSDictionary) { pageResources = new PDResources((COSDictionary) base, resourceCache); } } return pageResources; }
/** * A rectangle, expressed in default user space units, defining the boundaries of the physical * medium on which the page is intended to be displayed or printed. */ public PDRectangle getMediaBox() { if (mediaBox == null) { COSBase base = PDPageTree.getInheritableAttribute(page, COSName.MEDIA_BOX); if (base instanceof COSArray) { mediaBox = new PDRectangle((COSArray) base); } } if (mediaBox == null) { LOG.debug("Can't find MediaBox, will use U.S. Letter"); mediaBox = PDRectangle.LETTER; } return mediaBox; }
/** * Returns the rotation angle in degrees by which the page should be rotated * clockwise when displayed or printed. Valid values in a PDF must be a * multiple of 90. * * @return The rotation angle in degrees in normalized form (0, 90, 180 or * 270) or 0 if invalid or not set at this level. */ public int getRotation() { COSBase obj = PDPageTree.getInheritableAttribute(page, COSName.ROTATE); if (obj instanceof COSNumber) { int rotationAngle = ((COSNumber) obj).intValue(); if (rotationAngle % 90 == 0) { return (rotationAngle % 360 + 360) % 360; } } return 0; }
/** * Returns the given attribute, inheriting from parent tree nodes if necessary. * * @param node page object * @param key the key to look up * @return COS value for the given key */ public static COSBase getInheritableAttribute(COSDictionary node, COSName key) { COSBase value = node.getDictionaryObject(key); if (value != null) { return value; } COSDictionary parent = (COSDictionary) node.getDictionaryObject(COSName.PARENT, COSName.P); if (parent != null) { return getInheritableAttribute(parent, key); } return null; }
/** * A rectangle, expressed in default user space units, defining the visible region of default * user space. When the page is displayed or printed, its contents are to be clipped (cropped) * to this rectangle. */ public PDRectangle getCropBox() { COSBase base = PDPageTree.getInheritableAttribute(page, COSName.CROP_BOX); if (base instanceof COSArray) { return clipToMediaBox(new PDRectangle((COSArray) base)); } else { return getMediaBox(); } }
/** * A dictionary containing any resources required by the page. */ @Override public PDResources getResources() { if (pageResources == null) { COSBase base = PDPageTree.getInheritableAttribute(page, COSName.RESOURCES); // note: it's an error for resources to not be present if (base instanceof COSDictionary) { pageResources = new PDResources((COSDictionary) base, resourceCache); } } return pageResources; }
private List<CosBBox> getCosBBox(COSName key) { COSBase array = PDPageTree.getInheritableAttribute((COSDictionary) this.simplePDObject.getCOSObject(), key); if (array instanceof COSArray) { ArrayList<CosBBox> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); list.add(new PBCosBBox((COSArray) array, this.document, this.flavour)); return Collections.unmodifiableList(list); } return Collections.emptyList(); }
/** * A dictionary containing any resources required by the page. */ @Override public PDResources getResources() { if (pageResources == null) { COSDictionary resources = (COSDictionary) PDPageTree.getInheritableAttribute(page, COSName.RESOURCES); // note: it's an error for resources to not be present if (resources != null) { pageResources = new PDResources(resources, resourceCache); } } return pageResources; }
/** * Returns the rotation angle in degrees by which the page should be rotated * clockwise when displayed or printed. Valid values in a PDF must be a * multiple of 90. * * @return The rotation angle in degrees in normalized form (0, 90, 180 or * 270) or 0 if invalid or not set at this level. */ public int getRotation() { COSBase obj = PDPageTree.getInheritableAttribute(page, COSName.ROTATE); if (obj instanceof COSNumber) { int rotationAngle = ((COSNumber) obj).intValue(); if (rotationAngle % 90 == 0) { return (rotationAngle % 360 + 360) % 360; } } return 0; }
/** * A rectangle, expressed in default user space units, defining the boundaries of the physical medium on which the * page is intended to be displayed or printed. * * @return the media box. */ public PDRectangle getMediaBox() { if (mediaBox == null) { COSBase base = PDPageTree.getInheritableAttribute(page, COSName.MEDIA_BOX); if (base instanceof COSArray) { mediaBox = new PDRectangle((COSArray) base); } } if (mediaBox == null) { LOG.debug("Can't find MediaBox, will use U.S. Letter"); mediaBox = PDRectangle.LETTER; } return mediaBox; }
/** * A rectangle, expressed in default user space units, defining the boundaries of the physical * medium on which the page is intended to be displayed or printed. */ public PDRectangle getMediaBox() { if (mediaBox == null) { COSArray array = (COSArray) PDPageTree.getInheritableAttribute(page, COSName.MEDIA_BOX); if (array != null) { mediaBox = new PDRectangle(array); } } if (mediaBox == null) { LOG.debug("Can't find MediaBox, will use U.S. Letter"); mediaBox = PDRectangle.LETTER; } return mediaBox; }
/** * Returns the rotation angle in degrees by which the page should be rotated * clockwise when displayed or printed. Valid values in a PDF must be a * multiple of 90. * * @return The rotation angle in degrees in normalized form (0, 90, 180 or * 270) or 0 if invalid or not set at this level. */ public int getRotation() { COSBase obj = PDPageTree.getInheritableAttribute(page, COSName.ROTATE); if (obj instanceof COSNumber) { int rotationAngle = ((COSNumber) obj).intValue(); if (rotationAngle % 90 == 0) { return (rotationAngle % 360 + 360) % 360; } } return 0; }
/** * Returns the given attribute, inheriting from parent tree nodes if necessary. * * @param node page object * @param key the key to look up * @return COS value for the given key */ public static COSBase getInheritableAttribute(COSDictionary node, COSName key) { COSBase value = node.getDictionaryObject(key); if (value != null) { return value; } COSDictionary parent = (COSDictionary) node.getDictionaryObject(COSName.PARENT, COSName.P); if (parent != null) { return getInheritableAttribute(parent, key); } return null; }
/** * Returns the given attribute, inheriting from parent tree nodes if necessary. * * @param node page object * @param key the key to look up * @return COS value for the given key */ public static COSBase getInheritableAttribute(COSDictionary node, COSName key) { COSBase value = node.getDictionaryObject(key); if (value != null) { return value; } COSDictionary parent = (COSDictionary) node.getDictionaryObject(COSName.PARENT, COSName.P); if (parent != null) { return getInheritableAttribute(parent, key); } return null; }
/** * A rectangle, expressed in default user space units, defining the visible region of default user space. When the * page is displayed or printed, its contents are to be clipped (cropped) to this rectangle. * * @return the crop box. */ public PDRectangle getCropBox() { COSBase base = PDPageTree.getInheritableAttribute(page, COSName.CROP_BOX); if (base instanceof COSArray) { return clipToMediaBox(new PDRectangle((COSArray) base)); } else { return getMediaBox(); } }
/** * A rectangle, expressed in default user space units, defining the visible region of default * user space. When the page is displayed or printed, its contents are to be clipped (cropped) * to this rectangle. */ public PDRectangle getCropBox() { COSArray array = (COSArray) PDPageTree.getInheritableAttribute(page, COSName.CROP_BOX); if (array != null) { return clipToMediaBox(new PDRectangle(array)); } else { return getMediaBox(); } }