Package org.jpedal.tools
Class PdfMerge.XRefMerger
java.lang.Object
org.jpedal.tools.PdfMerge.XRefMerger
- Enclosing class:
PdfMerge
Class to track merged content reference changes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddEntry(int originalRef, long offset) Adds a new entry to the merged XRef table and turns the newRef for this entryvoidalterMergedOffsets(long offsetChange) Update all offsets by a given amount.voidalterOffset(int originalRef, long offset) Alter the offset for a referencevoidclearLookup(boolean alsoClearOutputEntries) Clear all stored references, included mocked up references for new objects created for the merge if set with the provided flag.intgetNewRefFromOriginalRef(int ref) Returns the new ref for the ref after merging, or -1 if not already present.intgetOriginalRefFromNewRef(int ref) Get the new ref for the ref after mergingbyte[]Returns the merged xref table as a byte array.intReturns the number of new references currently in the merged xref table.booleanobjectAlreadyMerged(int ref) Returns true if the object reference has already been added and has a new reference number.
-
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 fileoffset- 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 fileoffset- 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
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
-