/** * Returns the updated <code>Rect</code> entry for the annotation. * The rectangle completely contains the cloudy border. * * @return Annotation <code>Rect</code>. */ PDRectangle getRectangle() { return new PDRectangle((float)bboxMinX, (float)bboxMinY, (float)(bboxMaxX - bboxMinX), (float)(bboxMaxY - bboxMinY)); }
/** * Returns the stream. * {@inheritDoc} */ @Override public final COSStream getCOSObject() { return stream.getCOSObject(); }
/** * Get a padded rectangle. * * <p>Creates a new rectangle with padding applied to each side. * . * @param rectangle the rectangle. * @param padding the padding to apply. * @return the padded rectangle. */ PDRectangle getPaddedRectangle(PDRectangle rectangle, float padding) { return new PDRectangle(rectangle.getLowerLeftX() + padding, rectangle.getLowerLeftY() + padding, rectangle.getWidth() - 2 * padding, rectangle.getHeight() - 2 * padding); }
/** * This will create a translated rectangle based off of this rectangle, such * that the new rectangle retains the same dimensions(height/width), but the * lower left x,y values are zero. <br> * 100, 100, 400, 400 (llx, lly, urx, ury ) <br> * will be translated to 0,0,300,300 * * @return A new rectangle that has been translated back to the origin. */ public PDRectangle createRetranslatedRectangle() { PDRectangle retval = new PDRectangle(); retval.setUpperRightX( getWidth() ); retval.setUpperRightY( getHeight() ); return retval; }
/** * This will return a string representation of this rectangle. * * @return This object as a string. */ @Override public String toString() { return "[" + getLowerLeftX() + "," + getLowerLeftY() + "," + getUpperRightX() + "," + getUpperRightY() +"]"; } }
float width = mediabox.getWidth() - 2*margin; float startX = mediabox.getLowerLeftX() + margin; float startY = mediabox.getUpperRightY() - margin;
/** * This will get the height of this rectangle as calculated by * upperRightY - lowerLeftY. * * @return The height of this rectangle. */ public float getHeight() { return getUpperRightY() - getLowerLeftY(); }
/** * This will get the width of this rectangle as calculated by * upperRightX - lowerLeftX. * * @return The width of this rectangle. */ public float getWidth() { return getUpperRightX() - getLowerLeftX(); }
/** * Creates an Image XObject in the given document. This constructor is for internal PDFBox use * and is not for PDF generation. Users who want to create images should look at {@link #createFromFileByExtension(File, PDDocument) * }. * * @param document the current document * @throws java.io.IOException if there is an error creating the XObject. */ public PDImageXObject(PDDocument document) throws IOException { this(new PDStream(document), null); }
/** * Extract the XMP metadata. * To persist changes back to the PDF you must call importXMPMetadata. * * @return A stream to get the xmp data from. * * @throws IOException If there is an error parsing the XMP data. */ public InputStream exportXMPMetadata() throws IOException { return createInputStream(); }
/** * Sets the list of alternateColorSpace color spaces. * * @param list the list of color space objects */ public void setAlternateColorSpaces(List<PDColorSpace> list) { COSArray altArray = null; if(list != null) { altArray = COSArrayList.converterToCOSArray(list); } stream.getCOSObject().setItem(COSName.ALTERNATE, altArray); }
@Override public COSBase getCOSObject() { return obj.getCOSObject(); }
/** * Sets the parent to the given node. * * @param parentNode the node to be set as parent */ public void setParent(PDNameTreeNode<T> parentNode) { parent = parentNode; calculateLimits(); }
/** * Create a child node object. * * @param dic The dictionary for the child node object to refer to. * @return The new child node object. */ protected PDNumberTreeNode createChildNode( COSDictionary dic ) { return new PDNumberTreeNode(dic,valueType); }
/** * {@inheritDoc} */ @Override public boolean isEmpty() { return size() == 0; }
/** * Apply padding to a box. * * @param box box * @return the padded box. */ private PDRectangle applyPadding(PDRectangle box, float padding) { return new PDRectangle(box.getLowerLeftX() + padding, box.getLowerLeftY() + padding, box.getWidth() - 2 * padding, box.getHeight() - 2 * padding); } }
/** * Method to determine if the x/y point is inside this rectangle. * @param x The x-coordinate to test. * @param y The y-coordinate to test. * @return True if the point is inside this rectangle. */ public boolean contains( float x, float y ) { float llx = getLowerLeftX(); float urx = getUpperRightX(); float lly = getLowerLeftY(); float ury = getUpperRightY(); return x >= llx && x <= urx && y >= lly && y <= ury; }
float width = mediabox.getWidth() - 2*margin; float startX = mediabox.getLowerLeftX() + margin; float startY = mediabox.getUpperRightY() - margin;
public PDStream getContentStream() { return new PDStream(charStream); }