Class PDFObject

  • Direct Known Subclasses:
    DictionaryObject, Function, Page, Pages, Pattern, PDFFont, Shading, Stream

    public abstract class PDFObject
    extends java.lang.Object
    A PDF Object (also referred to as an 'Indirect Object' in the PDF specification). Objects are identified within a document by their PDF object number (which must be unique within the document) and their PDF object generation number.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int generation  
      private int number  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected PDFObject​(int number)
      Creates a new instance with the specified object number and the default generation number (0).
      protected PDFObject​(int number, int generation)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      int getGeneration()
      Returns the PDF object generation number.
      int getNumber()
      Returns the PDF object number (specified in the constructor).
      abstract byte[] getObjectBytes()
      Returns the bytes that go between the 'obj' and 'endobj' in the PDF output for this object.
      java.lang.String getReference()
      Returns the PDF reference string for this object (for example, "2 0 R").
      private java.lang.String objectIntroString()  
      byte[] toPDFBytes()
      Returns the PDF bytes representing this object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • number

        private int number
      • generation

        private int generation
    • Constructor Detail

      • PDFObject

        protected PDFObject​(int number)
        Creates a new instance with the specified object number and the default generation number (0).
        Parameters:
        number - the object number.
      • PDFObject

        protected PDFObject​(int number,
                            int generation)
        Creates a new instance.
        Parameters:
        number - the PDF object number (must be unique within the document).
        generation - the PDF generation number.
    • Method Detail

      • getNumber

        public int getNumber()
        Returns the PDF object number (specified in the constructor).
        Returns:
        The PDF object number.
      • getGeneration

        public int getGeneration()
        Returns the PDF object generation number.
        Returns:
        The PDF object generation number.
      • getReference

        public java.lang.String getReference()
        Returns the PDF reference string for this object (for example, "2 0 R"). This is the PDF object number followed by a space followed by the PDF object generation number, followed by a space and an 'R'.
        Returns:
        The PDF reference string.
      • toPDFBytes

        public byte[] toPDFBytes()
                          throws java.io.IOException
        Returns the PDF bytes representing this object.
        Returns:
        The PDF bytes representing this object.
        Throws:
        java.io.IOException - if there is a problem writing to the byte array.
      • getObjectBytes

        public abstract byte[] getObjectBytes()
                                       throws java.io.IOException
        Returns the bytes that go between the 'obj' and 'endobj' in the PDF output for this object.
        Returns:
        A byte array.
        Throws:
        java.io.IOException - if there is a problem writing to the byte array.
      • objectIntroString

        private java.lang.String objectIntroString()