com.lowagie.text.pdf
public class PdfReader extends Object implements PdfViewerPreferences
Nested Class Summary | |
---|---|
static class | PdfReader.PageRefs |
Constructor Summary | |
---|---|
protected | PdfReader() |
PdfReader(String filename) Reads and parses a PDF document. | |
PdfReader(String filename, byte[] ownerPassword) Reads and parses a PDF document. | |
PdfReader(byte[] pdfIn) Reads and parses a PDF document. | |
PdfReader(byte[] pdfIn, byte[] ownerPassword) Reads and parses a PDF document. | |
PdfReader(String filename, Certificate certificate, Key certificateKey, String certificateKeyProvider) Reads and parses a PDF document. | |
PdfReader(URL url) Reads and parses a PDF document. | |
PdfReader(URL url, byte[] ownerPassword) Reads and parses a PDF document. | |
PdfReader(InputStream is, byte[] ownerPassword)
Reads and parses a PDF document. | |
PdfReader(InputStream is)
Reads and parses a PDF document. | |
PdfReader(RandomAccessFileOrArray raf, byte[] ownerPassword)
Reads and parses a pdf document. | |
PdfReader(PdfReader reader) Creates an independent duplicate. |
Method Summary | |
---|---|
static byte[] | ASCII85Decode(byte[] in) Decodes a stream that has the ASCII85Decode filter. |
static byte[] | ASCIIHexDecode(byte[] in) Decodes a stream that has the ASCIIHexDecode filter. |
PRIndirectReference | addPdfObject(PdfObject obj) |
void | addViewerPreference(PdfName key, PdfObject value) Adds a viewer preference |
void | checkPRStreamLength(PRStream stream) |
void | close()
Closes the reader |
void | consolidateNamedDestinations() Replaces all the local named links with the actual destinations. |
int | createFakeFontSubsets() Finds all the fonts not subset but embedded and marks them as subset. |
static byte[] | decodePredictor(byte[] in, PdfObject dicPar) |
double | dumpPerc() |
protected static PdfDictionary | duplicatePdfDictionary(PdfDictionary original, PdfDictionary copy, PdfReader newReader) |
protected static PdfObject | duplicatePdfObject(PdfObject original, PdfReader newReader) |
void | eliminateSharedStreams() Eliminates shared streams if they exist. |
void | ensureXrefSize(int size) |
boolean | equalsArray(byte[] ar1, byte[] ar2, int size) |
static boolean | equalsn(byte[] a1, byte[] a2) |
static boolean | existsName(PdfDictionary dic, PdfName key, PdfName value) |
static byte[] | FlateDecode(byte[] in) Decodes a stream that has the FlateDecode filter. |
static byte[] | FlateDecode(byte[] in, boolean strict) A helper to FlateDecode. |
AcroFields | getAcroFields() Gets a read-only version of AcroFields . |
PRAcroForm | getAcroForm() Returns the document's acroform, if it has one. |
Rectangle | getBoxSize(int index, String boxName) Gets the box size. |
PdfDictionary | getCatalog() Returns the document's catalog. |
int | getCertificationLevel()
Gets the certification level for this document. |
Rectangle | getCropBox(int index) Gets the crop box without taking rotation into account. |
PdfIndirectReference | getCryptoRef() |
PdfEncryption | getDecrypt() |
int | getEofPos()
Gets the byte address of the %%EOF marker. |
int | getFileLength()
Getter for property fileLength. |
static String | getFontName(PdfDictionary dic) |
HashMap | getInfo() Returns the content of the document information dictionary as a HashMap
of String . |
String | getJavaScript(RandomAccessFileOrArray file)
Gets the global document JavaScript. |
String | getJavaScript()
Gets the global document JavaScript. |
int | getLastXref()
Gets the byte address of the last xref table. |
byte[] | getMetadata() Gets the XML metadata. |
static PdfArray | getNameArray(PdfObject obj) |
HashMap | getNamedDestination()
Gets all the named destinations as an HashMap . |
HashMap | getNamedDestinationFromNames()
Gets the named destinations from the /Dests key in the catalog as an HashMap . |
HashMap | getNamedDestinationFromStrings()
Gets the named destinations from the /Names key in the catalog as an HashMap . |
static Rectangle | getNormalizedRectangle(PdfArray box) Normalizes a Rectangle so that llx and lly are smaller than urx and ury. |
int | getNumberOfPages() Gets the number of pages in the document. |
byte[] | getPageContent(int pageNum, RandomAccessFileOrArray file) Gets the contents of the page. |
byte[] | getPageContent(int pageNum) Gets the contents of the page. |
PdfDictionary | getPageN(int pageNum) Gets the dictionary that represents a page. |
PdfDictionary | getPageNRelease(int pageNum) |
PRIndirectReference | getPageOrigRef(int pageNum) Gets the page reference to this page. |
int | getPageRotation(int index)
Gets the page rotation. |
int | getPageRotation(PdfDictionary page) |
Rectangle | getPageSize(int index) Gets the page size without taking rotation into account. |
Rectangle | getPageSize(PdfDictionary page)
Gets the page from a page dictionary |
Rectangle | getPageSizeWithRotation(int index) Gets the page size, taking rotation into account. |
Rectangle | getPageSizeWithRotation(PdfDictionary page)
Gets the rotated page from a page dictionary. |
static PdfObject | getPdfObject(PdfObject obj)
Reads a PdfObject resolving an indirect reference
if needed. |
static PdfObject | getPdfObject(PdfObject obj, PdfObject parent) |
PdfObject | getPdfObject(int idx) |
static PdfObject | getPdfObjectRelease(PdfObject obj) |
static PdfObject | getPdfObjectRelease(PdfObject obj, PdfObject parent)
Reads a PdfObject resolving an indirect reference
if needed. |
PdfObject | getPdfObjectRelease(int idx) |
protected PdfReaderInstance | getPdfReaderInstance(PdfWriter writer) |
char | getPdfVersion()
Gets the PDF version. |
int | getPermissions()
Gets the encryption permissions. |
RandomAccessFileOrArray | getSafeFile() Gets a new file instance of the original PDF
document. |
int | getSimpleViewerPreferences() |
static byte[] | getStreamBytes(PRStream stream, RandomAccessFileOrArray file) Get the content from a stream applying the required filters. |
static byte[] | getStreamBytes(PRStream stream) Get the content from a stream applying the required filters. |
static byte[] | getStreamBytesRaw(PRStream stream, RandomAccessFileOrArray file) Get the content from a stream as it is without applying any filter. |
static byte[] | getStreamBytesRaw(PRStream stream) Get the content from a stream as it is without applying any filter. |
static String | getSubsetPrefix(PdfDictionary dic) |
PdfDictionary | getTrailer()
Gets the trailer dictionary |
int | getXrefSize()
Gets the number of xref objects. |
boolean | is128Key()
Returns true if the PDF has a 128 bit key encryption. |
boolean | isAppendable()
Getter for property appendable. |
boolean | isEncrypted()
Returns true if the PDF is encrypted. |
boolean | isHybridXref()
Getter for property hybridXref. |
boolean | isNewXrefType()
Getter for property newXrefType. |
boolean | isRebuilt() Checks if the document had errors and was rebuilt. |
boolean | isTampered() Checks if the document was changed. |
void | iterateBookmarks(PdfObject outlineRef, HashMap names) |
static PdfObject | killIndirect(PdfObject obj)
Eliminates the reference to the object freeing the memory used by it and clearing
the xref entry. |
protected void | killXref(PdfObject obj) |
static byte[] | LZWDecode(byte[] in) Decodes a stream that has the LZWDecode filter. |
protected PdfArray | readArray() |
void | readDecryptedDocObj() |
protected PdfDictionary | readDictionary() |
protected void | readDocObj() |
protected void | readDocObjPartial() |
protected void | readObjStm(PRStream stream, IntHashtable map) |
protected PdfObject | readOneObjStm(PRStream stream, int idx) |
protected void | readPages() |
protected void | readPdf() |
protected void | readPdfPartial() |
protected PdfObject | readPRObject() |
protected PdfObject | readSingleObject(int k) |
protected void | readXref() |
protected PdfDictionary | readXrefSection() |
protected boolean | readXRefStream(int ptr) |
protected void | rebuildXref() |
void | releaseLastXrefPartial() |
static void | releaseLastXrefPartial(PdfObject obj) |
void | releasePage(int pageNum) |
void | removeAnnotations()
Removes all the annotations and fields from the document. |
void | removeFields()
Removes all the fields from the document. |
protected void | removeUnusedNode(PdfObject obj, boolean[] hits) |
int | removeUnusedObjects() Removes all the unreachable objects. |
void | removeUsageRights()
Removes any usage rights that this PDF may have. |
boolean | replaceNamedDestination(PdfObject obj, HashMap names) |
void | resetLastXrefPartial() |
void | resetReleasePage() |
void | selectPages(String ranges)
Selects the pages to keep in the document. |
void | selectPages(List pagesToKeep)
Selects the pages to keep in the document. |
void | setAppendable(boolean appendable)
Setter for property appendable. |
void | setPageContent(int pageNum, byte[] content) Sets the contents of the page. |
void | setTampered(boolean tampered)
Sets the tampered state. |
void | setViewerPreferences(int preferences) Sets the viewer preferences as the sum of several constants. |
void | setViewerPreferences(PdfViewerPreferencesImp vp) |
void | setXrefPartialObject(int idx, PdfObject obj) |
int | shuffleSubsetNames() Finds all the font subsets and changes the prefixes to some
random values. |
Parameters: filename the file name of the document
Throws: IOException on error
Parameters: filename the file name of the document ownerPassword the password to read the document
Throws: IOException on error
Parameters: pdfIn the byte array with the document
Throws: IOException on error
Parameters: pdfIn the byte array with the document ownerPassword the password to read the document
Throws: IOException on error
Parameters: filename the file name of the document certificate the certificate to read the document certificateKey the private key of the certificate certificateKeyProvider the security provider for certificateKey
Throws: IOException on error
Parameters: url the URL of the document
Throws: IOException on error
Parameters: url the URL of the document ownerPassword the password to read the document
Throws: IOException on error
Parameters: is the InputStream
containing the document. The stream is read to the
end but is not closed ownerPassword the password to read the document
Throws: IOException on error
Parameters: is the InputStream
containing the document. The stream is read to the
end but is not closed
Throws: IOException on error
PdfReader.close()
, reopen is automatic.Parameters: raf the document location ownerPassword the password or null
for no password
Throws: IOException on error
Parameters: reader the PdfReader
to duplicate
Parameters: in the input data
Returns: the decoded data
Parameters: in the input data
Returns: the decoded data
Parameters: obj
Returns: an indirect reference
Parameters: key a key for a viewer preference value a value for the viewer preference
See Also: PdfViewerPreferences
Returns: the number of fonts altered
Parameters: in dicPar
Returns: a byte array
Returns: the percentage of the cross reference table that has been read
Parameters: in the input data
Returns: the decoded data
Parameters: in the input data strict true
to read a correct stream. false
to try to read a corrupted stream
Returns: the decoded data
AcroFields
.Returns: a read-only version of AcroFields
Returns: the document's acroform
Parameters: index the page number. The first page is 1 boxName the box name
Returns: the box rectangle or null
Returns: the document's catalog
PdfSignatureAppearance.NOT_CERTIFIED
,
PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED
,
PdfSignatureAppearance.CERTIFIED_FORM_FILLING
and
PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS
.
No signature validation is made, use the methods availabe for that in AcroFields
.
Returns: gets the certification level for this document
Parameters: index the page number. The first page is 1
Returns: the crop box
Returns: the byte address of the %%EOF marker
Returns: Value of property fileLength.
HashMap
of String
.Returns: content of the document information dictionary
Parameters: file the document file
Returns: the global document JavaScript
Throws: IOException on error
Returns: the global document JavaScript
Throws: IOException on error
Returns: the byte address of the last xref table
Returns: the XML metadata
Throws: IOException on error
HashMap
. The key is the name
and the value is the destinations array.Returns: gets all the named destinations
HashMap
. The key is the name
and the value is the destinations array.Returns: gets the named destinations
HashMap
. The key is the name
and the value is the destinations array.Returns: gets the named destinations
Rectangle
so that llx and lly are smaller than urx and ury.Parameters: box the original rectangle
Returns: a normalized Rectangle
Returns: the number of pages in the document
Parameters: pageNum the page number. 1 is the first file the location of the PDF document
Returns: the content
Throws: IOException on error
Parameters: pageNum the page number. 1 is the first
Returns: the content
Throws: IOException on error
Parameters: pageNum the page number. 1 is the first
Returns: the page dictionary
Parameters: pageNum
Returns: a Dictionary object
Parameters: pageNum the page number. 1 is the first
Returns: the page reference
Parameters: index the page number. The first page is 1
Returns: the page rotation
Parameters: index the page number. The first page is 1
Returns: the page size
Parameters: page the page dictionary
Returns: the page
Rectangle
with the value of the /MediaBox and the /Rotate key.Parameters: index the page number. The first page is 1
Returns: a Rectangle
Parameters: page the page dictionary
Returns: the rotated page
PdfObject
resolving an indirect reference
if needed.Parameters: obj the PdfObject
to read
Returns: the resolved PdfObject
Parameters: obj parent
Returns: a PdfObject
Parameters: idx
Returns: aPdfObject
Parameters: obj
Returns: a PdfObject
PdfObject
resolving an indirect reference
if needed. If the reader was opened in partial mode the object will be released
to save memory.Parameters: obj the PdfObject
to read parent
Returns: a PdfObject
Parameters: idx
Returns: a PdfObject
Returns: the PDF version
PdfWriter.setEncryption()
.Returns: the encryption permissions
Returns: a new file instance of the original PDF document
Returns: an int that contains the Viewer Preferences.
Parameters: stream the stream file the location where the stream is
Returns: the stream content
Throws: IOException on error
Parameters: stream the stream
Returns: the stream content
Throws: IOException on error
Parameters: stream the stream file the location where the stream is
Returns: the stream content
Throws: IOException on error
Parameters: stream the stream
Returns: the stream content
Throws: IOException on error
Returns: the trailer dictionary
Returns: the number of xref objects
true
if the PDF has a 128 bit key encryption.Returns: true
if the PDF has a 128 bit key encryption
Returns: Value of property appendable.
true
if the PDF is encrypted.Returns: true
if the PDF is encrypted
Returns: Value of property hybridXref.
Returns: Value of property newXrefType.
Returns: true if rebuilt.
Returns: true
if the document was changed,
false
otherwise
Parameters: obj the object. If it's an indirect reference it will be eliminated
Returns: the object or the already erased dereferenced object
Parameters: in the input data
Returns: the decoded data
Throws: IOException
Parameters: obj
Parameters: pageNum
Returns: the number of indirect objects removed
Parameters: ranges the comma separated ranges as described in SequenceList
List
of Integer
. The page ordering can be changed but
no page repetitions are allowed. Note that it may be very slow in partial mode.Parameters: pagesToKeep the pages to keep in the document
Parameters: appendable New value of property appendable.
Parameters: content the new page content pageNum the page number. 1 is the first
Parameters: tampered the tampered state
Parameters: preferences the viewer preferences
See Also: PdfViewerPreferences
Returns: the number of font subsets altered