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, long offset)
    Adds a new entry to the merged XRef table and turns the newRef for this entry
    void
    alterMergedOffsets(long offsetChange)
    Update all offsets by a given amount.
    void
    alterOffset(int originalRef, long 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
    Returns the new ref for the ref after merging, or -1 if not already present.
    int
    Get the new ref for the ref after merging
    byte[]
    Returns the merged xref table as a byte array.
    int
    Returns the number of new references currently in the merged xref table.
    boolean
    Returns true 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, long 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, long 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)
      Returns true 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 object reference has already been added and has a new reference number
    • getNewRefFromOriginalRef

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

      public int getOriginalRefFromNewRef(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(long 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()
      Returns the number of new references currently in the merged xref table.
      Returns:
      the number of new references currently in the merged xref table
    • getXRefTableAsByteArray

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