Class PDFTextStream

    • Constructor Detail

      • PDFTextStream

        public PDFTextStream​(InputStream is,
                             String pdfName)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(File pdfFile)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(String pdfFilePath)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(InputStream is,
                             String pdfName,
                             byte[] userPasswd,
                             Configuration config)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(InputStream is,
                             String pdfName,
                             byte[] userPasswd)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(File pdfFile,
                             byte[] userPasswd,
                             Configuration config)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(String pdfFilePath,
                             byte[] userPasswd,
                             Configuration config)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(File pdfFile,
                             byte[] userPasswd)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(String pdfFilePath,
                             byte[] userPasswd)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(ByteBuffer pdfData,
                             String pdfName,
                             byte[] userPasswd,
                             Configuration config)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(ByteBuffer pdfData,
                             String pdfName,
                             byte[] userPasswd)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
      • PDFTextStream

        public PDFTextStream​(ByteBuffer pdfData,
                             String pdfName)
                      throws IOException
        Deprecated.
        Equivalent to the corresponding "open" static method in PDF, provided to ensure backwards compatibility with codebases using the PDFTextStream v2.x API.
        Throws:
        IOException
    • Method Detail

      • loadLicense

        public static boolean loadLicense​(String path)
        Deprecated.
        Retained to maintain PDFTextStream v2.x API compatibility. Use (String) instead.
      • loadLicense

        public static boolean loadLicense​(URL licenseLocation)
        Deprecated.
        Retained to maintain PDFTextStream v2.x API compatibility. Use PDF.loadLicense(java.net.URL) instead.
      • isLicensed

        public static boolean isLicensed()
        Deprecated.
        Retained to maintain PDFTextStream v2.x API compatibility. Use () instead.
      • pipe

        public void pipe​(OutputHandler handler,
                         Direction bd)
                  throws IOException
        Deprecated.
        Description copied from interface: OutputSource

        Extracts all available text from this OutputSource, sending all PDF text events to the given OutputHandler, with the specified Direction.

        If no special PDF text event handling is needed (i.e. you just want a straight text extract), then using an OutputTarget is recommended.

        Specified by:
        pipe in interface OutputSource
        Parameters:
        handler - an OutputHandler instance.
        bd - the Direction that should be used to disambiguate the order in which extracted text is emitted
        Throws:
        IOException - if an error occurs during the extraction process
        See Also:
        OutputHandler, OutputTarget
      • getPdfFileSize

        public long getPdfFileSize()
        Deprecated.
        Description copied from interface: Document
        Returns the size of the PDF file being read, in bytes.
        Specified by:
        getPdfFileSize in interface Document
      • getPageCnt

        public int getPageCnt()
        Deprecated.
        Description copied from interface: Document
        Returns the number of pages in the PDF document.
        Specified by:
        getPageCnt in interface Document
      • getPage

        public Page getPage​(int n)
                     throws IOException
        Deprecated.
        Description copied from interface: Document
        Reads and returns a single page. Page numbers are zero-indexed; they do not necessarily correspond with any reader-visible page number.
        Specified by:
        getPage in interface Document
        Parameters:
        n - the number of the page to retrieve.
        Throws:
        IOException - if an error occurs while preparing the Page for use
      • getName

        public String getName()
        Deprecated.
        Description copied from interface: Document
        Returns the name of the PDF that this Document is reading; this will be either the name of the PDF file that is being read, or the pdfName String that was provided if this Document was opened using one of the com.snowtide.PDF.open() methods that accepts an InputStream or ByteBuffer, e.g. PDF.open(java.io.InputStream, String)

        Nearly all of the logging messages generated by PDFxStream include the relevant Document's name, making them easier to interpret in a multithreaded production environment.

        Specified by:
        getName in interface Document
      • getPDFFile

        public File getPDFFile()
        Deprecated.
        Description copied from interface: Document
        Returns a reference to the file that this Document is processing. This reference may be null if the Document instance is not reading from a File or InputStream.
        Specified by:
        getPDFFile in interface Document
      • getFormData

        public Form getFormData()
                         throws IOException
        Deprecated.
        Description copied from interface: Document
        Loads the form data contained in the current document, and returns a Form object that represents that data. If the current PDF contains no forms, this function returns null. The Form instance that is returned by this function is guaranteed to be an AcroForm.

        This function MUST NOT be called after this Document is closed.

        Specified by:
        getFormData in interface Document
        Throws:
        IOException - if an error occurs loading the form data
      • getBookmarks

        public Bookmark getBookmarks()
                              throws IOException
        Deprecated.
        Description copied from interface: Document
        If the current PDF document contains a bookmark tree, this function will return its root node. If the document contains no bookmarks, this function will return null.

        An exception will be thrown if this function is called after this Document instance is closed.

        Specified by:
        getBookmarks in interface Document
        Throws:
        IOException - if an error occurs reading the bookmark tree
        See Also:
        Bookmark
      • getAnnotations

        public List<Annotation> getAnnotations​(int page)
                                        throws IOException
        Deprecated.
        Description copied from interface: Document
        Returns a List of all annotations found on the page indicated by the given page number; each object will be an instance of a class that implements the Annotation interface.

        This function will never return null; if a page contains no annotations, an empty list will be returned. The returned list is guaranteed to offer efficient random access to its elements.

        Specified by:
        getAnnotations in interface Document
        Throws:
        IOException - if an error occurs retrieving the annotation data
        See Also:
        Annotation
      • getAllAnnotations

        public List<Annotation> getAllAnnotations()
                                           throws IOException
        Deprecated.
        Description copied from interface: Document
        Returns a list containing all of the Annotations contained in the current PDF document. The returned list is guaranteed to offer efficient random access to its elements.
        Specified by:
        getAllAnnotations in interface Document
        Throws:
        IOException - if an error occurs retrieving the annotation data
      • getAllAnnotations

        public int getAllAnnotations​(List tgt)
                              throws IOException
        Deprecated.
        Description copied from interface: Document
        Adds to the given List all of the Annotations contained in the current PDF document.
        Specified by:
        getAllAnnotations in interface Document
        Returns:
        the number of annotations added to the list
        Throws:
        IOException - if an error occurs retrieving the annotation data
        See Also:
        Annotation
      • getPDFVersion

        public PDFVersion getPDFVersion()
                                 throws IOException
        Deprecated.
        Description copied from interface: Document

        Returns the PDFVersion instance that corresponds with the version of the PDF file specification to which current PDF file adheres. PDF specification version numbers correspond directly with particular versions of Adobe Acrobat:

        • v1.0 - Acrobat 1
        • v1.1 - Acrobat 2
        • v1.2 - Acrobat 3
        • v1.3 - Acrobat 4
        • v1.4 - Acrobat 5
        • v1.5 - Acrobat 6
        • v1.6 - Acrobat 7
        • v1.7 - Acrobat 8+

        This method may not be called after the Document is closed.

        Specified by:
        getPDFVersion in interface Document
        Throws:
        IOException - if an error occurs in determining what the PDF file's version is
      • getEncryptionInfo

        public EncryptionInfo getEncryptionInfo()
        Deprecated.
        Description copied from interface: Document
        Returns an EncryptionInfo object, which provides access to some of the parameters used for the current PDF document's encryption.

        If the current PDF document is not encrypted, this method will return null.

        Specified by:
        getEncryptionInfo in interface Document
      • getXmlMetadata

        public byte[] getXmlMetadata()
                              throws IOException
        Deprecated.
        Description copied from interface: Document

        Returns the XML metadata available from this Document, or null if no XML metadata is available.

        Note: This method must be called before the Document is closed, and it should not be called while text is being actively read out of it. (Supporting such concurrency would require synchronization that would negatively impact performance.) Therefore, the best times to call this method are:

        • just after opening the Document but before reading text out of it
        • after all text has been read out of the Document, but before it is closed

        PDFxStream does not control the content returned by this method -- it just provides access to the data that is already stored in a PDF document. The schema of the the returned XML data is defined by Adobe, and is called the Extensible Metadata Platform (XMP). More information about XMP can be found on Adobe's website

        Specified by:
        getXmlMetadata in interface Document
        Throws:
        IOException - if this Document has already been closed, or if an error occurs retrieving the XML metadata.
      • getAttribute

        public Object getAttribute​(String attrName)
                            throws IOException
        Deprecated.
        Description copied from interface: Document
        Returns the value of the specified document-level metadata attribute.

        All of the standard attribute names are defined in constants in this class, and are all prefixed with 'ATTR_'. A few notes should be kept in mind when accessing attribute values:

        • It is typical for only a subset of the possible attributes to be defined in a PDF document. Any attributes that are undefined will return a null value when their name is provided to this method.
        • Many more attributes are used in the real world than are formally specified by the PDF specification. It is entirely up to the PDF generator what attributes are to be outputted for a particular document, so some documents may contain attributes whose names are not canonicalized in the 'ATTR_' constants in this class. You can use the getAttributeKeys() method to get a Set of the names of all available attributes.
        • Most attribute values are Strings, but it is possible for attribute values to be Integers, Booleans, etc. The documentation associated with each attribute name constant in this class specifies what type may be expected when retrieving each particular attribute value. Any attributes specified as dates are returned from this method as String instances; these can be passed through parseDateString(String) to get a Date object.

        Note: the attributes available through this method are retrieved from the "classic" document /Info entry. The document metadata in an XML format (which typically contains the same set of metadata attributes that are available through this method) may be obtained via the getXmlMetadata() method.

        Specified by:
        getAttribute in interface Document
        Parameters:
        attrName - the name of the attribute to be retrieved
        Returns:
        the value of the attribute with the given name defined in the PDF document being read, or null if no attribute is available with the given name. The type of this object depends upon which attribute is being retrieved, and is noted in the documentation of the attribute name constants held by this class.
        Throws:
        IOException - if an error occurs while retrieving the PDF document's metadata
        See Also:
        getXmlMetadata() for access to the XML-formatted document metadata
      • getAttributeKeys

        public Set<String> getAttributeKeys()
                                     throws IOException
        Deprecated.
        Description copied from interface: Document
        Returns a Set containing the keys of all available document metadata attributes.
        Specified by:
        getAttributeKeys in interface Document
        Throws:
        IOException - if an error occurs while retrieving the PDF document's metadata
      • getAttributeMap

        public Map<String,​Object> getAttributeMap()
                                                 throws IOException
        Deprecated.
        Description copied from interface: Document
        Returns a Map containing a copy of all keys and values of all available document metadata attributes.
        Specified by:
        getAttributeMap in interface Document
        Throws:
        IOException - if an error occurs while retrieving the PDF document's metadata
      • getPages

        public List<Page> getPages()
        Deprecated.
        Description copied from interface: Document
        Returns a list of pages from this Document, which are loaded lazily when accessed via the returned list.
        Specified by:
        getPages in interface Document