|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.lowagie.text.pdf.PdfReader
public class PdfReader
Reads a PDF document.
| Nested Class Summary | |
|---|---|
(package private) static class |
PdfReader.PageRefs
|
| Field Summary | |
|---|---|
protected PRAcroForm |
acroForm
|
protected boolean |
acroFormParsed
|
private boolean |
appendable
Holds value of property appendable. |
protected PdfDictionary |
catalog
|
protected Certificate |
certificate
|
protected Key |
certificateKey
|
protected String |
certificateKeyProvider
|
protected boolean |
consolidateNamedDestinations
|
private PRIndirectReference |
cryptoRef
|
protected PdfEncryption |
decrypt
|
protected boolean |
encrypted
|
private boolean |
encryptionError
|
(package private) static byte[] |
endobj
|
(package private) static byte[] |
endstream
|
protected int |
eofPos
|
private int |
fileLength
|
protected int |
freeXref
|
private boolean |
hybridXref
|
protected int |
lastXref
|
private int |
lastXrefPartial
|
protected boolean |
newXrefType
|
private int |
objGen
|
private int |
objNum
|
protected HashMap |
objStmMark
|
protected IntHashtable |
objStmToOffset
|
private boolean |
ownerPasswordUsed
|
(package private) static PdfName[] |
pageInhCandidates
|
protected PdfReader.PageRefs |
pageRefs
|
private boolean |
partial
|
protected byte[] |
password
|
protected char |
pdfVersion
|
protected int |
pValue
|
protected boolean |
rebuilt
|
(package private) PdfDictionary |
rootPages
|
protected int |
rValue
|
protected boolean |
sharedStreams
|
protected ArrayList |
strings
|
protected boolean |
tampered
|
protected PRTokeniser |
tokens
|
protected PdfDictionary |
trailer
|
private PdfViewerPreferencesImp |
viewerPreferences
|
protected int[] |
xref
|
private ArrayList |
xrefObj
|
| Constructor Summary | |
|---|---|
protected |
PdfReader()
|
|
PdfReader(byte[] pdfIn)
Reads and parses a PDF document. |
|
PdfReader(byte[] pdfIn,
byte[] ownerPassword)
Reads and parses a PDF document. |
|
PdfReader(InputStream is)
Reads and parses a PDF document. |
|
PdfReader(InputStream is,
byte[] ownerPassword)
Reads and parses a PDF document. |
|
PdfReader(PdfReader reader)
Creates an independent duplicate. |
|
PdfReader(RandomAccessFileOrArray raf,
byte[] ownerPassword)
Reads and parses a pdf document. |
|
PdfReader(String filename)
Reads and parses a PDF document. |
|
PdfReader(String filename,
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. |
| Method Summary | |
|---|---|
PRIndirectReference |
addPdfObject(PdfObject obj)
|
void |
addViewerPreference(PdfName key,
PdfObject value)
Adds a viewer preference |
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. |
private void |
checkPRStreamLength(PRStream stream)
|
void |
close()
Closes the reader |
byte[] |
computeUserPassword()
|
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. |
private void |
ensureXrefSize(int size)
|
private boolean |
equalsArray(byte[] ar1,
byte[] ar2,
int size)
|
(package private) static boolean |
equalsn(byte[] a1,
byte[] a2)
|
(package private) 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. |
int |
getCryptoMode()
|
(package private) PdfIndirectReference |
getCryptoRef()
|
(package private) PdfEncryption |
getDecrypt()
|
int |
getEofPos()
Gets the byte address of the %%EOF marker. |
int |
getFileLength()
Getter for property fileLength. |
(package private) static String |
getFontName(PdfDictionary dic)
|
HashMap |
getInfo()
Returns the content of the document information dictionary as a HashMap
of String. |
String |
getJavaScript()
Gets the global document JavaScript. |
String |
getJavaScript(RandomAccessFileOrArray file)
Gets the global document JavaScript. |
int |
getLastXref()
Gets the byte address of the last xref table. |
ArrayList |
getLinks(int page)
|
byte[] |
getMetadata()
Gets the XML metadata. |
private 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)
Gets the contents of the page. |
byte[] |
getPageContent(int pageNum,
RandomAccessFileOrArray file)
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. |
(package private) 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. |
PdfObject |
getPdfObject(int idx)
|
static PdfObject |
getPdfObject(PdfObject obj)
Reads a PdfObject resolving an indirect reference
if needed. |
static PdfObject |
getPdfObject(PdfObject obj,
PdfObject parent)
|
PdfObject |
getPdfObjectRelease(int idx)
|
static PdfObject |
getPdfObjectRelease(PdfObject obj)
|
static PdfObject |
getPdfObjectRelease(PdfObject obj,
PdfObject parent)
Reads a PdfObject resolving an indirect reference
if needed. |
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)
Get the content from a stream applying the required filters. |
static byte[] |
getStreamBytes(PRStream stream,
RandomAccessFileOrArray file)
Get the content from a stream applying the required filters. |
static byte[] |
getStreamBytesRaw(PRStream stream)
Get the content from a stream as it is without applying any filter. |
static byte[] |
getStreamBytesRaw(PRStream stream,
RandomAccessFileOrArray file)
Get the content from a stream as it is without applying any filter. |
(package private) 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 |
isMetadataEncrypted()
|
boolean |
isNewXrefType()
Getter for property newXrefType. |
boolean |
isOpenedWithFullPermissions()
Checks if the document was opened with the owner password so that the end application can decide what level of access restrictions to apply. |
boolean |
isRebuilt()
Checks if the document had errors and was rebuilt. |
boolean |
isTampered()
Checks if the document was changed. |
private 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()
|
private 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. |
private boolean |
replaceNamedDestination(PdfObject obj,
HashMap names)
|
void |
resetLastXrefPartial()
|
void |
resetReleasePage()
|
void |
selectPages(List pagesToKeep)
Selects the pages to keep in the document. |
void |
selectPages(String ranges)
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 |
setPageContent(int pageNum,
byte[] content,
int compressionLevel)
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. |
(package private) void |
setViewerPreferences(PdfViewerPreferencesImp vp)
|
private void |
setXrefPartialObject(int idx,
PdfObject obj)
|
int |
shuffleSubsetNames()
Finds all the font subsets and changes the prefixes to some random values. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final PdfName[] pageInhCandidates
static final byte[] endstream
static final byte[] endobj
protected PRTokeniser tokens
protected int[] xref
protected HashMap objStmMark
protected IntHashtable objStmToOffset
protected boolean newXrefType
private ArrayList xrefObj
PdfDictionary rootPages
protected PdfDictionary trailer
protected PdfDictionary catalog
protected PdfReader.PageRefs pageRefs
protected PRAcroForm acroForm
protected boolean acroFormParsed
protected boolean encrypted
protected boolean rebuilt
protected int freeXref
protected boolean tampered
protected int lastXref
protected int eofPos
protected char pdfVersion
protected PdfEncryption decrypt
protected byte[] password
protected Key certificateKey
protected Certificate certificate
protected String certificateKeyProvider
private boolean ownerPasswordUsed
protected ArrayList strings
protected boolean sharedStreams
protected boolean consolidateNamedDestinations
protected int rValue
protected int pValue
private int objNum
private int objGen
private int fileLength
private boolean hybridXref
private int lastXrefPartial
private boolean partial
private PRIndirectReference cryptoRef
private PdfViewerPreferencesImp viewerPreferences
private boolean encryptionError
private boolean appendable
| Constructor Detail |
|---|
protected PdfReader()
public PdfReader(String filename)
throws IOException
filename - the file name of the document
IOException - on error
public PdfReader(String filename,
byte[] ownerPassword)
throws IOException
filename - the file name of the documentownerPassword - the password to read the document
IOException - on error
public PdfReader(byte[] pdfIn)
throws IOException
pdfIn - the byte array with the document
IOException - on error
public PdfReader(byte[] pdfIn,
byte[] ownerPassword)
throws IOException
pdfIn - the byte array with the documentownerPassword - the password to read the document
IOException - on error
public PdfReader(String filename,
Certificate certificate,
Key certificateKey,
String certificateKeyProvider)
throws IOException
filename - the file name of the documentcertificate - the certificate to read the documentcertificateKey - the private key of the certificatecertificateKeyProvider - the security provider for certificateKey
IOException - on error
public PdfReader(URL url)
throws IOException
url - the URL of the document
IOException - on error
public PdfReader(URL url,
byte[] ownerPassword)
throws IOException
url - the URL of the documentownerPassword - the password to read the document
IOException - on error
public PdfReader(InputStream is,
byte[] ownerPassword)
throws IOException
is - the InputStream containing the document. The stream is read to the
end but is not closedownerPassword - the password to read the document
IOException - on error
public PdfReader(InputStream is)
throws IOException
is - the InputStream containing the document. The stream is read to the
end but is not closed
IOException - on error
public PdfReader(RandomAccessFileOrArray raf,
byte[] ownerPassword)
throws IOException
PdfReader.close(), reopen is automatic.
raf - the document locationownerPassword - the password or null for no password
IOException - on errorpublic PdfReader(PdfReader reader)
reader - the PdfReader to duplicate| Method Detail |
|---|
public RandomAccessFileOrArray getSafeFile()
protected PdfReaderInstance getPdfReaderInstance(PdfWriter writer)
public int getNumberOfPages()
public PdfDictionary getCatalog()
public PRAcroForm getAcroForm()
public int getPageRotation(int index)
index - the page number. The first page is 1
int getPageRotation(PdfDictionary page)
public Rectangle getPageSizeWithRotation(int index)
Rectangle with the value of the /MediaBox and the /Rotate key.
index - the page number. The first page is 1
Rectanglepublic Rectangle getPageSizeWithRotation(PdfDictionary page)
page - the page dictionary
public Rectangle getPageSize(int index)
index - the page number. The first page is 1
public Rectangle getPageSize(PdfDictionary page)
page - the page dictionary
public Rectangle getCropBox(int index)
index - the page number. The first page is 1
public Rectangle getBoxSize(int index,
String boxName)
index - the page number. The first page is 1boxName - the box name
public HashMap getInfo()
HashMap
of String.
public static Rectangle getNormalizedRectangle(PdfArray box)
Rectangle so that llx and lly are smaller than urx and ury.
box - the original rectangle
Rectangle
protected void readPdf()
throws IOException
IOException
protected void readPdfPartial()
throws IOException
IOException
private boolean equalsArray(byte[] ar1,
byte[] ar2,
int size)
private void readDecryptedDocObj()
throws IOException
IOExceptionpublic static PdfObject getPdfObjectRelease(PdfObject obj)
obj -
public static PdfObject getPdfObject(PdfObject obj)
PdfObject resolving an indirect reference
if needed.
obj - the PdfObject to read
PdfObject
public static PdfObject getPdfObjectRelease(PdfObject obj,
PdfObject parent)
PdfObject resolving an indirect reference
if needed. If the reader was opened in partial mode the object will be released
to save memory.
obj - the PdfObject to readparent -
public static PdfObject getPdfObject(PdfObject obj,
PdfObject parent)
obj - parent -
public PdfObject getPdfObjectRelease(int idx)
idx -
public PdfObject getPdfObject(int idx)
idx -
public void resetLastXrefPartial()
public void releaseLastXrefPartial()
public static void releaseLastXrefPartial(PdfObject obj)
obj -
private void setXrefPartialObject(int idx,
PdfObject obj)
public PRIndirectReference addPdfObject(PdfObject obj)
obj -
protected void readPages()
throws IOException
IOException
protected void readDocObjPartial()
throws IOException
IOException
protected PdfObject readSingleObject(int k)
throws IOException
IOException
protected PdfObject readOneObjStm(PRStream stream,
int idx)
throws IOException
IOExceptionpublic double dumpPerc()
protected void readDocObj()
throws IOException
IOException
private void checkPRStreamLength(PRStream stream)
throws IOException
IOException
protected void readObjStm(PRStream stream,
IntHashtable map)
throws IOException
IOExceptionpublic static PdfObject killIndirect(PdfObject obj)
obj - the object. If it's an indirect reference it will be eliminated