public class PdfReader extends Object implements Closeable, Serializable
Modifier and Type | Class and Description |
---|---|
protected static class |
PdfReader.ReusableRandomAccessSource |
Modifier and Type | Field and Description |
---|---|
protected static boolean |
correctStreamLength |
protected PdfEncryption |
decrypt |
protected boolean |
encrypted |
protected long |
eofPos |
protected boolean |
fixedXref |
protected PdfVersion |
headerPdfVersion |
protected boolean |
hybridXref |
protected long |
lastXref |
protected PdfAConformanceLevel |
pdfAConformanceLevel |
protected PdfDocument |
pdfDocument |
protected ReaderProperties |
properties |
protected boolean |
rebuiltXref |
protected PdfTokenizer |
tokens |
protected PdfDictionary |
trailer |
protected boolean |
xrefStm |
Constructor and Description |
---|
PdfReader(InputStream is)
Reads and parses a PDF document.
|
PdfReader(InputStream is, ReaderProperties properties)
Reads and parses a PDF document.
|
PdfReader(IRandomAccessSource byteSource, ReaderProperties properties)
Constructs a new PdfReader.
|
PdfReader(String filename)
Reads and parses a PDF document.
|
PdfReader(String filename, ReaderProperties properties)
Reads and parses a PDF document.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
byte[] |
computeUserPassword()
Computes user password if standard encryption handler is used with Standard40, Standard128 or AES128 encryption algorithm.
|
static byte[] |
decodeBytes(byte[] b, PdfDictionary streamDictionary)
Decode a byte[] applying the filters specified in the provided dictionary using default filter handlers.
|
static byte[] |
decodeBytes(byte[] b, PdfDictionary streamDictionary, Map<PdfName,IFilterHandler> filterHandlers)
Decode a byte[] applying the filters specified in the provided dictionary using the provided filter handlers.
|
protected void |
fixXref() |
int |
getCryptoMode() |
long |
getFileLength()
Provides the size of the opened file.
|
long |
getLastXref()
Gets position of the last Cross-Reference table.
|
byte[] |
getOriginalFileId() |
PdfAConformanceLevel |
getPdfAConformanceLevel()
Gets the declared Pdf/A conformance level of the source document that is being read.
|
long |
getPermissions() |
RandomAccessFileOrArray |
getSafeFile()
Gets a new file instance of the original PDF document.
|
boolean |
hasFixedXref()
If any exception generated while reading PdfObject, PdfReader will try to fix offsets of all objects.
|
boolean |
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.
|
boolean |
hasRebuiltXref()
If any exception generated while reading XRef section, PdfReader will try to rebuild it.
|
boolean |
hasXrefStm()
Indicates whether the document has Cross-Reference Streams.
|
boolean |
isCloseStream() |
boolean |
isEncrypted() |
boolean |
isOpenedWithFullPermission() |
protected PdfArray |
readArray(boolean objStm) |
protected PdfDictionary |
readDictionary(boolean objStm) |
protected PdfObject |
readObject(boolean readAsDirect) |
protected PdfObject |
readObject(boolean readAsDirect, boolean objStm) |
protected PdfObject |
readObject(PdfIndirectReference reference) |
protected void |
readObjectStream(PdfStream objectStream) |
protected void |
readPdf()
Parses the entire PDF
|
protected PdfName |
readPdfName(boolean readAsDirect) |
InputStream |
readStream(PdfStream stream, boolean decode)
Gets the input stream associated with PdfStream.
|
byte[] |
readStreamBytes(PdfStream stream, boolean decode)
Reads and gets stream bytes.
|
byte[] |
readStreamBytesRaw(PdfStream stream) |
protected void |
readXref() |
protected PdfDictionary |
readXrefSection() |
protected boolean |
readXrefStream(long ptr) |
protected void |
rebuildXref() |
void |
setCloseStream(boolean closeStream) |
PdfReader |
setUnethicalReading(boolean unethicalReading) |
protected static boolean correctStreamLength
protected PdfTokenizer tokens
protected PdfEncryption decrypt
protected PdfVersion headerPdfVersion
protected long lastXref
protected long eofPos
protected PdfDictionary trailer
protected PdfDocument pdfDocument
protected PdfAConformanceLevel pdfAConformanceLevel
protected ReaderProperties properties
protected boolean encrypted
protected boolean rebuiltXref
protected boolean hybridXref
protected boolean fixedXref
protected boolean xrefStm
public PdfReader(IRandomAccessSource byteSource, ReaderProperties properties) throws IOException
byteSource
- source of bytes for the reader
properties
- properties of the created reader
IOException
public PdfReader(InputStream is, ReaderProperties properties) throws IOException
is
- the InputStream
containing the document. The stream is read to the end but is not closed
properties
- properties of the created reader
IOException
- on error
public PdfReader(InputStream is) throws IOException
is
- the InputStream
containing the document. Stream is closed automatically, when document is closed, if user doesn't want to close stream, he should set closeStream=false;
IOException
- on error
public PdfReader(String filename, ReaderProperties properties) throws IOException
filename
- the file name of the document
properties
- properties of the created reader
IOException
- on error
public PdfReader(String filename) throws IOException
filename
- the file name of the document
IOException
- on error
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public PdfReader setUnethicalReading(boolean unethicalReading)
public boolean isCloseStream()
public void setCloseStream(boolean closeStream)
public boolean hasRebuiltXref()
public boolean hasHybridXref()
public boolean hasXrefStm()
public boolean hasFixedXref()
public long getLastXref()
public byte[] readStreamBytes(PdfStream stream, boolean decode) throws IOException
decode
- true if to get decoded stream bytes, false if to leave it originally encoded.
IOException
public byte[] readStreamBytesRaw(PdfStream stream) throws IOException
IOException
public InputStream readStream(PdfStream stream, boolean decode) throws IOException
decode
- true if to get decoded stream, false if to leave it originally encoded.
IOException
public static byte[] decodeBytes(byte[] b, PdfDictionary streamDictionary)
b
- the bytes to decode
streamDictionary
- the dictionary that contains filter information
PdfException
- if there are any problems decoding the bytes
public static byte[] decodeBytes(byte[] b, PdfDictionary streamDictionary, Map<PdfName,IFilterHandler> filterHandlers)
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
PdfException
- if there are any problems decoding the bytes
public RandomAccessFileOrArray getSafeFile()
public long getFileLength() throws IOException
IOException
public boolean isOpenedWithFullPermission()
public long getPermissions()
public int getCryptoMode()
public PdfAConformanceLevel getPdfAConformanceLevel()
null
if no Pdf/A conformance level information is specified.
public byte[] computeUserPassword()
protected void readPdf() throws IOException
IOException
protected void readObjectStream(PdfStream objectStream) throws IOException
IOException
protected PdfObject readObject(PdfIndirectReference reference)
protected PdfObject readObject(boolean readAsDirect) throws IOException
IOException
protected PdfObject readObject(boolean readAsDirect, boolean objStm) throws IOException
IOException
protected PdfName readPdfName(boolean readAsDirect)
protected PdfDictionary readDictionary(boolean objStm) throws IOException
IOException
protected PdfArray readArray(boolean objStm) throws IOException
IOException
protected void readXref() throws IOException
IOException
protected PdfDictionary readXrefSection() throws IOException
IOException
protected boolean readXrefStream(long ptr) throws IOException
IOException
protected void fixXref() throws IOException
IOException
protected void rebuildXref() throws IOException
IOException
public byte[] getOriginalFileId()
public boolean isEncrypted()
Copyright © 1998–2016 iText Group NV. All rights reserved.