Save This Page
Home » iText-src-2.1.3 » com.lowagie » text » pdf » [javadoc | source]
com.lowagie.text.pdf
public class: PdfReader [javadoc | source]
java.lang.Object
   com.lowagie.text.pdf.PdfReader

All Implemented Interfaces:
    PdfViewerPreferences

Direct Known Subclasses:
    FdfReader

Reads a PDF document.
Nested Class Summary:
static class  PdfReader.PageRefs   
Field Summary
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     
 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     
protected  ArrayList strings     
protected  boolean sharedStreams     
protected  boolean consolidateNamedDestinations     
protected  int rValue     
protected  int pValue     
Constructor:
 protected PdfReader() 
 public PdfReader(String filename) throws IOException 
    Reads and parses a PDF document.
    Parameters:
    filename - the file name of the document
    Throws:
    IOException - on error
 public PdfReader(byte[] pdfIn) throws IOException 
    Reads and parses a PDF document.
    Parameters:
    pdfIn - the byte array with the document
    Throws:
    IOException - on error
 public PdfReader(URL url) throws IOException 
    Reads and parses a PDF document.
    Parameters:
    url - the URL of the document
    Throws:
    IOException - on error
 public PdfReader(InputStream is) throws IOException 
    Reads and parses a PDF document.
    Parameters:
    is - the InputStream containing the document. The stream is read to the end but is not closed
    Throws:
    IOException - on error
 public PdfReader(PdfReader reader) 
    Creates an independent duplicate.
    Parameters:
    reader - the PdfReader to duplicate
 public PdfReader(String filename,
    byte[] ownerPassword) throws IOException 
    Reads and parses a PDF document.
    Parameters:
    filename - the file name of the document
    ownerPassword - the password to read the document
    Throws:
    IOException - on error
 public PdfReader(byte[] pdfIn,
    byte[] ownerPassword) throws IOException 
    Reads and parses a PDF document.
    Parameters:
    pdfIn - the byte array with the document
    ownerPassword - the password to read the document
    Throws:
    IOException - on error
 public PdfReader(URL url,
    byte[] ownerPassword) throws IOException 
    Reads and parses a PDF document.
    Parameters:
    url - the URL of the document
    ownerPassword - the password to read the document
    Throws:
    IOException - on error
 public PdfReader(InputStream is,
    byte[] ownerPassword) throws IOException 
    Reads and parses a PDF document.
    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
 public PdfReader(RandomAccessFileOrArray raf,
    byte[] ownerPassword) throws IOException 
    Reads and parses a pdf document. Contrary to the other constructors only the xref is read into memory. The reader is said to be working in "partial" mode as only parts of the pdf are read as needed. The pdf is left open but may be closed at any time with PdfReader.close(), reopen is automatic.
    Parameters:
    raf - the document location
    ownerPassword - the password or null for no password
    Throws:
    IOException - on error
 public PdfReader(String filename,
    Certificate certificate,
    Key certificateKey,
    String certificateKeyProvider) throws IOException 
    Reads and parses a PDF document.
    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
Method from com.lowagie.text.pdf.PdfReader Summary:
ASCII85Decode,   ASCIIHexDecode,   FlateDecode,   FlateDecode,   LZWDecode,   addPdfObject,   addViewerPreference,   close,   computeUserPassword,   consolidateNamedDestinations,   createFakeFontSubsets,   decodePredictor,   dumpPerc,   duplicatePdfDictionary,   duplicatePdfObject,   eliminateSharedStreams,   equalsn,   existsName,   getAcroFields,   getAcroForm,   getBoxSize,   getCatalog,   getCertificationLevel,   getCropBox,   getCryptoMode,   getCryptoRef,   getDecrypt,   getEofPos,   getFileLength,   getFontName,   getInfo,   getJavaScript,   getJavaScript,   getLastXref,   getLinks,   getMetadata,   getNamedDestination,   getNamedDestinationFromNames,   getNamedDestinationFromStrings,   getNormalizedRectangle,   getNumberOfPages,   getPageContent,   getPageContent,   getPageN,   getPageNRelease,   getPageOrigRef,   getPageRotation,   getPageRotation,   getPageSize,   getPageSize,   getPageSizeWithRotation,   getPageSizeWithRotation,   getPdfObject,   getPdfObject,   getPdfObject,   getPdfObjectRelease,   getPdfObjectRelease,   getPdfObjectRelease,   getPdfReaderInstance,   getPdfVersion,   getPermissions,   getSafeFile,   getSimpleViewerPreferences,   getStreamBytes,   getStreamBytes,   getStreamBytesRaw,   getStreamBytesRaw,   getSubsetPrefix,   getTrailer,   getXrefSize,   is128Key,   isAppendable,   isEncrypted,   isHybridXref,   isMetadataEncrypted,   isNewXrefType,   isOpenedWithFullPermissions,   isRebuilt,   isTampered,   killIndirect,   killXref,   readArray,   readDictionary,   readDocObj,   readDocObjPartial,   readObjStm,   readOneObjStm,   readPRObject,   readPages,   readPdf,   readPdfPartial,   readSingleObject,   readXRefStream,   readXref,   readXrefSection,   rebuildXref,   releaseLastXrefPartial,   releaseLastXrefPartial,   releasePage,   removeAnnotations,   removeFields,   removeUnusedNode,   removeUnusedObjects,   removeUsageRights,   resetLastXrefPartial,   resetReleasePage,   selectPages,   selectPages,   setAppendable,   setPageContent,   setPageContent,   setTampered,   setViewerPreferences,   setViewerPreferences,   shuffleSubsetNames
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.lowagie.text.pdf.PdfReader Detail:
 public static byte[] ASCII85Decode(byte[] in) 
    Decodes a stream that has the ASCII85Decode filter.
 public static byte[] ASCIIHexDecode(byte[] in) 
    Decodes a stream that has the ASCIIHexDecode filter.
 public static byte[] FlateDecode(byte[] in) 
    Decodes a stream that has the FlateDecode filter.
 public static byte[] FlateDecode(byte[] in,
    boolean strict) 
    A helper to FlateDecode.
 public static byte[] LZWDecode(byte[] in) 
    Decodes a stream that has the LZWDecode filter.
 public PRIndirectReference addPdfObject(PdfObject obj) 
 public  void addViewerPreference(PdfName key,
    PdfObject value) 
    Adds a viewer preference
 public  void close() 
    Closes the reader
 public byte[] computeUserPassword() 
 public  void consolidateNamedDestinations() 
    Replaces all the local named links with the actual destinations.
 public int createFakeFontSubsets() 
    Finds all the fonts not subset but embedded and marks them as subset.
 public static byte[] decodePredictor(byte[] in,
    PdfObject dicPar) 
 public double dumpPerc() 
 protected static PdfDictionary duplicatePdfDictionary(PdfDictionary original,
    PdfDictionary copy,
    PdfReader newReader) 
 protected static PdfObject duplicatePdfObject(PdfObject original,
    PdfReader newReader) 
 public  void eliminateSharedStreams() 
    Eliminates shared streams if they exist.
 static boolean equalsn(byte[] a1,
    byte[] a2) 
 static boolean existsName(PdfDictionary dic,
    PdfName key,
    PdfName value) 
 public AcroFields getAcroFields() 
    Gets a read-only version of AcroFields.
 public PRAcroForm getAcroForm() 
    Returns the document's acroform, if it has one.
 public Rectangle getBoxSize(int index,
    String boxName) 
    Gets the box size. Allowed names are: "crop", "trim", "art", "bleed" and "media".
 public PdfDictionary getCatalog() 
    Returns the document's catalog. This dictionary is not a copy, any changes will be reflected in the catalog.
 public int getCertificationLevel() 
    Gets the certification level for this document. The return values can be 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 available for that in AcroFields.

 public Rectangle getCropBox(int index) 
    Gets the crop box without taking rotation into account. This is the value of the /CropBox key. The crop box is the part of the document to be displayed or printed. It usually is the same as the media box but may be smaller. If the page doesn't have a crop box the page size will be returned.
 public int getCryptoMode() 
 PdfIndirectReference getCryptoRef() 
 PdfEncryption getDecrypt() 
 public int getEofPos() 
    Gets the byte address of the %%EOF marker.
 public int getFileLength() 
    Getter for property fileLength.
 static String getFontName(PdfDictionary dic) 
 public HashMap getInfo() 
    Returns the content of the document information dictionary as a HashMap of String.
 public String getJavaScript() throws IOException 
    Gets the global document JavaScript.
 public String getJavaScript(RandomAccessFileOrArray file) throws IOException 
    Gets the global document JavaScript.
 public int getLastXref() 
    Gets the byte address of the last xref table.
 public ArrayList getLinks(int page) 
 public byte[] getMetadata() throws IOException 
    Gets the XML metadata.
 public HashMap getNamedDestination() 
    Gets all the named destinations as an HashMap. The key is the name and the value is the destinations array.
 public HashMap getNamedDestinationFromNames() 
    Gets the named destinations from the /Dests key in the catalog as an HashMap. The key is the name and the value is the destinations array.
 public HashMap getNamedDestinationFromStrings() 
    Gets the named destinations from the /Names key in the catalog as an HashMap. The key is the name and the value is the destinations array.
 public static Rectangle getNormalizedRectangle(PdfArray box) 
    Normalizes a Rectangle so that llx and lly are smaller than urx and ury.
 public int getNumberOfPages() 
    Gets the number of pages in the document.
 public byte[] getPageContent(int pageNum) throws IOException 
    Gets the contents of the page.
 public byte[] getPageContent(int pageNum,
    RandomAccessFileOrArray file) throws IOException 
    Gets the contents of the page.
 public PdfDictionary getPageN(int pageNum) 
    Gets the dictionary that represents a page.
 public PdfDictionary getPageNRelease(int pageNum) 
 public PRIndirectReference getPageOrigRef(int pageNum) 
    Gets the page reference to this page.
 public int getPageRotation(int index) 
    Gets the page rotation. This value can be 0, 90, 180 or 270.
 int getPageRotation(PdfDictionary page) 
 public Rectangle getPageSize(int index) 
    Gets the page size without taking rotation into account. This is the value of the /MediaBox key.
 public Rectangle getPageSize(PdfDictionary page) 
    Gets the page from a page dictionary
 public Rectangle getPageSizeWithRotation(int index) 
    Gets the page size, taking rotation into account. This is a Rectangle with the value of the /MediaBox and the /Rotate key.
 public Rectangle getPageSizeWithRotation(PdfDictionary page) 
    Gets the rotated page from a page dictionary.
 public static PdfObject getPdfObject(PdfObject obj) 
    Reads a PdfObject resolving an indirect reference if needed.
 public PdfObject getPdfObject(int idx) 
 public static PdfObject getPdfObject(PdfObject obj,
    PdfObject parent) 
 public static PdfObject getPdfObjectRelease(PdfObject obj) 
 public PdfObject getPdfObjectRelease(int idx) 
 public static PdfObject getPdfObjectRelease(PdfObject obj,
    PdfObject parent) 
    Reads a PdfObject resolving an indirect reference if needed. If the reader was opened in partial mode the object will be released to save memory.
 protected PdfReaderInstance getPdfReaderInstance(PdfWriter writer) 
 public char getPdfVersion() 
    Gets the PDF version. Only the last version char is returned. For example version 1.4 is returned as '4'.
 public int getPermissions() 
    Gets the encryption permissions. It can be used directly in PdfWriter.setEncryption().
 public RandomAccessFileOrArray getSafeFile() 
    Gets a new file instance of the original PDF document.
 public int getSimpleViewerPreferences() 
 public static byte[] getStreamBytes(PRStream stream) throws IOException 
    Get the content from a stream applying the required filters.
 public static byte[] getStreamBytes(PRStream stream,
    RandomAccessFileOrArray file) throws IOException 
    Get the content from a stream applying the required filters.
 public static byte[] getStreamBytesRaw(PRStream stream) throws IOException 
    Get the content from a stream as it is without applying any filter.
 public static byte[] getStreamBytesRaw(PRStream stream,
    RandomAccessFileOrArray file) throws IOException 
    Get the content from a stream as it is without applying any filter.
 static String getSubsetPrefix(PdfDictionary dic) 
 public PdfDictionary getTrailer() 
    Gets the trailer dictionary
 public int getXrefSize() 
    Gets the number of xref objects.
 public boolean is128Key() 
    Returns true if the PDF has a 128 bit key encryption.
 public boolean isAppendable() 
    Getter for property appendable.
 public boolean isEncrypted() 
    Returns true if the PDF is encrypted.
 public boolean isHybridXref() 
    Getter for property hybridXref.
 public boolean isMetadataEncrypted() 
 public boolean isNewXrefType() 
    Getter for property newXrefType.
 public final 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. If the document is not encrypted it will return true.
 public boolean isRebuilt() 
    Checks if the document had errors and was rebuilt.
 public boolean isTampered() 
    Checks if the document was changed.
 public 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) 
 protected PdfArray readArray() throws IOException 
 protected PdfDictionary readDictionary() throws IOException 
 protected  void readDocObj() throws IOException 
 protected  void readDocObjPartial() throws IOException 
 protected  void readObjStm(PRStream stream,
    IntHashtable map) throws IOException 
 protected PdfObject readOneObjStm(PRStream stream,
    int idx) throws IOException 
 protected PdfObject readPRObject() throws IOException 
 protected  void readPages() throws IOException 
 protected  void readPdf() throws IOException 
 protected  void readPdfPartial() throws IOException 
 protected PdfObject readSingleObject(int k) throws IOException 
 protected boolean readXRefStream(int ptr) throws IOException 
 protected  void readXref() throws IOException 
 protected PdfDictionary readXrefSection() throws IOException 
 protected  void rebuildXref() throws IOException 
 public  void releaseLastXrefPartial() 
 public static  void releaseLastXrefPartial(PdfObject obj) 
 public  void releasePage(int pageNum) 
 public  void removeAnnotations() 
    Removes all the annotations and fields from the document.
 public  void removeFields() 
    Removes all the fields from the document.
 protected  void removeUnusedNode(PdfObject obj,
    boolean[] hits) 
 public int removeUnusedObjects() 
    Removes all the unreachable objects.
 public  void removeUsageRights() 
    Removes any usage rights that this PDF may have. Only Adobe can grant usage rights and any PDF modification with iText will invalidate them. Invalidated usage rights may confuse Acrobat and it's advisable to remove them altogether.
 public  void resetLastXrefPartial() 
 public  void resetReleasePage() 
 public  void selectPages(String ranges) 
    Selects the pages to keep in the document. The pages are described as ranges. The page ordering can be changed but no page repetitions are allowed. Note that it may be very slow in partial mode.
 public  void selectPages(List pagesToKeep) 
    Selects the pages to keep in the document. The pages are described as a 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.
 public  void setAppendable(boolean appendable) 
    Setter for property appendable.
 public  void setPageContent(int pageNum,
    byte[] content) 
    Sets the contents of the page.
 public  void setPageContent(int pageNum,
    byte[] content,
    int compressionLevel) 
    Sets the contents of the page.
 public  void setTampered(boolean tampered) 
    Sets the tampered state. A tampered PdfReader cannot be reused in PdfStamper.
 public  void setViewerPreferences(int preferences) 
    Sets the viewer preferences as the sum of several constants.
  void setViewerPreferences(PdfViewerPreferencesImp vp) 
 public int shuffleSubsetNames() 
    Finds all the font subsets and changes the prefixes to some random values.