Class Document

java.lang.Object
com.datalogics.PDFL.Document

public class Document extends Object
The underlying PDF representation of a document. Use document objects to perform most of the functions related to pages in a PDF file, such as deleting pages, inserting blank pages, copying watermarks, creating bookmarks and thumbnails, and so on.

  • Field Details

  • Constructor Details

    • Document

      public Document(ImageInputStream stream) throws IOException
      Open a Document from a javax.imageio.stream.ImageInputStream. This allows a document to be read from a ImageInputStream object. ImageInputStream can be created from InputStream using MemoryCacheImageInputStream or FileCacheImageInputStream. Once passed to the Document constructor, ownership of the stream is passed to the Document. The Stream must remain open while the Document itself is open.
      Parameters:
      stream - The stream from which to read the Document.
      Throws:
      IOException
    • Document

      public Document(ImageInputStream stream, String password, PermissionRequestOperation perms, boolean doRepair) throws IOException
      Open a Document from a javax.imageio.stream.ImageInputStream. This allows a document to be read from a ImageInputStream object. ImageInputStream can be created from InputStream using MemoryCacheImageInputStream or FileCacheImageInputStream. Once passed to the Document constructor, ownership of the stream is passed to the Document. The Stream must remain open while the Document itself is open.
      Parameters:
      stream - The stream from which to read the Document.
      password - The password to use to attempt to open the document.
      perms - The permissions being requested. It must be an OR of the PermissionRequestOperation values.
      doRepair - If true, attempt to repair the file if it is damaged. If false, do not attempt to repair the file if it is damaged.
      Throws:
      IOException
    • Document

      public Document()
      Creates a new document. The only Cos object in the document will be a Catalog. After the document is created, at least one page must be added using CreatePage or InsertPages before the PDF Viewer can display or save the document.

    • Document

      public Document(String fileName)
      Opens the specified document. If the call fails and the exception is pdErrNeedRebuild, then call again with doRepair set to true. This allows the application to decide whether to perform the time-consuming repair operation.

      Parameters:
      fileName - A path name to the file, specified in whatever format is correct for fileSys.
    • Document

      public Document(String fileName, String password, PermissionRequestOperation perms, boolean doRepair)
      Opens the specified document. If the document is already open, it returns a reference to the already opened Document. You must call Close() once for every successful open. If the call fails and the exception is pdErrNeedRebuild, then call again with doRepair equal to true. This allows the application to decide whether to perform the time-consuming repair operation.

      Parameters:
      fileName - A path name to the file.
      password - The password to use to attempt to open the document.
      perms - The permissions being requested. It must be an OR of the PermissionRequestOperation values.
      doRepair - If true, attempt to repair the file if it is damaged. If false, do not attempt to repair the file if it is damaged.
    • Document

      public Document(String XPSFilename, XPSConvertParams ConversionParams)
      Create a Document from an XPS file.

      Documents are converted one at a time. In multi-threaded applications, threads that are making simultaneous calls to this method will block and execute the method sequentially.

      NOTE: This method is only available on Windows or Linux.

      Parameters:
      XPSFilename - The path to the XPS file to convert.
      ConversionParams - Additional parameters for XPS conversion.
    • Document

      public Document(com.datalogics.PDFL.JavaStreamFile file)
    • Document

      public Document(com.datalogics.PDFL.JavaStreamFile file, String password, PermissionRequestOperation perms, boolean doRepair)
  • Method Details

    • delete

      public void delete()
      Closes that document and releases its resources. Changes are not saved. You must use Save() to save any modifications before destroying this object.

    • save

      public void save(EnumSet<SaveFlags> saveFlags, ImageOutputStream stream) throws IOException
      Saves a Document to a javax.imageio.stream.ImageOutputStream. The save is always performed as a full, copy save. The Document remains open with the original file. If the document was created with Document(), at least one page must be added using createPage() or insertPages() before the Document can be saved. A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new Cos object number.
      Parameters:
      saveFlags - An enum of SaveFlags values.
      stream - The stream to which the file is saved.
      Throws:
      IOException
    • save

      public void save(EnumSet<SaveFlags> saveFlags, ImageOutputStream stream, ProgressMonitor progressMonitor, CancelProc cancelProc) throws IOException
      Throws:
      IOException
    • cloneAsPDFADocument

      public PDFAConvertResult cloneAsPDFADocument(PDFAConvertType type, PDFAConvertParams parms)
      Create a PDF/A compliant version of this Document. The returned Document will be compliant with the PDF/A standard. You can save it using any of the standard Save() methods. The PDFAConvertResult object contains both the Document and the SaveFlags you should use when saving the Document. You MUST use these exact flags to save the returned Document or it will no longer be PDF/A compliant. The returned Document will have its MajorVersion and MinorVersion set to values required for PDF/A compliance. These will not be visible until after you save the Document. If this Document could not be converted to PDF/A, the PDFADocument field in the PDFAConvertResult object will be null or a LibraryException will be thrown. A LibraryException message should be checked to see if setting a PDFAConvertParams property will allow conversion to succeed. For example, if the message is "Unembeddable font in annotation", then try calling the setRemoveAllAnnotations() method with a value of true and then call cloneAsPDFADocument().
      Parameters:
      type - The type of PDF/A conversion to perform
      parms - A PDFAConvertParams object specifying options for the conversion
      Returns:
      A PDFAConvertResult object containing the Document and SaveFlags.
    • cloneAsPDFXDocument

      public PDFXConvertResult cloneAsPDFXDocument(PDFXConvertType type, PDFXConvertParams parms)
      Create a PDF/X compliant version of this Document. The returned Document will be compliant with the PDF/A standard. You can save it using any of the standard Save() methods. The PDFXConvertResult object contains both the Document and the SaveFlags you should use when saving the Document. You MUST use these exact flags to save the returned Document or it will no longer be PDF/X compliant. The returned Document will have its MajorVersion and MinorVersion set to values required for PDF/X compliance. These will not be visible until after you save the Document. If this Document could not be converted to PDF/X the PDFXDocument field in the PDFXConvertResult object will be null.
      Parameters:
      type - The type of PDF/X conversion to perform
      parms - A PDFXConvertParams object specifying options for the conversion
      Returns:
      A PDFXConvertResult object containing the Document and SaveFlags.
    • getFileName

      public String getFileName()
      Get the filename associated with this Document, if it has a representation on disk.

      Returns:
      The filename associated with this Document.
    • save

      public void save(EnumSet<SaveFlags> saveFlags, String newPath)
      Saves a document to disk. If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to newPath.

      If the document was created with Document, at least one page must be added using CreatePage() or InsertPages() before a PDF Viewer can save the document.

      A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new PDFObject number. At the end of the save operation, PDFL flushes its information of the PD layer and below to synchronize its in-memory state with the new disk file just written.

      If the document has a signature, it will be saved incrementally regardless of the full save flag. This is required to preserve the exact contents of the document at the time of signing.

      Parameters:
      saveFlags - A bit field composed of an OR of the SaveFlags values.
      newPath - The path to which the file is saved. A path must be specified when either SaveFlags.Full or SaveFlags.Copy are used for saveFlags. If SaveFlags.Incremental is specified in saveFlags, then newPath should be NULL. If SaveFlags.Full is specified and newPath is the same as the file's original path, the new file is saved to a file system-determined temporary path, then the old file is deleted and the new file is renamed to newPath.
    • save

      public void save(EnumSet<SaveFlags> saveFlags, String newPath, ProgressMonitor progressMonitor, CancelProc cancelProc)
      Saves a document to disk. If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to newPath.

      If the document was created with Document, at least one page must be added using CreatePage() or InsertPages() before a PDF Viewer can save the document.

      A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new PDFObject number. At the end of the save operation, PDFL flushes its information of the PD layer and below to synchronize its in-memory state with the new disk file just written.

      If the document has a signature, it will be saved incrementally regardless of the full save flag. This is required to preserve the exact contents of the document at the time of signing.

      Parameters:
      saveFlags - A bit field composed of an OR of the SaveFlags values.
      newPath - The path to which the file is saved. A path must be specified when either SaveFlags.Full or SaveFlags.Copy are used for saveFlags. If SaveFlags.Incremental is specified in saveFlags, then newPath should be NULL. If SaveFlags.Full is specified and newPath is the same as the file's original path, the new file is saved to a file system-determined temporary path, then the old file is deleted and the new file is renamed to newPath.
      progressMonitor - a ProgressMonitor that will receive progress information, may be null
      cancelProc - a CancelProc, which can return true to cancel the operation, may be null
    • save

      public void save(EnumSet<SaveFlags> saveFlags)
      Saves a document to disk. If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to the save file name.

      A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new PDFObject number. At the end of the save operation, PDFL flushes its information of the PD layer and below to synchronize its in-memory state with the new disk file just written.

      If the document has a signature, it will be saved incrementally regardless of the full save flag. This is required to preserve the exact contents of the document at the time of signing.

      Parameters:
      saveFlags - A bit field composed of an OR of the SaveFlags values.
    • save

      public void save(EnumSet<SaveFlags> saveFlags, ProgressMonitor progressMonitor, CancelProc cancelProc)
      Saves a document to disk. If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to the save file name.

      A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new PDFObject number. At the end of the save operation, PDFL flushes its information of the PD layer and below to synchronize its in-memory state with the new disk file just written.

      If the document has a signature, it will be saved incrementally regardless of the full save flag. This is required to preserve the exact contents of the document at the time of signing.

      Parameters:
      saveFlags - A bit field composed of an OR of the SaveFlags values.
      progressMonitor - a ProgressMonitor that will receive progress information, may be null
      cancelProc - a CancelProc, which can return true to cancel the operation, may be null
    • save

      public void save(EnumSet<SaveFlags> saveFlags, com.datalogics.PDFL.JavaStreamFile dest, ProgressMonitor progressMonitor, CancelProc cancelProc)
    • save

      public void save(EnumSet<SaveFlags> saveFlags, com.datalogics.PDFL.JavaStreamFile dest)
    • getPermissionFlags

      public EnumSet<PermissionFlags> getPermissionFlags()
      Allows to obtain security flags for the document.
      Returns:
      flags that have been set
    • secure

      public void secure(EnumSet<PermissionFlags> permissions, String ownerPassword, String userPassword)
      Secure the PDF document securely with password(s). If the document has a security handler, it is retained. If the document does not have a security handler, it is assigned the "Standard" security handler with a 16-bit encryption key length. Access permissions as well as owner and user passwords are assigned to the PDF document. This method by default encrypts PDF's content as well as its metadata. To make selective encryption use appropriate overload of Secure() method.

      The document must be saved for the changes to take effect. A full save is required.

      Parameters:
      permissions - an "OR" of the types of PDF document specified by Permissions:
      ownerPassword - optional PDF document owner password; pass null if not used.
      userPassword - optional PDF document user password; pass null if not used.
    • secure

      public void secure(EnumSet<PermissionFlags> permissions, String ownerPassword, String userPassword, EncryptionType encryptionType)
      Secure the PDF document securely with password(s). The security handler used for the document depends on the encryption type specified. Access permissions as well as owner and user passwords are assigned to the PDF document. This method by default encrypts PDF's content as well as its metadata. To make selective encryption use appropriate overload of Secure() method.

      The document must be saved for the changes to take effect. A full save is required.

      Parameters:
      permissions - an "OR" of the types of PDF document specified by Permissions:
      ownerPassword - optional PDF document owner password; pass null if not used.
      userPassword - optional PDF document user password; pass null if not used.
      encryptionType - Encryption type to be used for securing the document.
    • secure

      public void secure(EnumSet<PermissionFlags> permissions, String ownerPassword, String userPassword, EncryptionType encryptionType, boolean encryptMetadata)
      Secure the PDF document securely with password(s). The security handler used for the document depends on the encryption type specified. Access permissions as well as owner and user passwords are assigned to the PDF document. This method allows selective encryption. Depending on encryptMetadata parameter, it may or may not encrypt PDF's metadata.

      The document must be saved for the changes to take effect. A full save is required.

      Parameters:
      permissions - an "OR" of the types of PDF document specified by Permissions:
      ownerPassword - optional PDF document owner password; pass null if not used.
      userPassword - optional PDF document user password; pass null if not used.
      encryptionType - Encryption type to be used for securing the document.
      encryptMetadata - A flag that indicates whether document metadata will be encrypted.
    • unsecure

      public void unsecure()
      Remove security handler from the PDF document. If the document has a security handler, it is removed. If the document does not have a security handler, this method does nothing.

      To remove the security handler, you must hold the PermissionRequestOperation.Secure permission, which you can obtain via Document.PermRequest. This call will throw an ApplicationException if you do not hold the Secure permission.

      The document must be saved for the changes to take effect. A full save is required.

    • permRequest

      public boolean permRequest(String password, PermissionRequestOperation perms)
      Request the permissions to be changed on a PDF document. This takes effect immediately

      Parameters:
      password - The document password which authorizes the change. Note - if this argument is set to a NULL (""), then the return will be an indicator of whether or not the requested permission is already set in this document, with no changes made to the PDF document.
      perms - the permissions on the PDF file which is to be set or checked.
      Returns:
      a boolean if the permission change is successful or if the permission was set.
    • permRequest

      public boolean permRequest(PermissionRequestOperation requestedperm)
      Tests if a permission is set on a document
      Parameters:
      requestedperm - The document permission which to check
      Returns:
      a boolean if the permission is set in the document.
    • close

      public void close()
      Closes a document and releases its resources. Changes are not saved. You must use Save to save any modifications before calling Close.

      See Also:
    • embedFonts

      public void embedFonts()
      Embed unembedded fonts in a document.

      To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

      With no flags, fonts marked as embedded or subsettable will be embedded.

      By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, use the version of this call that takes a list of Font objects and a set of flags for embedding. Passing the list of new Fonts and the DontScanDocument flag will directly embed the fonts in the list without scanning the document.

    • embedFonts

      public void embedFonts(EnumSet<EmbedFlags> flags)
      Embed unembedded fonts in a document.

      To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

      By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, use the version of this call that takes a list of Font objects and a set of flags for embedding. Passing the list of new Fonts and the DontScanDocument flag will directly embed the fonts in the list without scanning the document.

      Parameters:
      flags - One of the EmbedFlags
    • embedFonts

      public void embedFonts(EnumSet<EmbedFlags> flags, ProgressMonitor progressMonitor, CancelProc cancelProc, ReportProc reportProc)
      Embed unembedded fonts in a document.

      To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

      By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, use the version of this call that takes a list of Font objects and a set of flags for embedding. Passing the list of new Fonts and the DontScanDocument flag will directly embed the fonts in the list without scanning the document.

      Parameters:
      flags - One of the EmbedFlags
      progressMonitor - a ProgressMonitor that will receive progress information, may be null
      cancelProc - a CancelProc, which can return true to cancel the operation, may be null
      reportProc - a ReportProc, which will be called with warnings about fonts that do not embed, may be null
    • embedFonts

      public void embedFonts(List<Font> fonts)
      Embed specified fonts in a document.

      To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

      The fonts passed to this function must be fonts actually used in the current document. These fonts may be obtained by using the GetFonts or GetLoadedFonts functions, or obtained from a TextRun. Fonts created by name will not work in this context.

      By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, use the version of this call that takes a list of Font objects and a set of flags for embedding. Passing the list of new Fonts and the DontScanDocument flag will directly embed the fonts in the list without scanning the document.

    • embedFonts

      public void embedFonts(List<Font> fonts, EnumSet<EmbedFlags> flags)
      Embed specified fonts in a document.

      To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

      The fonts passed to this function must be fonts actually used in the current document. These fonts may be obtained by using the GetFonts or GetLoadedFonts functions, or obtained from a TextRun. Fonts created by name will not work in this context.

      By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, pass the list of new Fonts and the DontScanDocument flag. This will directly embed the fonts in the list without scanning the document.

      Parameters:
      fonts - The list of fonts to embed. See restrictions above.
      flags - One of the EmbedFlags
    • embedFonts

      public void embedFonts(List<Font> fonts, EnumSet<EmbedFlags> flags, ProgressMonitor progressMonitor, CancelProc cancelProc, ReportProc reportProc)
      Embed specified fonts in a document.

      To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

      The fonts passed to this function must be fonts actually used in the current document. These fonts may be obtained by using the GetFonts or GetLoadedFonts functions, or obtained from a TextRun. Fonts created by name will not work in this context.

      By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, pass the list of new Fonts and the DontScanDocument flag. This will directly embed the fonts in the list without scanning the document.

      Parameters:
      fonts - The list of fonts to embed. See restrictions above.
      flags - One of the EmbedFlags
      progressMonitor - a ProgressMonitor that will receive progress information, may be null
      cancelProc - a CancelProc, which can return true to cancel the operation, may be null
      reportProc - a ReportProc, which will be called with warnings about fonts that do not embed, may be null
    • embedOCRFonts

      public void embedOCRFonts()
      Embed fonts that were used in creating OCR text.

      This is also done automatically when saving.

    • print

      public void print(PrintUserParams userParams)
      Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

      Parameters:
      userParams - Parameters to control printing.
    • print

      public void print(PrintUserParams userParams, PrintCancelProc printCancelProc)
      Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

      Parameters:
      userParams - Parameters to control printing.
      printCancelProc - A PrintCancelProc, which can return true to cancel printing, may be null.
    • print

      public void print(PrintUserParams userParams, PrintCancelProc printCancelProc, PrintProgressProc printProgressProc)
      Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

      Parameters:
      userParams - Parameters to control printing.
      printCancelProc - A PrintCancelProc, which can return true to cancel printing, may be null.
      printProgressProc - A PrintProgressProc, may be null.
    • printToFile

      public void printToFile(PrintUserParams userParams, String path)
      Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

      The output is placed in the specified file.

      Parameters:
      userParams - Parameters to control printing.
      path - The output file to be created.
    • printToFile

      public void printToFile(PrintUserParams userParams, PrintCancelProc printCancelProc, String path)
      Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

      The output is placed in the specified file.

      Parameters:
      userParams - Parameters to control printing.
      printCancelProc - A PrintCancelProc, which can return true to cancel printing, may be null.
      path - The output file to be created.
    • printToFile

      public void printToFile(PrintUserParams userParams, PrintCancelProc printCancelProc, PrintProgressProc printProgressProc, String path)
      Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

      The output is placed in the specified file.

      Parameters:
      userParams - Parameters to control printing.
      printCancelProc - A PrintCancelProc, which can return true to cancel printing, may be null.
      printProgressProc - A PrintProgressProc, may be null.
      path - The output file to be created.
    • exportAsPostScript

      public void exportAsPostScript(PrintUserParams userParams, String path)
      Exports a PDF document or pages from a PDF document as PostScript allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

      The output is placed in the specified file.

      Parameters:
      userParams - Parameters to control printing.
      path - The output file to be created.
    • exportAsPostScript

      public void exportAsPostScript(PrintUserParams userParams, PrintCancelProc printCancelProc, String path)
      Exports a PDF document or pages from a PDF document as PostScript allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

      The output is placed in the specified file.

      Parameters:
      userParams - Parameters to control printing.
      printCancelProc - A PrintCancelProc, which can return true to cancel printing, may be null.
      path - The output file to be created.
    • exportAsPostScript

      public void exportAsPostScript(PrintUserParams userParams, PrintCancelProc printCancelProc, PrintProgressProc printProgressProc, String path)
      Exports a PDF document or pages from a PDF document as PostScript allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

      The output is placed in the specified file.

      Parameters:
      userParams - Parameters to control printing.
      printCancelProc - A PrintCancelProc, which can return true to cancel printing, may be null.
      printProgressProc - A PrintProgressProc, may be null.
      path - The output file to be created.
    • getNumPages

      public int getNumPages()
      Gets the number of pages in a document.
      Returns:
      The number of pages in the document. Remember to subtract 1 from this value if you are going to pass it to a Page method that takes a zero-based page number.
    • getPage

      public Page getPage(int pageNumber)
      Gets a Page from a document.

      Parameters:
      pageNumber - The page number of the page to acquire. The first page is 0.
    • createPage

      public Page createPage(int afterPageNum, Rect mediaBox)
      Creates and acquires a new Page. The page is inserted into the document at the specified location.

      Parameters:
      afterPageNum - The page number after which the new page is inserted. The first page is 0. Use Document.BeforeFirstPage to insert the new page at the beginning of a document.
      mediaBox - A rectangle specifying the page's media box, specified in user space coordinates.
      Returns:
      The newly created page.
    • movePage

      public void movePage(int moveToAfterThisPage, int pageToMove)
      Moves one page in a document.
      Parameters:
      moveToAfterThisPage - The new location of the page to move. The first page is 0. It may either be a page number, or the constant Document.BeforeFirstPage.
      pageToMove - The page number of the page to move.
    • insertPages

      public void insertPages(int mergeAfterThisPage, Document doc2, int startPage, int numPages, EnumSet<PageInsertFlags> insertFlags)
      Inserts numPages pages from doc2 into doc. All annotations, and anything else associated with the page (such as a thumbnail image) are copied from the doc2 pages to the new pages in doc. This method does not insert pages if doc equals doc2.

      The insertFlags parameter controls whether bookmarks and threads are inserted along with the specified pages. Setting this parameter to PageInsertFlags.All has two effects:

      • The parameters indicating which pages to insert are ignored: all the pages of doc2 are inserted.

      • In addition to inserting the pages themselves, it also merges other document data from doc2 into doc:

        • Named destinations from doc2 (of PDF 1.1 and later) are copied into doc. If there are named destinations in doc2 with the same name as some named destination in doc, the ones in doc retain their names and the copied named destinations are given new names based on the old ones, with distinguishing digits added. Actions and bookmarks referring to the old names are made to refer to the new names after being copied into doc.

        • If it is also the case that mergeAfterThisPage denotes the last page of the document, then document metadata is merged, and the optional content properties are merged in a more symmetrical manner than would otherwise be the case.

      Document logical structure from doc2 is copied into doc. If less than the whole of doc2 is being inserted, only those structure elements having content on the copied pages, and the ancestors of those elements, are copied into the logical structure tree of doc. The top-level children of the structure tree root of doc2 are copied as new top-level children of the structure tree root of doc; a structure tree root is created in doc if there was none before. The role maps of the two structure trees are merged, with name conflicts resolved in favor of the role mappings present in doc. Attribute objects having scalar values, or values that are arrays of scalar values, are copied. Class map information from doc2 is also merged into that for doc.

      Parameters:
      mergeAfterThisPage - The page number in doc after which pages from doc2 are inserted. The first page is 0. If Document.BeforeFirstPage is used, the pages are inserted before the first page in doc. Use Document.LastPage to insert pages after the last page in doc.
      doc2 - The document containing the pages that are inserted into doc.
      startPage - The page number of the first page in doc2 to insert into doc. The first page is 0.
      numPages - The number of pages in doc2 to insert into doc. Use Document.AllPages to insert all pages from doc2 into doc.
      insertFlags - Flags that determine what additional information is copied from doc2 into doc. It is an OR of the following constants: PageInsertFlags.Bookmarks, PageInsertFlags.Threads, PageInsertFlags.All
    • insertPages

      public void insertPages(int mergeAfterThisPage, Document doc2, int startPage, int numPages, EnumSet<PageInsertFlags> insertFlags, ProgressMonitor progressMonitor, CancelProc cancelProc)
      Inserts numPages pages from doc2 into doc. All annotations, and anything else associated with the page (such as a thumbnail image) are copied from the doc2 pages to the new pages in doc. This method does not insert pages if doc equals doc2.

      The insertFlags parameter controls whether bookmarks and threads are inserted along with the specified pages. Setting this parameter to PageInsertFlags.All has two effects:

      • The parameters indicating which pages to insert are ignored: all the pages of doc2 are inserted.

      • In addition to inserting the pages themselves, it also merges other document data from doc2 into doc:

        • Named destinations from doc2 (of PDF 1.1 and later) are copied into doc. If there are named destinations in doc2 with the same name as some named destination in doc, the ones in doc retain their names and the copied named destinations are given new names based on the old ones, with distinguishing digits added. Actions and bookmarks referring to the old names are made to refer to the new names after being copied into doc.

        • If it is also the case that mergeAfterThisPage denotes the last page of the document, then document metadata is merged, and the optional content properties are merged in a more symmetrical manner than would otherwise be the case.

      Document logical structure from doc2 is copied into doc. If less than the whole of doc2 is being inserted, only those structure elements having content on the copied pages, and the ancestors of those elements, are copied into the logical structure tree of doc. The top-level children of the structure tree root of doc2 are copied as new top-level children of the structure tree root of doc; a structure tree root is created in doc if there was none before. The role maps of the two structure trees are merged, with name conflicts resolved in favor of the role mappings present in doc. Attribute objects having scalar values, or values that are arrays of scalar values, are copied. Class map information from doc2 is also merged into that for doc.

      Parameters:
      mergeAfterThisPage - The page number in doc after which pages from doc2 are inserted. The first page is 0. If Document.BeforeFirstPage is used, the pages are inserted before the first page in doc. Use Document.LastPage to insert pages after the last page in doc.
      doc2 - The document containing the pages that are inserted into doc.
      startPage - The page number of the first page in doc2 to insert into doc. The first page is 0.
      numPages - The number of pages in doc2 to insert into doc. Use Document.AllPages to insert all pages from doc2 into doc.
      insertFlags - Flags that determine what additional information is copied from doc2 into doc. It is an OR of the following constants: PageInsertFlags.Bookmarks, PageInsertFlags.Threads, PageInsertFlags.All
      progressMonitor - a ProgressMonitor that will receive progress information, may be null
      cancelProc - a CancelProc, which can return true to cancel the operation, may be null
    • replacePages

      public void replacePages(int startPage, Document doc2, int startPageDoc2, int numPages, boolean mergeTextAnnots)
      Replaces the specified range of pages in one document with pages from another. The contents, resources, size and rotation of the pages are replaced. The bookmarks are not copied, because they are attached to the document, not to individual pages.

      Parameters:
      startPage - The first page number in doc to replace. The first page is 0.
      doc2 - The document from which pages are copied into doc.
      startPageDoc2 - The page number of the first page in doc2 to copy. The first page is 0.
      numPages - The number of pages to replace.
      mergeTextAnnots - If true, text annotations from doc2 are appended if they are different than all existing annotations on the page in doc. No other types of annotations are copied.
    • deletePages

      public void deletePages(int firstPage, int lastPage)
      Deletes the specified pages.

      Parameters:
      firstPage - The page number of the first page to delete. The first page is 0.
      lastPage - The page number of the last page to delete.
    • deletePages

      public void deletePages(int firstPage, int lastPage, EnumSet<PageDeleteFlags> deleteFlags)
      Deletes the specified pages with option to parse Structure Tree.

      Parameters:
      firstPage - The page number of the first page to delete. The first page is 0.
      lastPage - The page number of the last page to delete.
      deleteFlags - One of the DeleteFlags.
    • removeDuplicateOCG

      public void removeDuplicateOCG()
      Removes duplicate optional content group from the document. This does not remove any content associated with the duplicate group,

    • removeOCG

      public void removeOCG(OptionalContentGroup ocg)
      Removes the specified optional content group from the document. This does not remove any content associated with the specified group, only the group itself.

      Parameters:
      ocg - The optional content group to remove.
    • getFonts

      public List<Font> getFonts(int firstPage, int lastPage)
      Get all the fonts in the specified page range. This may take a considerable amount of time for a large page range.

      Parameters:
      firstPage - The page number of the first page for which fonts are enumerated. The first page is 0.
      lastPage - The page number of the last page for which fonts are enumerated.
    • getLoadedFonts

      public List<Font> getLoadedFonts()
      Enumerates all the fonts that have been encountered so far. A font is loaded when a page that uses it is processed. This typically happens when a page is drawn or its thumbnail image is created.

    • getPageLabels

      public List<PageLabel> getPageLabels()
      The list of PageLabel objects used in the document.

      PageLabels are always stored in page index order; if two PageLabels start on the same page index, the last PageLabel appearing in the list will be used.

    • setPageLabels

      public void setPageLabels(List<PageLabel> arg0)
      The list of PageLabel objects used in the document.

    • findLabelForPageNum

      public String findLabelForPageNum(int pageIndex)
      Fetch the label string for a page index, using the current page labels.

      Parameters:
      pageIndex - Index of a page in the Document
      Returns:
      The label string for the page
    • findPageNumForLabel

      public int findPageNumForLabel(String label)
      Look up a page index based on a label string.

      Parameters:
      label - The label string to look up
      Returns:
      The index of the corresponding page, or -1 if the label could not be matched
    • watermark

      public void watermark(Page page, WatermarkParams watermarkParams)
      Adds a Page as a watermark to a page range in the given document.
      Parameters:
      page - The page to be added as a watermark.
      watermarkParams - Structure specifying how the watermark should be added to the document.
    • watermark

      public void watermark(WatermarkTextParams watermarkTextParams, WatermarkParams watermarkParams)
      Adds a text-based watermark to a page range in the given document.
      Parameters:
      watermarkTextParams - Structure describing the text-based watermark to be added.
      watermarkParams - Structure specifying how the watermark should be added to the document.
    • getBookmarkRoot

      public Bookmark getBookmarkRoot()
      Gets the root of the document's bookmark tree. The return value is valid even if the document's bookmark tree is empty (meaning that there is no Outlines key in the underlying PDF file).

      Returns:
      The document's root bookmark.
    • getOptionalContentGroups

      public List<OptionalContentGroup> getOptionalContentGroups()
      Gets the optional-content groups for the document. The order of the groups is not guaranteed to be the creation order, and is not the same as the display order (see PDOCConfigGetOCGOrder()).

      Returns:
      A list of COptionalContentGroup objects.
    • getOptionalContentContext

      public OptionalContentContext getOptionalContentContext()
      Gets the built-in default OptionalContentContext for the document. This context is used by all content drawing and enumeration calls that do not take an OptionalContentContext parameter, or for which no context is specified.

      Returns:
      The document's current OptionalContentContext.
    • getDefaultOptionalContentConfig

      public OptionalContentConfig getDefaultOptionalContentConfig()
      Gets the default OptionalContentConfig for the document. The OptionalContentConfig determines default settings for optional content, such as the order in which layers (i.e. OptionalContentGroup) appear in the Layers control panel. These settings are used when the document is first opened.

      Returns:
      The document's current default OptionalContentConfig.
    • getOptionalContentConfigs

      public List<OptionalContentConfig> getOptionalContentConfigs()
      Gets all OptionalContentConfigs stored in this document. The first will be the default OptionalContentConfig (the same value returned by DefaultOptionalContentConfig); subsequent values will be additional Configs stored in the document. Any of these can be made the default by setting it via the DefaultOptionalContentConfig property.

      Any OptionalContentConfigs created via the OptionalContentConfig constructor will appear in this list.

      Returns:
      A list of all OptionalContentConfigs in the document.
    • setInfo

      public void setInfo(String infoname, String infovalue)
      Sets metadata information in a PDF document.
      Parameters:
      infoname - The name of metadata to be set
      infovalue - The value for metadata which will be set
    • setTitle

      public void setTitle(String titlevalue)
      The title of the PDF document.

    • setSubject

      public void setSubject(String subjectvalue)
      The subject of the PDF document.

    • setAuthor

      public void setAuthor(String authorvalue)
      The author of the PDF document.

    • setKeywords

      public void setKeywords(String keywordsvalue)
      The keywords of the PDF document.

    • setCreator

      public void setCreator(String creatorvalue)
      The creator of the PDF document.

    • setProducer

      public void setProducer(String producervalue)
      The producer of the PDF document.

    • setBaseURI

      public void setBaseURI(String URIvalue)
      The Base URI of the PDF document.
    • setPageMode

      public void setPageMode(PageMode pagemode)
      The PageMode of the PDF document.

      The default PageMode for a new Document is PageMode.NoPreference .

      Parameters:
      pagemode - the pagemode to apply to the Document
    • getInfo

      public String getInfo(String infoname)
      Gets the value of metadata information in a PDF file.
      Parameters:
      infoname - The name of metadata which value will be obtained.
      Returns:
      The value of the metadata obtained from the PDF file.
    • getTitle

      public String getTitle()
      The title of the PDF document.

    • getSubject

      public String getSubject()
      The subject of the PDF document.

    • getAuthor

      public String getAuthor()
      The author of the PDF document.

    • getKeywords

      public String getKeywords()
      The keywords of the PDF file.

    • getCreator

      public String getCreator()
      The creator of the PDF file.

    • getProducer

      public String getProducer()
      The producer of the PDF file.

    • getBaseURI

      public String getBaseURI()
      The Base URI of the PDF document.
    • getPageMode

      public PageMode getPageMode()
      The PageMode of the PDF document.

    • getInfoDict

      public PDFDict getInfoDict()
      The Info dictionary of the document as a PDFObject.

    • getRoot

      public PDFDict getRoot()
      The Catalog of the document as a PDFObject.

    • getCompressionLevel

      public int getCompressionLevel()
      The compression level of the document.

      The compression level can be one of three values returned by this property:

      • 0 - No compression. All objects are available without inflation.

      • 1 - Partial compression. Objects related to logical structure are stored in object streams and must be inflated.

      • 2 - Full compression. All objects are compressed and must be inflated.

    • getPermanentID

      public byte[] getPermanentID()
      Get the permanent ID for this document.

    • getInstanceID

      public byte[] getInstanceID()
      Get the instance ID for this document.

    • findPDFObjectByID

      public PDFObject findPDFObjectByID(int ID)
      Retrieves an indirect PDFObject by its ID number. Note that direct PDFObjects cannot be retrieved by ID.

    • findBookmark

      public Bookmark findBookmark(String title, int maxDepth)
      Find bookmark by its title, searching within the document's bookmark tree to a depth determined by maxDepth (e.g., 0 = root bookmark only and not any of its children, 1 = search one level below root bookmark level, etc. Omit to search entire bookmark tree.)

      Parameters:
      title - The title of the bookmark for which to search.
      maxDepth - If supplied (with a value greater than or equal to 0), declares the number of levels below this bookmark to search. (If omitted, the entire subtree is searched.)
      Returns:
      The bookmark within the document's bookmark tree that has the supplied title. Returns NULL if there is no bookmark with the supplied title.
    • findBookmark

      public Bookmark findBookmark(String title)
      Find bookmark by its title, searching within the document's entire bookmark tree.

      Parameters:
      title - The title of the bookmark for which to search.
      Returns:
      The bookmark within the document's bookmark tree that has the supplied title. Returns NULL if there is no bookmark with the supplied title.
    • enumIndirectPDFObjects

      public boolean enumIndirectPDFObjects(PDFObjectEnumProc enumProc)
      Enumerates all the indirect objects of this document.

      The objects are enumerated in no particular order. Successive enumerations of the same Document are not guaranteed to enumerate objects in the same order.

      This method does not enumerate invalid objects, which include objects that are defined as null, objects that are not defined at all (those having no cross-reference entry), and objects that are on the free list.

      This re-raises any exception that proc raises.

      Parameters:
      enumProc - A user-supplied callback to call for each indirect object in dP. Enumeration ends when enumProc returns false or all indirect objects have been enumerated. The value parameter returned in enumProc is always null.
      Returns:
      true if all of the calls to enumProc returned true. It returns false as soon as a call to enumProc returns false.
    • createNameTree

      public NameTree createNameTree(String nameTreeName)
      Retrieves the name tree inside the Names dictionary with the specified key name, or creates it if it does not exist.

      Parameters:
      nameTreeName - The name of the NameTree to create.
      Returns:
      The retrieved or newly created NameTree.
    • getNameTree

      public NameTree getNameTree(String nameTreeName)
      Retrieves the name tree inside the Names dictionary with the specified key name.

      Parameters:
      nameTreeName - The name of the NameTree to get.
      Returns:
      The retrieved NameTree.
    • removeNameTree

      public void removeNameTree(String nameTreeName)
      Removes the name tree inside the Names dictionary with the specified key name. It does nothing if no object with that name exists.

      Parameters:
      nameTreeName - The name of the NameTree to remove.
    • getAttachments

      public List<FileAttachment> getAttachments()
      Allows to obtain all attached files from the PDF document.

      Returns:
      set of attached files.
    • getCollection

      public Collection getCollection()
      GetCollection allows to retrieve collection from the PDF document.
      Returns:
      collection object if collection exists in the Document or NULL otherwise.
    • createCollection

      public void createCollection()
      CreateCollection allows to create new collection in the PDF document. It replaces any existing collection.
    • removeCollection

      public void removeCollection()
      RemoveCollection Removes a collection dictionary from a document.
    • getXMPMetadata

      public String getXMPMetadata()
      The XMP metadata associated with a document.

      The XMP metadata returned always represents all the properties in the Document's Info dictionary, and can also contain properties not present in the Info dictionary. This call is preferred to GetInfo, which only returns properties that are in the Info dictionary (although the older function is supported for compatibility).

    • setXMPMetadata

      public void setXMPMetadata(String metadata)
      The XMP metadata associated with a document.

      The XMP metadata returned always represents all the properties in the Document's Info dictionary, and can also contain properties not present in the Info dictionary. This call is preferred to GetInfo, which only returns properties that are in the Info dictionary (although the older function is supported for compatibility).

    • getXMPMetadataProperty

      public String getXMPMetadataProperty(String namespaceName, String path)
      Gets the value of an XMP metadata property associated with a document. It returns the XML text of the value of the specified property in the XMP metadata associated with the Document. The XMP metadata can represent all properties in the Document object's Info dictionary, as well as other properties.

      Parameters:
      namespaceName - The XML namespace URI for the schema in which the property is to be found.
      path - The name of the desired simple property. Note that XMP properties can have an XML substructure; this method can only retrieve values from simple textual properties.
    • setXMPMetadataProperty

      public void setXMPMetadataProperty(String namespaceName, String namespacePrefix, String path, String newValue)
      Sets the value of an XMP metadata property associated with a document. The XMP metadata represents all the properties in pdDoc object's Info dictionary, and can also contain properties that are not in the Info dictionary.

      Parameters:
      namespaceName - The XML namespace URI for the schema in which the property is to be found.
      namespacePrefix - A brief string to be used as an abbreviation when creating the XML representation of the property. This string must not be empty.
      path - The name of the simple property to be modified.
      newValue - The new XML text value for the property.
    • countXMPMetadataArrayItems

      public int countXMPMetadataArrayItems(String namespaceName, String path)
      Returns the number of array items in a property array associated with a Document.

      Parameters:
      namespaceName - The XML namespace URI for the schema in which the property is to be found.
      path - The name of the simple property .
      Returns:
      number of array items in the property array.
    • getXMPMetadataArrayItem

      public String getXMPMetadataArrayItem(String namespaceName, String path, int index)
      Gets the value of an XMP metadata array item, associated with a document, based on an index.

      Parameters:
      namespaceName - The XML namespace URI for the schema in which the property is to be found.
      path - The name of the desired simple property.
      index - The index in the metadata property array associated with the property.
      Returns:
      a string containing the XML text of the value of the specified property in the XMP metadata associated with the Document, or an empty string if no such property is found.
    • setXMPMetadataArrayItem

      public void setXMPMetadataArrayItem(String namespaceName, String namespacePrefix, String path, int index, String newValue)
      Sets the value of an XMP metadata array item, associated with a document, based on an index.

      Parameters:
      namespaceName - The XML namespace URI for the schema in which the property is to be found.
      namespacePrefix - A brief string to be used as an abbreviation when creating the XML representation of the property. This string must not be empty.
      path - The name of the simple property to be modified.
      index - The index in the metadata property array associated with the property.
      newValue - The new XML text value for the property.
    • getMergedXMPKeywords

      public String getMergedXMPKeywords()
      A string containing a semicolon-separated list of fields. The first such field is the entire contents of the pdf:Keywords property of the document XMP; the remaining fields are the contents of successive items in the xmp:Keywords bag of keyword items.

    • mergeXMPKeywords

      public void mergeXMPKeywords()
      Causes a string produced as by PDDocGetMergedXAPKeywords() to be stored as the new value of the pdf:Keywords property, and the former value of the pdf:Keywords property to be stored as an item in the xmp:Keywords bag of keyword items.

      The algorithm used to compute merged keywords lists detects the case in which the keywords lists have already been merged and makes no changes to the XMP metadata in this case.

    • setNeedsSave

      public void setNeedsSave(boolean value)
      The document has been modified and needs to be saved.

      Parameters:
      value - The NeedSave property
    • getNeedsSave

      public boolean getNeedsSave()
      The document has been modified and needs to be saved.

      Returns:
      The NeedsSave property
    • setRequiresFullSave

      public void setRequiresFullSave(boolean value)
      The document cannot be saved incrementally; when it is saved using Document.Save(), the SaveFlags.Full flag must be specified. This flag can only be set, never cleared.

      Parameters:
      value - The RequiresFullSave property
    • getRequiresFullSave

      public boolean getRequiresFullSave()
      The document cannot be saved incrementally; when it is saved using Document.Save(), the SaveFlags.Full flag must be specified. This flag can only be set, never cleared.

      Returns:
      The RequiresFullSave property
    • getIsModified

      public boolean getIsModified()
      The document has been modified slightly (for example, bookmarks or text annotations have been opened or closed), but not in a way that warrants saving. This flag is get only.

      Returns:
      The IsModified property
    • setDeleteOnClose

      public void setDeleteOnClose(boolean value)
      The document is based on a temporary file that must be deleted when the document is closed or saved.

      Parameters:
      value - The DeleteOnClose property
    • getDeleteOnClose

      public boolean getDeleteOnClose()
      The document is based on a temporary file that must be deleted when the document is closed or saved.

      Returns:
      The DeleteOnClose property
    • getWasRepaired

      public boolean getWasRepaired()
      The document was repaired when it was opened. This flag is get only.

      Returns:
      The WasRepaired property
    • getMajorVersionIsNewerThanCurrentLibrary

      public boolean getMajorVersionIsNewerThanCurrentLibrary()
      The document's major version is newer than the current library version. This flag is get only.

      Returns:
      The MajorVersionIsNewerThanCurrentLibrary property
    • getMinorVersionIsNewerThanCurrentLibrary

      public boolean getMinorVersionIsNewerThanCurrentLibrary()
      The document's minor version is newer than the current library version. This flag is get only.

      Returns:
      The MinorVersionIsNewerThanCurrentLibrary property
    • getVersionIsOlderThanCurrentLibrary

      public boolean getVersionIsOlderThanCurrentLibrary()
      The document's version is older than the current library version. This flag is get only.

      Returns:
      The VersionIsOlderThanCurrentLibrary property
    • setSuppressErrors

      public void setSuppressErrors(boolean value)
      Do not display errors.

      Parameters:
      value - The SuppressErrors property
    • getSuppressErrors

      public boolean getSuppressErrors()
      Do not display errors.

      Returns:
      The SuppressErrors property
    • setIsEmbedded

      public void setIsEmbedded(boolean value)
      The document is embedded in a compound document (OLE, OpenDoc).

      Parameters:
      value - The IsEmbedded property
    • getIsEmbedded

      public boolean getIsEmbedded()
      The document is embedded in a compound document (OLE, OpenDoc).

      Returns:
      The IsEmbedded property
    • getIsLinearized

      public boolean getIsLinearized()
      The document is linearized (optimized) for page-served remote (network) access. This flag is get only.

      Returns:
      The IsLinearized property
    • setIsOptimized

      public void setIsOptimized(boolean value)
      The document is optimized. If this flag is cleared, the Adobe PDF Library does not save the file optimized. You can, therefore, linearize a PDF file without optimizing it. Optimizing without linearizing is not allowed, however. This flag can only be set, never cleared.

      Parameters:
      value - The IsOptimized property
    • getIsOptimized

      public boolean getIsOptimized()
      The document is optimized. If this flag is cleared, the Adobe PDF Library does not save the file optimized. You can, therefore, linearize a PDF file without optimizing it. Optimizing without linearizing is not allowed, however. This flag can only be set, never cleared.

      Returns:
      The IsOptimized property
    • getIsPxDF

      public boolean getIsPxDF()
      The underlying file is PxDF. This flag is get only.

      Returns:
      The IsPxDF property
    • getVersionString

      public String getVersionString()
      The PDF version of the document, which is specified in the header of a PDF file in the string "%PDF-xx.yy" where xx is the major version and yy is the minor version.

      Note that this returns a string containing both the major and minor versions. For version comparisons, use MajorVersion and MinorVersion.

      Returns:
      A string containing the PDF version number of the document.
    • getMajorVersion

      public short getMajorVersion()
      The major PDF version number of the document. The PDF version is specified in the header of a PDF file in the string "%PDF-xx. yy" where xx is the major version and yy is the minor version.

      Returns:
      The major PDF version number of the document.
    • getMinorVersion

      public short getMinorVersion()
      The minor PDF version number of the document. The PDF version is specified in the header of a PDF file in the string "%PDF-xx. yy" where xx is the major version and yy is the minor version.

      Please note: Setting the minor version on a document only changes the version number in the document's file header. It will NOT actually change the PDF's contents and it will NOT alter the PDF to conform to the standard of the new minor version.

      The new minor version number will appear in the file header once the document is saved.

      Returns:
      The minor PDF version number of the document.
    • setMinorVersion

      public void setMinorVersion(short minorVersion)
      The minor PDF version number of the document. The PDF version is specified in the header of a PDF file in the string "%PDF-xx. yy" where xx is the major version and yy is the minor version. For example, version 1.2 has the string "%PDF-1 .2".

      Please note: Setting the minor version on a document only changes the version number in the document's file header. It will NOT actually change the PDF's contents and it will NOT alter the PDF to conform to the standard of the new minor version.

      The new minor version number will appear in the file header once the document is saved.

      Parameters:
      minorVersion - The new minor version number to be set in the document's file header.
    • setMajorVersion

      public void setMajorVersion(short majorVersion)
      The major PDF version number of the document. The PDF version is specified in the header of a PDF file in the string "%PDF-x.y" where x is the major version and y is the minor version. For example, version 1.2 has the string "%PDF-1.2". See Section I.2 in the PDF Reference.

      Please note: Setting the major version on a document only changes the version number in the document's file header. It will NOT actually change the PDF's contents and it will NOT alter the PDF to conform to the standard of the new major version.

      The new major version number will appear in the file header once the document is saved.

      Parameters:
      majorVersion - The new major version number to be set in the document's file header.
    • applyRedactions

      public boolean applyRedactions(Redaction redact)
    • applyRedactions

      public boolean applyRedactions()
    • flattenTransparency

      public int flattenTransparency()
      Flattens all transparencies in the document. To flatten specific pages, see Document.FlattenTransparency(params, firstPage, lastPage)

      Documents are flattened one at a time. In multi-threaded applications, threads that are making simultaneous calls to this method will block and execute the method sequentially.

      Returns:
      The number of pages that were flattened.
    • flattenTransparency

      public int flattenTransparency(FlattenTransparencyParams params)
      Flattens all transparencies in the document. To flatten specific pages, see Document.FlattenTransparency(params, firstPage, lastPage)

      Documents are flattened one at a time. In multi-threaded applications, threads that are making simultaneous calls to this method will block and execute the method sequentially.

      Parameters:
      params - Additional parameters for performing transparency flattening.
      Returns:
      The number of pages that were flattened.
    • flattenTransparency

      public int flattenTransparency(FlattenTransparencyParams params, int firstPage, int lastPage)
      Flattens transparencies in the document that occur on pages within the specified range. When performing flattening on multiple pages, this method is more efficient than making multiple Page.FlattenTransparency() calls.

      Documents are flattened one at a time. In multi-threaded applications, threads that are making simultaneous calls to this method will block and execute the method sequentially.

      Parameters:
      params - Additional parameters for performing transparency flattening.
      firstPage - The first page of the range of pages to flatten.
      lastPage - The last page of the range of pages to flatten.
      Returns:
      The number of pages that were flattened.
    • flattenOptionalContent

      public boolean flattenOptionalContent()
      Flattens optional content in the document.

      Every page in the document will be replaced with a version that has no optional content. The new version of the page will contain only what was visible on the page when the call was made. All other optional content information will be removed from the document.

      The document's default optional content context will be used to determine visibility of optional content.

      Returns:
      true if the document was successfully flattened, false otherwise.
    • flattenOptionalContent

      public boolean flattenOptionalContent(OptionalContentContext occ)
      Flattens optional content in the document.

      Every page in the document will be replaced with a version that has no optional content. The new version of the page will contain only what was visible on the page when the call was made. All other optional content information will be removed from the document.

      Parameters:
      occ - The optional content context in which content is checked for visibility.
      Returns:
      true if the document was successfully flattened, false otherwise.
    • colorConvertPages

      public boolean colorConvertPages(ColorConvertParams params)
      Convert the colors (in place) in a Document as specified by by the params block by applying an ICC profile to the objects contained in the Document.

      Returns:
      True if color conversion occurred. False if nothing was color converted.
    • getHasSignature

      public boolean getHasSignature()
      The document contains a Digital Signature.

      Returns:
      If the Document has a Digital Signature.
    • collectNamesOfTree

      public void collectNamesOfTree(PDFArray namesArray, List<FileAttachment> attachments)
    • lookForKidsInNameTree

      public void lookForKidsInNameTree(PDFDict nameTree, List<FileAttachment> attachments)
    • getRolledBackDocuments

      public List<RolledBackDocument> getRolledBackDocuments()
      A Document that have been previously saved Incrementally means changes were written to the end of the file leaving its original contents intact. Thus an Incrementally saved file may contain multiple entire PDF documents that represent prior incarnations of the current document. This method retrieves any such previous documents found in sequential order from the beginning of the file.

      Returns:
      The list of Rolled Back Documents, the documents must be saved to disk before they can be loaded into PDFL.
    • convertToWord

      public static boolean convertToWord(String inputPDFFileFilePath, String outputOfficeFilePath)
      This function converts a PDF file to a Microsoft Word Office file (.docx).

      NOTE: This method is only available on Windows 32/64-bit and Linux 64-bit.

      Parameters:
      inputPDFFileFilePath - The PDF file path to convert.
      outputOfficeFilePath - The output Office file path.
      Returns:
      true if the conversion was successful, false if an error occurred.
    • convertToExcel

      public static boolean convertToExcel(String inputPDFFileFilePath, String outputOfficeFilePath)
      This function converts a PDF file to a Microsoft Excel Office file (.xlsx).

      NOTE: This method is only available on Windows 32/64-bit and Linux 64-bit.

      Parameters:
      inputPDFFileFilePath - The PDF file path to convert.
      outputOfficeFilePath - The output Office file path.
      Returns:
      true if the conversion was successful, false if an error occurred.
    • convertToPowerPoint

      public static boolean convertToPowerPoint(String inputPDFFileFilePath, String outputOfficeFilePath)
      This function converts a PDF file to a Microsoft PowerPoint Office file (.pptx).

      NOTE: This method is only available on Windows 32/64-bit and Linux 64-bit.

      Parameters:
      inputPDFFileFilePath - The PDF file path to convert.
      outputOfficeFilePath - The output Office file path.
      Returns:
      true if the conversion was successful, false if an error occurred.
    • flattenXFAFormFields

      public long flattenXFAFormFields()
      Flatten a XFA Document (Static or Dynamic). XFA content is not widely supported by PDF processors, flattening this content transforms into static PDF page content that is part of typical PDF files that can easily be understood by PDF processors. All XFA fields are removed.

      https://www.datalogics.com/pdf-form-functions.

      Returns:
      the number of output pages created in the flattened document.
    • flattenAcroFormFields

      public void flattenAcroFormFields()
      Flatten a AcroForms document. Interactive AcroForm fields are flattened into static PDF page content. All AcroForm fields are removed.

      NOTE: This method is part of the APDFL Forms Extension that is available separately from APDFL. For more information, please see https://www.datalogics.com/pdf-form-functions.

    • convertXFAFieldsToAcroFormFields

      public long convertXFAFieldsToAcroFormFields()
      Convert a XFA document into a document with only AcroForms. XFA content is not widely supported by PDF processors, converting this content transforms XFA fields into AcroForm fields which are more widely suppored by PDF processors All XFA fields are removed.

      https://www.datalogics.com/pdf-form-functions.

      Returns:
      the number of output pages created in the converted document
    • exportXFAFormsData

      public boolean exportXFAFormsData(String fileName, XFAFormExportType exportType)
      Export the XFA Forms data. XFA forms data is exported into a format that can later be imported into another XFA document.

      https://www.datalogics.com/pdf-form-functions.

      Parameters:
      fileName - The path on disk of the file the XFA form data is exported to.
      exportType - The format type the XFA data should be exported to. The supported types are XDP, XML, and XFD.
      Returns:
      true indicates exporting succeeded and false indicates an error occurred
    • importXFAFormsData

      public boolean importXFAFormsData(String fileName)
      Import the XFA Forms data. XFA forms data is imported from a supported format into the XFA document so its existing fields can be populated for example.

      https://www.datalogics.com/pdf-form-functions.

      Parameters:
      fileName - The path on disk of the XFA form data file to be imported, the supported types of data that can be imported are XDP, XML, and XFD.
      Returns:
      true indicates importing succeeded and false indicates an error occurred
    • exportAcroFormsData

      public boolean exportAcroFormsData(String fileName, AcroFormExportType exportType)
      Export the AcroForms data. AcroForms data is exported into a format that can later be imported into another AcroForms document.

      https://www.datalogics.com/pdf-form-functions.

      Parameters:
      fileName - The path on disk of the file the AcroForms data is exported to.
      exportType - The format type the AcroForm data should be exported to. The supported types are XFDF, FDF, and XML.
      Returns:
      true indicates exporting succeeded and false indicates an error occurred
    • importAcroFormsData

      public boolean importAcroFormsData(String fileName, AcroFormImportType importType)
      Import the AcroForms data. AcroForms data is imported from a supported format into the AcroForms document so its existing fields can be populated for example.

      https://www.datalogics.com/pdf-form-functions.

      Parameters:
      fileName - The path on disk of the AcroFormsdata file to be imported.
      importType - The format type the data type should be imported to. The supported types are XFDF, FDF, and XML.
      Returns:
      true indicates importing succeeded and false indicates an error occurred
    • isDynamicXFA

      public boolean isDynamicXFA()
      Indicates if the document is Dynamic XFA. Dynamic XFA documents can change in appearance in response to changes in the data. They don't contain a meaningful PDF representation. Such XFA content is not widely supported by PDF processors.

      https://www.datalogics.com/pdf-form-functions.

      Returns:
      true indicates the Document is Dynamic XFA, false indicates it is not
    • isStaticXFA

      public boolean isStaticXFA()
      Indicates if the document is Static XFA. Static XFA documents have a fixed appearance and layout. They usually contain a meaningful PDF representation. Such XFA content is not widely supported by PDF processors.

      https://www.datalogics.com/pdf-form-functions.

      Returns:
      true indicates the Document is Static XFA, false indicates it is not
    • flattenXFAFormFieldsAsIfPrinted

      public long flattenXFAFormFieldsAsIfPrinted()
      Flatten a XFA Document (Static or Dynamic) as if it was Printed. XFA content is not widely supported by PDF processors, flattening this content transforms into static PDF page content that is part of typical PDF files that can easily be understood by PDF processors. All XFA fields are removed.

      The Flattened appearance will take into consideration how the document should appear when printed.

      https://www.datalogics.com/pdf-form-functions.

      Returns:
      the number of output pages created in the flattened document.
    • flattenNonFormAnnotations

      public void flattenNonFormAnnotations()
      Flatten a Non-Form (no AcroForm, no XFA) document's Annotations. Annotations are flattened into static PDF page content.

      NOTE: This method is part of the APDFL Forms Extension that is available separately from APDFL. For more information, please see https://www.datalogics.com/pdf-form-functions.

    • getFormsType

      public PDDocFormsType getFormsType()
      Returns the document's Forms Type. This property is more versatile than the related IsDynamicXFA() and IsStaticXFA() methods.

      https://www.datalogics.com/pdf-form-functions.

      Returns:
      the Type of Forms the Document contains.