iText 7 7.1.8 API
iText.Kernel.Pdf.PdfReader Class Reference

Reads a PDF document. More...

Inheritance diagram for iText.Kernel.Pdf.PdfReader:

Classes

class   ReusableRandomAccessSource
 

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...
 
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 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, decrypt and optionally decode stream bytes into System.IO.MemoryStreamUser is responsible for closing returned stream. 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. If the size of ID array does not equal 2, an empty array will be returned. More...
 
virtual byte[]  GetModifiedFileId ()
  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. More...
 
virtual bool  IsEncrypted ()
 

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...
 

Detailed Description

Reads a PDF document.

Constructor & Destructor Documentation

◆ PdfReader() [1/6]

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
Exceptions
System.IO.IOException

◆ PdfReader() [2/6]

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

Reads and parses a PDF document.

Parameters
is the InputStream containing the document. The stream is read to the end but is not closed.
properties properties of the created reader
Exceptions
System.IO.IOException on error

◆ PdfReader() [3/6]

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

Reads and parses a PDF document.

Parameters
file the File containing the document.
Exceptions
System.IO.IOException on error
System.IO.FileNotFoundException when the specified File is not found

◆ PdfReader() [4/6]

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

Reads and parses a PDF document.

Parameters
is the InputStream containing the document. the InputStream containing the document. The stream is read to the end but is not closed.
Exceptions
System.IO.IOException on error

◆ PdfReader() [5/6]

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
Exceptions
System.IO.IOException on error

◆ PdfReader() [6/6]

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

Reads and parses a PDF document.

Parameters
filename the file name of the document
Exceptions
System.IO.IOException on error

Member Function Documentation

◆ Close()

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

Close iText.IO.Source.PdfTokenizer

Exceptions
System.IO.IOException on error.

◆ 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
Exceptions
iText.Kernel.PdfException if there are any problems decoding the 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
Exceptions
iText.Kernel.PdfException if there are any problems decoding the bytes

◆ GetCryptoMode()

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

Gets encryption algorithm and access permissions.

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.
Exceptions
System.IO.IOException on error.

◆ 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. If the size of ID array does not equal 2, an empty array will be returned.

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. If the size of ID array does not equal 2, an empty array will be returned.

Returns
byte array represents original file ID.

PdfDocument::getOriginalDocumentId(). The ultimate document id should be taken from PdfDocument

◆ 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.

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

◆ 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.

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.

◆ 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, decrypt and optionally decode stream bytes into System.IO.MemoryStreamUser is responsible for closing returned stream.

Parameters
decode true if to get decoded stream, false if to leave it originally encoded.
Returns
InputStream or null if reading was failed.
Exceptions
System.IO.IOException on error.

◆ 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
decode true if to get decoded stream bytes, false if to leave it originally encoded.
Returns
byte[] array.
Exceptions
System.IO.IOException on error.

◆ 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.

Returns
byte[] array.
Exceptions
System.IO.IOException on error.

◆ 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.

◆ 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.