Package com.orsonpdf

Class PDFObject

java.lang.Object
com.orsonpdf.PDFObject
Direct Known Subclasses:
DictionaryObject, Function, Page, Pages, Pattern, PDFFont, Shading, Stream

public abstract class PDFObject extends 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
     
    private int
     
  • 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

    Modifier and Type
    Method
    Description
    int
    Returns the PDF object generation number.
    int
    Returns the PDF object number (specified in the constructor).
    abstract byte[]
    Returns the bytes that go between the 'obj' and 'endobj' in the PDF output for this object.
    Returns the PDF reference string for this object (for example, "2 0 R").
    private String
     
    byte[]
    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 Details

    • number

      private int number
    • generation

      private int generation
  • Constructor Details

    • 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 Details

    • 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 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 IOException
      Returns the PDF bytes representing this object.
      Returns:
      The PDF bytes representing this object.
      Throws:
      IOException - if there is a problem writing to the byte array.
    • getObjectBytes

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

      private String objectIntroString()