Class PdfMerge.XRefMerger

java.lang.Object
org.jpedal.tools.PdfMerge.XRefMerger
Enclosing class:
PdfMerge

public static class PdfMerge.XRefMerger extends Object
Class to track merged content reference changes
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    addEntry(int originalRef, int offset)
    Adds a new entry to the merged XRef table and turns the newRef for this entry
    void
    alterMergedOffsets(int offsetChange)
    Update all offsets by a given amount.
    void
    alterOffset(int originalRef, int offset)
    Alter the offset for a reference
    void
    clearLookup(boolean alsoClearOutputEntries)
    Clear all stored references, included mocked up references for new objects created for the merge if set with the provided flag.
    int
    Get the new ref for the ref after merging
    byte[]
    Get the merged xref table as a byte array
    int
    Get the number of new references currently in the merged xref table
    boolean
    Return if the object reference has already been added and has a new reference number

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XRefMerger

      public XRefMerger()
  • Method Details

    • addEntry

      public int addEntry(int originalRef, int offset)
      Adds a new entry to the merged XRef table and turns the newRef for this entry
      Parameters:
      originalRef - The ref used in the original file
      offset - The offset for the new reference
      Returns:
      The new reference number for this object in the merged output
    • alterOffset

      public void alterOffset(int originalRef, int offset)
      Alter the offset for a reference
      Parameters:
      originalRef - The ref used in the original file
      offset - The offset for the new reference
    • clearLookup

      public void clearLookup(boolean alsoClearOutputEntries)
      Clear all stored references, included mocked up references for new objects created for the merge if set with the provided flag.
      Parameters:
      alsoClearOutputEntries - Set if we should also remove mocked up objects used internally for the merge.
    • objectAlreadyMerged

      public boolean objectAlreadyMerged(int ref)
      Return if the object reference has already been added and has a new reference number
      Parameters:
      ref - The ref from the original file
      Returns:
      True if the ref has already been added
    • getNewRefFromOriginalRef

      public int getNewRefFromOriginalRef(int ref)
      Get the new ref for the ref after merging
      Parameters:
      ref - The ref from the original file
      Returns:
      the new ref for the ref from the original file or -1 if not already present
    • alterMergedOffsets

      public void alterMergedOffsets(int offsetChange)
      Update all offsets by a given amount. This is useful for when writing out these object after other content.
      Parameters:
      offsetChange - The amount all offsets should be updated by
    • getXRefTableSize

      public int getXRefTableSize()
      Get the number of new references currently in the merged xref table
      Returns:
      The count of all new references
    • getXRefTableAsByteArray

      public byte[] getXRefTableAsByteArray() throws IOException
      Get the merged xref table as a byte array
      Returns:
      a byte array for the xref table
      Throws:
      IOException - Thrown if there is an issue creating the byte array