Class PdfImageXObject


  • public class PdfImageXObject
    extends PdfXObject
    A wrapper for Image XObject. ISO 32000-1, 8.9 Images.
    • Field Detail

      • width

        private float width
      • height

        private float height
      • mask

        private boolean mask
      • softMask

        private boolean softMask
    • Method Detail

      • getWidth

        public float getWidth()
        Gets width of image, Width key.
        Overrides:
        getWidth in class PdfXObject
        Returns:
        float value.
      • getHeight

        public float getHeight()
        Gets height of image, Height key.
        Overrides:
        getHeight in class PdfXObject
        Returns:
        float value.
      • flush

        public void flush()
        To manually flush a PdfObject behind this wrapper, you have to ensure that this object is added to the document, i.e. it has an indirect reference. Basically this means that before flushing you need to explicitly call PdfObjectWrapper.makeIndirect(PdfDocument). For example: wrapperInstance.makeIndirect(document).flush(); Note, that not every wrapper require this, only those that have such warning in documentation.
        Overrides:
        flush in class PdfObjectWrapper<PdfStream>
      • getBufferedImage

        public java.awt.image.BufferedImage getBufferedImage()
                                                      throws java.io.IOException
        Gets image bytes, wrapped with buffered image.
        Returns:
        BufferedImage image.
        Throws:
        java.io.IOException - if an error occurs during reading.
      • getImageBytes

        public byte[] getImageBytes()
        Gets decoded image bytes.
        Returns:
        byte array.
      • identifyImageFileExtension

        public java.lang.String identifyImageFileExtension()
        Identifies recommended file extension to store the bytes of this PdfImageXObject. Possible values are: 'png', 'jpg', 'jp2', 'tif', 'jbig2'. This extension can later be used together with the result of getImageBytes().
        Returns:
        a String with recommended file extension
        See Also:
        identifyImageType()
      • put

        public PdfImageXObject put​(PdfName key,
                                   PdfObject value)
        Puts the value into Image XObject dictionary and associates it with the specified key. If the key is already present, it will override the old value with the specified one.
        Parameters:
        key - key to insert or to override
        value - the value to associate with the specified key
        Returns:
        object itself.
      • initWidthField

        private float initWidthField()
      • initHeightField

        private float initHeightField()
      • createDictionaryFromMap

        private static PdfDictionary createDictionaryFromMap​(PdfStream stream,
                                                             java.util.Map<java.lang.String,​java.lang.Object> parms)
      • createArray

        private static PdfArray createArray​(PdfStream stream,
                                            java.lang.Object[] objects)