Class PdfXObject

    • Constructor Detail

      • PdfXObject

        protected PdfXObject​(PdfStream pdfObject)
    • Method Detail

      • calculateProportionallyFitRectangleWithWidth

        public static Rectangle calculateProportionallyFitRectangleWithWidth​(PdfXObject xObject,
                                                                             float x,
                                                                             float y,
                                                                             float width)
        Calculates a rectangle with the specified coordinates and width, and the height is calculated in such a way that the original proportions of the xObject do not change.

        To calculate the original width and height of the xObject, the BBox and Matrix fields are used. For mor information see paragraph 8.10.1 in ISO-32000-1.

        Parameters:
        xObject - the xObject for which we are calculating the rectangle
        x - the x-coordinate of the lower-left corner of the rectangle
        y - the y-coordinate of the lower-left corner of the rectangle
        width - the width of the rectangle
        Returns:
        the rectangle with specified coordinates and width
      • calculateProportionallyFitRectangleWithHeight

        public static Rectangle calculateProportionallyFitRectangleWithHeight​(PdfXObject xObject,
                                                                              float x,
                                                                              float y,
                                                                              float height)
        Calculates a rectangle with the specified coordinates and height, and the width is calculated in such a way that the original proportions of the xObject do not change.

        To calculate the original width and height of the xObject, the BBox and Matrix fields are used. For mor information see paragraph 8.10.1 in ISO-32000-1.

        Parameters:
        xObject - the xObject for which we are calculating the rectangle
        x - the x-coordinate of the lower-left corner of the rectangle
        y - the y-coordinate of the lower-left corner of the rectangle
        height - the height of the rectangle
        Returns:
        the rectangle with specified coordinates and height
      • setLayer

        public void setLayer​(IPdfOCG layer)
        Sets the layer this XObject belongs to.
        Parameters:
        layer - the layer this XObject belongs to.
      • getWidth

        public float getWidth()
        Gets width of XObject.
        Returns:
        float value.
      • getHeight

        public float getHeight()
        Gets height of XObject.
        Returns:
        float value.
      • addAssociatedFile

        public void addAssociatedFile​(PdfFileSpec fs)
        Adds file associated with PDF XObject and identifies the relationship between them. Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. The method adds file to array value of the AF key in the XObject dictionary.

        For associated files their associated file specification dictionaries shall include the AFRelationship key

        Parameters:
        fs - file specification dictionary of associated file
      • getAssociatedFiles

        public PdfArray getAssociatedFiles​(boolean create)
        Returns files associated with XObject.
        Parameters:
        create - defines whether AF arrays will be created if it doesn't exist
        Returns:
        associated files array
      • isWrappedObjectMustBeIndirect

        protected boolean isWrappedObjectMustBeIndirect()
        Defines if the object behind this wrapper must be an indirect object in the resultant document.

        If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.

        Return value of this method shouldn't depend on any logic, it should return always true or false.
        Specified by:
        isWrappedObjectMustBeIndirect in class PdfObjectWrapper<PdfStream>
        Returns:
        true if in the resultant document the object behind the wrapper must be indirect, otherwise false.