Class PdfIndirectReference
java.lang.Object
com.itextpdf.kernel.pdf.PdfObject
com.itextpdf.kernel.pdf.PdfIndirectReference
- All Implemented Interfaces:
Comparable<PdfIndirectReference>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intObject generation.private static final intprotected intIndirect reference number of object stream containing refersTo object.protected final intObject number.protected longOffset in a document of therefersToobject.protected PdfDocumentPdfDocument object belongs to.protected PdfObjectPdfObject that current PdfIndirectReference instance refers to.Fields inherited from class PdfObject
ARRAY, BOOLEAN, DICTIONARY, FLUSHED, FORBID_RELEASE, FREE, INDIRECT_REFERENCE, indirectReference, LITERAL, MODIFIED, MUST_BE_FLUSHED, MUST_BE_INDIRECT, NAME, NULL, NUMBER, ORIGINAL_OBJECT_STREAM, READ_ONLY, READING, STREAM, STRING, UNENCRYPTED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPdfIndirectReference(PdfDocument doc, int objNr) protectedPdfIndirectReference(PdfDocument doc, int objNr, int genNr) protectedPdfIndirectReference(PdfDocument doc, int objNr, int genNr, long offset) -
Method Summary
Modifier and TypeMethodDescriptionprivate intcomparePdfDocumentLinks(PdfIndirectReference toCompare) intprotected voidcopyContent(PdfObject from, PdfDocument document) Copies object content from object 'from'.protected voidcopyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter) Copies object content from object 'from'.boolean(package private) voidfixOffset(long offset) intintgetIndex()Gets refersTo object index in the object stream.intintlongGets refersTo object offset in a document.protected PdfReaderGets a PdfReader associated with the document object belongs to.getRefersTo(boolean recursively) Gets direct object and try to resolve indirects chain.bytegetType()Gets object type.protected PdfWriterGets a PdfWriter associated with the document object belongs to.inthashCode()booleanisFree()Checks if thisPdfIndirectReferenceinstance corresponds to free indirect reference.protected PdfObjectCreates new instance of object.voidsetFree()Marks indirect reference as free in the document.(package private) voidsetIndex(long index) (package private) voidsetObjStreamNumber(int objectStreamNumber) (package private) voidsetOffset(long offset) protected voidsetRefersTo(PdfObject refersTo) protected PdfObjectsetState(short state) Sets special states of current object.toString()Methods inherited from class PdfObject
checkState, clearState, clone, clone, containsIndirectReference, copyTo, copyTo, copyTo, copyTo, equalContent, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isReleaseForbidden, isStream, isString, makeIndirect, makeIndirect, processCopying, processCopying, release, setIndirectReference, setModified
-
Field Details
-
LENGTH_OF_INDIRECTS_CHAIN
private static final int LENGTH_OF_INDIRECTS_CHAIN- See Also:
-
objNr
protected final int objNrObject number. -
genNr
protected int genNrObject generation. -
refersTo
PdfObject that current PdfIndirectReference instance refers to. -
objectStreamNumber
protected int objectStreamNumberIndirect reference number of object stream containing refersTo object. If refersTo is not placed into object stream - objectStreamNumber = 0. -
offsetOrIndex
protected long offsetOrIndexOffset in a document of therefersToobject. If the object placed into object stream then it is an object index inside object stream. -
pdfDocument
PdfDocument object belongs to. For direct objects it is null.
-
-
Constructor Details
-
PdfIndirectReference
-
PdfIndirectReference
-
PdfIndirectReference
-
-
Method Details
-
getObjNumber
public int getObjNumber() -
getGenNumber
public int getGenNumber() -
getRefersTo
-
getRefersTo
Gets direct object and try to resolve indirects chain.Note: If chain of references has length of more than 32, this method return 31st reference in chain.
- Parameters:
recursively-trueto resolve indirects chain- Returns:
- the
PdfObjectresult of indirect reference resolving
-
setRefersTo
-
getObjStreamNumber
public int getObjStreamNumber() -
getOffset
public long getOffset()Gets refersTo object offset in a document.- Returns:
- object offset in a document. If refersTo object is in object stream then -1.
-
getIndex
public int getIndex()Gets refersTo object index in the object stream.- Returns:
- object index in a document. If refersTo object is not in object stream then -1.
-
equals
-
hashCode
-
compareTo
- Specified by:
compareToin interfaceComparable<PdfIndirectReference>
-
getType
-
getDocument
-
setFree
public void setFree()Marks indirect reference as free in the document. This doesn't "remove" indirect objects from the document, it only ensures that corresponding xref entry is free and indirect object referred by this reference is no longer linked to it. Actual object still might be written to the resultant document (and would get a new corresponding indirect reference in this case) if it is still contained in some other object.This method will not give any result if the corresponding indirect object or another object that contains a reference to this object is already flushed.
Note: in some cases, removing a link of indirect object to it's indirect reference while leaving the actual object in the document structure might lead to errors, because some objects are expected to always have such explicit link (e.g. Catalog object, page objects, etc).
-
isFree
public boolean isFree()Checks if thisPdfIndirectReferenceinstance corresponds to free indirect reference. Indirect reference might be in a free state either because it was read as such from the opened existing PDF document or because it was set free viasetFree()method.- Returns:
trueif thisPdfIndirectReferenceis free,falseotherwise.
-
toString
-
getWriter
Gets a PdfWriter associated with the document object belongs to.- Returns:
- PdfWriter.
-
getReader
Gets a PdfReader associated with the document object belongs to.- Returns:
- PdfReader.
-
newInstance
Description copied from class:PdfObjectCreates new instance of object.- Specified by:
newInstancein classPdfObject- Returns:
- new instance of object.
-
copyContent
Description copied from class:PdfObjectCopies object content from object 'from'.- Overrides:
copyContentin classPdfObject- Parameters:
from- object to copy content from.document- document to copy object to.copyFilter-ICopyFiltera filter that will apply on dictionaries and array UseNullCopyFilterfor no filtering
-
copyContent
Description copied from class:PdfObjectCopies object content from object 'from'.- Overrides:
copyContentin classPdfObject- Parameters:
from- object to copy content from.document- document to copy object to.
-
setState
-
setObjStreamNumber
void setObjStreamNumber(int objectStreamNumber) -
setIndex
void setIndex(long index) -
setOffset
void setOffset(long offset) -
fixOffset
void fixOffset(long offset) -
comparePdfDocumentLinks
-