Class PdfObject
public abstract class PdfObject
- Inheritance
-
PdfObject
- Derived
- Inherited Members
Constructors
PdfObject()
protected PdfObject()
Fields
ARRAY
public const byte ARRAY = 1
Field Value
BOOLEAN
public const byte BOOLEAN = 2
Field Value
DICTIONARY
public const byte DICTIONARY = 3
Field Value
FLUSHED
Indicates if the object has been flushed.
protected const short FLUSHED = 1
Field Value
FORBID_RELEASE
Indicates that the object is highly sensitive and we do not want to release it even if release() is called.
protected const short FORBID_RELEASE = 128
Field Value
Remarks
Indicates that the object is highly sensitive and we do not want to release it even if release() is called. This flag can be set in stamping mode in object wrapper constructors and is automatically set when setModified flag is set (we do not want to release changed objects). The flag is set automatically for some wrappers that need document even in reader mode (FormFields etc).
FREE
Indicates that the indirect reference of the object could be reused or have to be marked as free.
protected const short FREE = 2
Field Value
INDIRECT_REFERENCE
public const byte INDIRECT_REFERENCE = 5
Field Value
LITERAL
public const byte LITERAL = 4
Field Value
MODIFIED
Indicates that object changed (is used in append mode).
protected const short MODIFIED = 8
Field Value
MUST_BE_FLUSHED
For internal usage only.
protected const short MUST_BE_FLUSHED = 32
Field Value
Remarks
For internal usage only. Marks objects that shall be written to the output document. Option is needed to build the correct PDF objects tree when closing the document. As a result it avoids writing unused (removed) objects.
MUST_BE_INDIRECT
Indicates that the object shall be indirect when it is written to the document.
protected const short MUST_BE_INDIRECT = 64
Field Value
Remarks
Indicates that the object shall be indirect when it is written to the document. It is used to postpone the creation of indirect reference for the objects that shall be indirect, so it is possible to create such objects without PdfDocument instance.
NAME
public const byte NAME = 6
Field Value
NULL
public const byte NULL = 7
Field Value
NUMBER
public const byte NUMBER = 8
Field Value
ORIGINAL_OBJECT_STREAM
Indicates that the indirect reference of the object represents ObjectStream from original document.
protected const short ORIGINAL_OBJECT_STREAM = 16
Field Value
Remarks
Indicates that the indirect reference of the object represents ObjectStream from original document. When PdfReader read ObjectStream reference marked as OriginalObjectStream to avoid further reusing.
READING
Indicates that definition of the indirect reference of the object still not found (e.g. keys in XRefStm).
protected const short READING = 4
Field Value
READ_ONLY
Indicates that we do not want this object to be ever written into the resultant document (because of multiple objects read from the same reference inconsistency).
protected const short READ_ONLY = 256
Field Value
STREAM
public const byte STREAM = 9
Field Value
STRING
public const byte STRING = 10
Field Value
UNENCRYPTED
Indicates that this object is not encrypted in the encrypted document.
protected const short UNENCRYPTED = 512
Field Value
Remarks
Indicates that this object is not encrypted in the encrypted document. E.g. digital signature dictionary /Contents entry shall not be encrypted.
indirectReference
If object is flushed the indirect reference is kept here.
protected PdfIndirectReference indirectReference
Field Value
Methods
CheckState(short)
Checks state of the flag of current object.
protected virtual bool CheckState(short state)
Parameters
state
shortspecial flag to check
Returns
- bool
true if the state was set.
ClearState(short)
Clear state of the flag of current object.
protected virtual PdfObject ClearState(short state)
Parameters
state
shortspecial flag state to clear
Returns
Clone()
Creates clone of the object which belongs to the same document as original object.
public virtual PdfObject Clone()
Returns
- PdfObject
cloned object.
Remarks
Creates clone of the object which belongs to the same document as original object. New object shall not be used in other documents.
Clone(ICopyFilter)
Creates clone of the object which belongs to the same document as original object.
public virtual PdfObject Clone(ICopyFilter filter)
Parameters
filter
ICopyFilterFilter what will be copied or not
Returns
- PdfObject
cloned object.
Remarks
Creates clone of the object which belongs to the same document as original object. New object shall not be used in other documents.
CopyContent(PdfObject, PdfDocument)
Copies object content from object 'from'.
protected virtual void CopyContent(PdfObject from, PdfDocument document)
Parameters
from
PdfObjectobject to copy content from.
document
PdfDocumentdocument to copy object to.
CopyContent(PdfObject, PdfDocument, ICopyFilter)
Copies object content from object 'from'.
protected virtual void CopyContent(PdfObject from, PdfDocument document, ICopyFilter filter)
Parameters
from
PdfObjectobject to copy content from.
document
PdfDocumentdocument to copy object to.
filter
ICopyFilterICopyFilter a filter that will apply on dictionaries and array Use NullCopyFilter for no filtering
CopyTo(PdfDocument)
Copies object to a specified document.
public virtual PdfObject CopyTo(PdfDocument document)
Parameters
document
PdfDocumentdocument to copy object to.
Returns
- PdfObject
copied object.
Remarks
Copies object to a specified document.
NOTE: Works only for objects that are read from document opened in reading mode,
otherwise an exception is thrown.
CopyTo(PdfDocument, bool)
Copies object to a specified document.
public virtual PdfObject CopyTo(PdfDocument document, bool allowDuplicating)
Parameters
document
PdfDocumentdocument to copy object to.
allowDuplicating
boolindicates if to allow copy objects which already have been copied. If object is associated with any indirect reference and allowDuplicating is false then already existing reference will be returned instead of copying object. If allowDuplicating is true then object will be copied and new indirect reference will be assigned.
Returns
- PdfObject
copied object.
Remarks
Copies object to a specified document.
NOTE: Works only for objects that are read from document opened in reading mode,
otherwise an exception is thrown.
CopyTo(PdfDocument, bool, ICopyFilter)
Copies object to a specified document.
public virtual PdfObject CopyTo(PdfDocument document, bool allowDuplicating, ICopyFilter copyFilter)
Parameters
document
PdfDocumentdocument to copy object to.
allowDuplicating
boolindicates if to allow copy objects which already have been copied. If object is associated with any indirect reference and allowDuplicating is false then already existing reference will be returned instead of copying object. If allowDuplicating is true then object will be copied and new indirect reference will be assigned.
copyFilter
ICopyFilterICopyFilter a filter to apply while copying arrays and dictionaries Use NullCopyFilter for no filtering
Returns
- PdfObject
copied object.
Remarks
Copies object to a specified document.
NOTE: Works only for objects that are read from document opened in reading mode,
otherwise an exception is thrown.
CopyTo(PdfDocument, ICopyFilter)
Copies object to a specified document.
public virtual PdfObject CopyTo(PdfDocument document, ICopyFilter copyFilter)
Parameters
document
PdfDocumentdocument to copy object to.
copyFilter
ICopyFilterICopyFilter a filter to apply while copying arrays and dictionaries Use NullCopyFilter for no filtering
Returns
- PdfObject
copied object.
Remarks
Copies object to a specified document.
NOTE: Works only for objects that are read from document opened in reading mode,
otherwise an exception is thrown.
Flush()
Flushes the object to the document.
public void Flush()
Flush(bool)
Flushes the object to the document.
public void Flush(bool canBeInObjStm)
Parameters
canBeInObjStm
boolindicates whether object can be placed into object stream.
GetIndirectReference()
Gets the indirect reference associated with the object.
public virtual PdfIndirectReference GetIndirectReference()
Returns
- PdfIndirectReference
indirect reference.
Remarks
Gets the indirect reference associated with the object. The indirect reference is used when flushing object to the document.
GetObjectType()
Gets object type.
public abstract byte GetObjectType()
Returns
- byte
object type.
IsArray()
Checks if this PdfObject
is of the type
PdfArray
.
public virtual bool IsArray()
Returns
- bool
true
orfalse
IsBoolean()
Checks if this PdfObject
is of the type
PdfBoolean
.
public virtual bool IsBoolean()
Returns
- bool
true
orfalse
IsDictionary()
Checks if this PdfObject
is of the type
PdfDictionary
.
public virtual bool IsDictionary()
Returns
- bool
true
orfalse
IsFlushed()
Indicates is the object has been flushed or not.
public virtual bool IsFlushed()
Returns
- bool
true if object has been flushed, otherwise false.
IsIndirect()
Checks if object is indirect.
public virtual bool IsIndirect()
Returns
Remarks
Checks if object is indirect.
Note:
Return value
true
doesn't necessarily mean that indirect reference of this object
is not null at the moment. Object could be marked as indirect and
be transformed to indirect on flushing.
E.g. all PdfStreams are transformed to indirect objects when they are written, but they don't always
have indirect references at any given moment.
IsIndirectReference()
Checks if this PdfObject
is of the type
PdfIndirectReference
.
public virtual bool IsIndirectReference()
Returns
- bool
true
if this is an indirect reference, otherwisefalse
IsLiteral()
Checks if this PdfObject
is of the type
PdfLiteral
.
public virtual bool IsLiteral()
Returns
- bool
true
if this is a literal, otherwisefalse
IsModified()
Indicates is the object has been set as modified or not.
public virtual bool IsModified()
Returns
- bool
true is object has been set as modified, otherwise false.
Remarks
Indicates is the object has been set as modified or not. Useful for incremental updates (e.g. appendMode).
IsName()
Checks if this PdfObject
is of the type
PdfName
.
public virtual bool IsName()
Returns
- bool
true
orfalse
IsNull()
Checks if this PdfObject
is of the type
PdfNull
.
public virtual bool IsNull()
Returns
- bool
true
orfalse
IsNumber()
Checks if this PdfObject
is of the type
PdfNumber
.
public virtual bool IsNumber()
Returns
- bool
true
orfalse
IsReleaseForbidden()
Checks if it's forbidden to release this PdfObject instance.
public virtual bool IsReleaseForbidden()
Returns
- bool
true if releasing this object is forbidden, otherwise false
Remarks
Checks if it's forbidden to release this PdfObject instance. Some objects are vital for the living period of PdfDocument or may be prevented from releasing by high-level entities dealing with the objects. Also it's not possible to release the objects that have been modified.
IsStream()
Checks if this PdfObject
is of the type
PdfStream
.
public virtual bool IsStream()
Returns
- bool
true
orfalse
IsString()
Checks if this PdfObject
is of the type
PdfString
.
public virtual bool IsString()
Returns
- bool
true
orfalse
MakeIndirect(PdfDocument)
Marks object to be saved as indirect.
public virtual PdfObject MakeIndirect(PdfDocument document)
Parameters
document
PdfDocumenta document the indirect reference will belong to.
Returns
- PdfObject
object itself.
MakeIndirect(PdfDocument, PdfIndirectReference)
Marks object to be saved as indirect.
public virtual PdfObject MakeIndirect(PdfDocument document, PdfIndirectReference reference)
Parameters
document
PdfDocumenta document the indirect reference will belong to.
reference
PdfIndirectReferenceindirect reference which will be associated with this document
Returns
- PdfObject
object itself.
NewInstance()
Creates new instance of object.
protected abstract PdfObject NewInstance()
Returns
- PdfObject
new instance of object.
Release()
public virtual void Release()
SetIndirectReference(PdfIndirectReference)
protected virtual PdfObject SetIndirectReference(PdfIndirectReference indirectReference)
Parameters
indirectReference
PdfIndirectReference
Returns
SetModified()
Sets the 'modified' flag to the indirect object, the flag denotes that the object was modified since the document opening.
public virtual PdfObject SetModified()
Returns
Remarks
Sets the 'modified' flag to the indirect object, the flag denotes that the object was modified since the document opening. It is recommended to set this flag after changing any PDF object.
For example flag is used in the append mode (see UseAppendMode() ). In append mode the whole document is preserved as is, and only changes to the document are appended to the end of the document file. Because of this, only modified objects need to be flushed and are allowed to be flushed (i.e. to be written).SetState(short)
Sets special states of current object.
protected virtual PdfObject SetState(short state)
Parameters
state
shortspecial flag of current object