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 TypeMethodDescriptionint
addEntry
(int originalRef, int offset) Adds a new entry to the merged XRef table and turns the newRef for this entryvoid
alterMergedOffsets
(int offsetChange) Update all offsets by a given amount.void
alterOffset
(int originalRef, int offset) Alter the offset for a referencevoid
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
getNewRefFromOriginalRef
(int ref) Get the new ref for the ref after mergingbyte[]
Get the merged xref table as a byte arrayint
Get the number of new references currently in the merged xref tableboolean
objectAlreadyMerged
(int ref) Return 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, 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 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, int 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) 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
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
-