iText 8.0.4 API
iText.Kernel.Pdf.PdfReader Class Reference

Reads a PDF document. More...

Inheritance diagram for iText.Kernel.Pdf.PdfReader:

Classes

class   ReusableRandomAccessSource
 
class   StrictnessLevel
  Enumeration representing the strictness level for reading. More...
 
class   XrefProcessor
  Class containing a callback which is called on every xref table reading.
 

Public Member Functions

  PdfReader (IRandomAccessSource byteSource, ReaderProperties properties)
  Constructs a new PdfReader. More...
 
  PdfReader (Stream @is, ReaderProperties properties)
  Reads and parses a PDF document. More...
 
  PdfReader (FileInfo file)
  Reads and parses a PDF document. More...
 
  PdfReader (Stream @is)
  Reads and parses a PDF document. More...
 
  PdfReader (String filename, ReaderProperties properties)
  Reads and parses a PDF document. More...
 
  PdfReader (String filename)
  Reads and parses a PDF document. More...
 
  PdfReader (FileInfo file, ReaderProperties properties)
  Reads and parses a PDF document. More...
 
virtual void  Close ()
  Close iText.IO.Source.PdfTokenizer. More...
 
virtual iText.Kernel.Pdf.PdfReader  SetUnethicalReading (bool unethicalReading)
  The iText is not responsible if you decide to change the value of this parameter. More...
 
virtual iText.Kernel.Pdf.PdfReader  SetMemorySavingMode (bool memorySavingMode)
  Defines if memory saving mode is enabled. More...
 
virtual PdfReader.StrictnessLevel  GetStrictnessLevel ()
  Get the current StrictnessLevel of the reader. More...
 
virtual iText.Kernel.Pdf.PdfReader  SetStrictnessLevel (PdfReader.StrictnessLevel strictnessLevel)
  Set the StrictnessLevel for the reader. More...
 
virtual bool  IsCloseStream ()
  Gets whether Close() method shall close input stream. More...
 
virtual void  SetCloseStream (bool closeStream)
  Sets whether Close() method shall close input stream. More...
 
virtual bool  HasRebuiltXref ()
  If any exception generated while reading XRef section, PdfReader will try to rebuild it. More...
 
virtual bool  HasHybridXref ()
  Some documents contain hybrid XRef, for more information see "7.5.8.4 Compatibility with Applications That Do Not Support Compressed Reference Streams" in PDF 32000-1:2008 spec. More...
 
virtual bool  HasXrefStm ()
  Indicates whether the document has Cross-Reference Streams. More...
 
virtual bool  HasFixedXref ()
  If any exception generated while reading PdfObject, PdfReader will try to fix offsets of all objects. More...
 
virtual long  GetLastXref ()
  Gets position of the last Cross-Reference table. More...
 
virtual byte[]  ReadStreamBytes (PdfStream stream, bool decode)
  Reads, decrypt and optionally decode stream bytes. More...
 
virtual byte[]  ReadStreamBytesRaw (PdfStream stream)
  Reads and decrypt stream bytes. More...
 
virtual Stream  ReadStream (PdfStream stream, bool decode)
  Reads, decrypts and optionally decodes stream bytes into System.IO.MemoryStream. More...
 
virtual RandomAccessFileOrArray  GetSafeFile ()
  Gets a new file instance of the original PDF document. More...
 
virtual long  GetFileLength ()
  Provides the size of the opened file. More...
 
virtual bool  IsOpenedWithFullPermission ()
  Checks if the document was opened with the owner password so that the end application can decide what level of access restrictions to apply. More...
 
virtual long  GetPermissions ()
  Gets the encryption permissions. More...
 
virtual int  GetCryptoMode ()
  Gets encryption algorithm and access permissions. More...
 
virtual PdfAConformanceLevel  GetPdfAConformanceLevel ()
  Gets the declared PDF/A conformance level of the source document that is being read. More...
 
virtual byte[]  ComputeUserPassword ()
  Computes user password if standard encryption handler is used with Standard40, Standard128 or AES128 encryption algorithm. More...
 
virtual byte[]  GetOriginalFileId ()
  Gets original file ID, the first element in PdfName.ID key of trailer. More...
 
virtual byte[]  GetModifiedFileId ()
  Gets modified file ID, the second element in PdfName.ID key of trailer. More...
 
virtual bool  IsEncrypted ()
  Checks if the PdfDocument read with this PdfReader is encrypted. More...
 

Static Public Member Functions

static byte[]  DecodeBytes (byte[] b, PdfDictionary streamDictionary)
  Decode bytes applying the filters specified in the provided dictionary using default filter handlers. More...
 
static byte[]  DecodeBytes (byte[] b, PdfDictionary streamDictionary, IDictionary< PdfName, IFilterHandler > filterHandlers)
  Decode a byte[] applying the filters specified in the provided dictionary using the provided filter handlers. More...
 

Static Public Attributes

static readonly PdfReader.StrictnessLevel  DEFAULT_STRICTNESS_LEVEL = PdfReader.StrictnessLevel.LENIENT
  The default StrictnessLevel to be used. More...
 

Detailed Description

Reads a PDF document.

Constructor & Destructor Documentation

◆ PdfReader() [1/7]

iText.Kernel.Pdf.PdfReader.PdfReader ( IRandomAccessSource  byteSource,
ReaderProperties  properties 
)
inline

Constructs a new PdfReader.

Parameters
byteSource source of bytes for the reader
properties properties of the created reader

◆ PdfReader() [2/7]

iText.Kernel.Pdf.PdfReader.PdfReader ( Stream @  is,
ReaderProperties  properties 
)
inline

Reads and parses a PDF document.

Parameters
is the InputStream containing the document. If the inputStream is an instance of iText.IO.Source.RASInputStream then the iText.IO.Source.IRandomAccessSource would be extracted. Otherwise the stream is read to the end but is not closed.
properties properties of the created reader

◆ PdfReader() [3/7]

iText.Kernel.Pdf.PdfReader.PdfReader ( FileInfo  file )
inline

Reads and parses a PDF document.

Parameters
file the File containing the document.

◆ PdfReader() [4/7]

iText.Kernel.Pdf.PdfReader.PdfReader ( Stream @  is )
inline

Reads and parses a PDF document.

Parameters
is the InputStream containing the document. If the inputStream is an instance of iText.IO.Source.RASInputStream then the iText.IO.Source.IRandomAccessSource would be extracted. Otherwise the stream is read to the end but is not closed.

◆ PdfReader() [5/7]

iText.Kernel.Pdf.PdfReader.PdfReader ( String  filename,
ReaderProperties  properties 
)
inline

Reads and parses a PDF document.

Parameters
filename the file name of the document
properties properties of the created reader

◆ PdfReader() [6/7]

iText.Kernel.Pdf.PdfReader.PdfReader ( String  filename )
inline

Reads and parses a PDF document.

Parameters
filename the file name of the document

◆ PdfReader() [7/7]

iText.Kernel.Pdf.PdfReader.PdfReader ( FileInfo  file,
ReaderProperties  properties 
)
inline

Reads and parses a PDF document.

Parameters
file the file of the document
properties properties of the created reader

Member Function Documentation

◆ Close()

virtual void iText.Kernel.Pdf.PdfReader.Close ( )
inlinevirtual

◆ ComputeUserPassword()

virtual byte [] iText.Kernel.Pdf.PdfReader.ComputeUserPassword ( )
inlinevirtual

Computes user password if standard encryption handler is used with Standard40, Standard128 or AES128 encryption algorithm.

Returns
user password, or null if not a standard encryption handler was used or if ownerPasswordUsed wasn't use to open the document.

◆ DecodeBytes() [1/2]

static byte [] iText.Kernel.Pdf.PdfReader.DecodeBytes ( byte[]  b,
PdfDictionary  streamDictionary 
)
inlinestatic

Decode bytes applying the filters specified in the provided dictionary using default filter handlers.

Parameters
b the bytes to decode
streamDictionary the dictionary that contains filter information
Returns
the decoded bytes

◆ DecodeBytes() [2/2]

static byte [] iText.Kernel.Pdf.PdfReader.DecodeBytes ( byte[]  b,
PdfDictionary  streamDictionary,
IDictionary< PdfName, IFilterHandler filterHandlers 
)
inlinestatic

Decode a byte[] applying the filters specified in the provided dictionary using the provided filter handlers.

Parameters
b the bytes to decode
streamDictionary the dictionary that contains filter information
filterHandlers the map used to look up a handler for each type of filter
Returns
the decoded bytes

◆ GetCryptoMode()

virtual int iText.Kernel.Pdf.PdfReader.GetCryptoMode ( )
inlinevirtual

Gets encryption algorithm and access permissions.

Returns

int value corresponding to a certain type of encryption.

See also
EncryptionConstants

◆ GetFileLength()

virtual long iText.Kernel.Pdf.PdfReader.GetFileLength ( )
inlinevirtual

Provides the size of the opened file.

Returns
The size of the opened file.

◆ GetLastXref()

virtual long iText.Kernel.Pdf.PdfReader.GetLastXref ( )
inlinevirtual

Gets position of the last Cross-Reference table.

Returns
-1 if Cross-Reference table has rebuilt, otherwise position of the last Cross-Reference table.

◆ GetModifiedFileId()

virtual byte [] iText.Kernel.Pdf.PdfReader.GetModifiedFileId ( )
inlinevirtual

Gets modified file ID, the second element in PdfName.ID key of trailer.

Gets modified file ID, the second element in PdfName.ID key of trailer. If the size of ID array does not equal 2, an empty array will be returned.

The returned value reflects the value that was written in opened document. If document is modified, the ultimate document id can be retrieved from PdfDocument.GetModifiedDocumentId().

Returns
byte array represents modified file ID.
See also
PdfDocument.GetModifiedDocumentId()

◆ GetOriginalFileId()

virtual byte [] iText.Kernel.Pdf.PdfReader.GetOriginalFileId ( )
inlinevirtual

Gets original file ID, the first element in PdfName.ID key of trailer.

Gets original file ID, the first element in PdfName.ID key of trailer. If the size of ID array does not equal 2, an empty array will be returned.

The returned value reflects the value that was written in opened document. If document is modified, the ultimate document id can be retrieved from PdfDocument.GetOriginalDocumentId().

Returns
byte array represents original file ID.
See also
PdfDocument.GetOriginalDocumentId()

◆ GetPdfAConformanceLevel()

virtual PdfAConformanceLevel iText.Kernel.Pdf.PdfReader.GetPdfAConformanceLevel ( )
inlinevirtual

Gets the declared PDF/A conformance level of the source document that is being read.

Gets the declared PDF/A conformance level of the source document that is being read. Note that this information is provided via XMP metadata and is not verified by iText. pdfAConformanceLevel is lazy initialized. It will be initialized during the first call of this method.

Returns
conformance level of the source document, or null if no PDF/A conformance level information is specified.

◆ GetPermissions()

virtual long iText.Kernel.Pdf.PdfReader.GetPermissions ( )
inlinevirtual

Gets the encryption permissions.

Gets the encryption permissions. It can be used directly in WriterProperties.SetStandardEncryption(byte[], byte[], int, int). See ISO 32000-1, Table 22 for more details.

Returns
the encryption permissions, an unsigned 32-bit quantity.

◆ GetSafeFile()

virtual RandomAccessFileOrArray iText.Kernel.Pdf.PdfReader.GetSafeFile ( )
inlinevirtual

Gets a new file instance of the original PDF document.

Returns
a new file instance of the original PDF document

◆ GetStrictnessLevel()

virtual PdfReader.StrictnessLevel iText.Kernel.Pdf.PdfReader.GetStrictnessLevel ( )
inlinevirtual

Get the current StrictnessLevel of the reader.

Returns
the current StrictnessLevel

◆ HasFixedXref()

virtual bool iText.Kernel.Pdf.PdfReader.HasFixedXref ( )
inlinevirtual

If any exception generated while reading PdfObject, PdfReader will try to fix offsets of all objects.

If any exception generated while reading PdfObject, PdfReader will try to fix offsets of all objects.

This method's returned value might change over time, because PdfObjects reading can be postponed even up to document closing.

Returns
true, if PdfReader fixed offsets of PdfObjects.

◆ HasHybridXref()

virtual bool iText.Kernel.Pdf.PdfReader.HasHybridXref ( )
inlinevirtual

Some documents contain hybrid XRef, for more information see "7.5.8.4 Compatibility with Applications That Do Not Support Compressed Reference Streams" in PDF 32000-1:2008 spec.

Returns
true, if the document has hybrid Cross-Reference section.

◆ HasRebuiltXref()

virtual bool iText.Kernel.Pdf.PdfReader.HasRebuiltXref ( )
inlinevirtual

If any exception generated while reading XRef section, PdfReader will try to rebuild it.

Returns
true, if PdfReader rebuilt Cross-Reference section.

◆ HasXrefStm()

virtual bool iText.Kernel.Pdf.PdfReader.HasXrefStm ( )
inlinevirtual

Indicates whether the document has Cross-Reference Streams.

Returns
true, if the document has Cross-Reference Streams.

◆ IsCloseStream()

virtual bool iText.Kernel.Pdf.PdfReader.IsCloseStream ( )
inlinevirtual

Gets whether Close() method shall close input stream.

Returns
true, if Close() method will close input stream, otherwise false.

◆ IsEncrypted()

virtual bool iText.Kernel.Pdf.PdfReader.IsEncrypted ( )
inlinevirtual

Checks if the PdfDocument read with this PdfReader is encrypted.

Returns

true is the document is encrypted, otherwise false.

◆ IsOpenedWithFullPermission()

virtual bool iText.Kernel.Pdf.PdfReader.IsOpenedWithFullPermission ( )
inlinevirtual

Checks if the document was opened with the owner password so that the end application can decide what level of access restrictions to apply.

Checks if the document was opened with the owner password so that the end application can decide what level of access restrictions to apply. If the document is not encrypted it will return true.

Returns

true if the document was opened with the owner password or if it's not encrypted, false if the document was opened with the user password.

◆ ReadStream()

virtual Stream iText.Kernel.Pdf.PdfReader.ReadStream ( PdfStream  stream,
bool  decode 
)
inlinevirtual

Reads, decrypts and optionally decodes stream bytes into System.IO.MemoryStream.

Reads, decrypts and optionally decodes stream bytes into System.IO.MemoryStream. User is responsible for closing returned stream.

Parameters
stream a PdfStream stream instance to be read
decode true if to get decoded stream, false if to leave it originally encoded.
Returns
InputStream or null if reading was failed.

◆ ReadStreamBytes()

virtual byte [] iText.Kernel.Pdf.PdfReader.ReadStreamBytes ( PdfStream  stream,
bool  decode 
)
inlinevirtual

Reads, decrypt and optionally decode stream bytes.

Reads, decrypt and optionally decode stream bytes. Note, this method doesn't store actual bytes in any internal structures.

Parameters
stream a PdfStream stream instance to be read and optionally decoded.
decode true if to get decoded stream bytes, false if to leave it originally encoded.
Returns
byte[] array.

◆ ReadStreamBytesRaw()

virtual byte [] iText.Kernel.Pdf.PdfReader.ReadStreamBytesRaw ( PdfStream  stream )
inlinevirtual

Reads and decrypt stream bytes.

Reads and decrypt stream bytes. Note, this method doesn't store actual bytes in any internal structures.

Parameters
stream a PdfStream stream instance to be read
Returns
byte[] array.

◆ SetCloseStream()

virtual void iText.Kernel.Pdf.PdfReader.SetCloseStream ( bool  closeStream )
inlinevirtual

Sets whether Close() method shall close input stream.

Parameters
closeStream true, if Close() method shall close input stream, otherwise false.

◆ SetMemorySavingMode()

virtual iText.Kernel.Pdf.PdfReader iText.Kernel.Pdf.PdfReader.SetMemorySavingMode ( bool  memorySavingMode )
inlinevirtual

Defines if memory saving mode is enabled.

Defines if memory saving mode is enabled.

By default memory saving mode is disabled for the sake of time–memory trade-off.

If memory saving mode is enabled, document processing might slow down, but reading will be less memory demanding.

Parameters
memorySavingMode true to enable memory saving mode, false to disable it.
Returns
this PdfReader instance.

◆ SetStrictnessLevel()

virtual iText.Kernel.Pdf.PdfReader iText.Kernel.Pdf.PdfReader.SetStrictnessLevel ( PdfReader.StrictnessLevel  strictnessLevel )
inlinevirtual

Set the StrictnessLevel for the reader.

Set the StrictnessLevel for the reader. If the argument is null , then the DEFAULT_STRICTNESS_LEVEL will be used.

Parameters
strictnessLevel the StrictnessLevel to set
Returns
this PdfReader instance

◆ SetUnethicalReading()

virtual iText.Kernel.Pdf.PdfReader iText.Kernel.Pdf.PdfReader.SetUnethicalReading ( bool  unethicalReading )
inlinevirtual

The iText is not responsible if you decide to change the value of this parameter.

Parameters
unethicalReading true to enable unethicalReading, false to disable it. By default unethicalReading is disabled.
Returns
this PdfReader instance.

Member Data Documentation

◆ DEFAULT_STRICTNESS_LEVEL

readonly PdfReader.StrictnessLevel iText.Kernel.Pdf.PdfReader.DEFAULT_STRICTNESS_LEVEL = PdfReader.StrictnessLevel.LENIENT
static

The default StrictnessLevel to be used.