com.groupdocs.merger.handler

Class DocumentHandler



  • public class DocumentHandler
    extends Object

    Handler for manipulating documents.

    • Constructor Detail

      • DocumentHandler

        public DocumentHandler()
    • Method Detail

      • addPassword

        public DocumentResult addPassword(InputStream documentStream,
                                 AddPasswordOptions addPasswordOptions)
                                   throws Exception

        Protects document of known format with password. Source document file format must be specified explicitly.

        Parameters:
        documentStream - Unprotected document.
        addPasswordOptions - The options for specifying password and document file format.
        Returns:
        Password-protected document.
        Throws:
        Exception
      • addPassword

        public DocumentResult addPassword(InputStream documentStream,
                                 String password)
                                   throws Exception

        Protects document of unknown format with password. Source document file format will be detected on the fly.

        Parameters:
        documentStream - Unprotected document.
        password - Password to be set.
        Returns:
        Password-protected document.
        Throws:
        Exception
      • changeOrientation

        public final DocumentResult changeOrientation(InputStream documentStream,
                                       int mode,
                                       int[] pageNumbers)
                                               throws Exception

        Makes new document from document of unknown format and applis new orientation mode for specified pages.

        Parameters:
        documentStream - The document stream.
        mode - Mode of page orientation.
        pageNumbers - Array of page numbers.
        Returns:
        Document
        Throws:
        Exception
      • changeOrientation

        public final DocumentResult changeOrientation(InputStream documentStream,
                                       OrientationOptions orientationOptions)
                                               throws Exception

        Makes new document from document of known format and applies new orientation mode for specified pages.

        Parameters:
        documentStream - The document stream.
        orientationOptions - The change orientation options.
        Returns:
        Document
        Throws:
        Exception
      • getSupportedFormats

        public final Map<String,Long> getSupportedFormats()

        Get list of supported document formats.

        Returns:
      • isPasswordSet

        public boolean isPasswordSet(InputStream documentStream)
                              throws Exception

        Checks whether document of unknown format is password protected. Source document file format will be detected on the fly.

        Parameters:
        documentStream - The document stream.
        Returns:
        Returns a value indicating whether document is protected or not.
        Throws:
        Exception
      • isPasswordSet

        public boolean isPasswordSet(InputStream documentStream,
                            long fileFormat)
                              throws Exception

        Checks whether document of known format is password protected. Source document file format must be specified explicitly.

        Parameters:
        documentStream - The document stream.
        fileFormat - The file format.
        Returns:
        Returns a value indicating whether document is protected or not.
        Throws:
        Exception
      • join

        public DocumentResult join(List<JoinItem> joinItems)
                            throws Exception

        Joins multiple documents of known format into the one document. Each document format should be specified explicitly via JoinItem properties.

        Parameters:
        joinItems - The documents to join.
        Returns:
        Joined document.
        Throws:
        Exception
      • joinStream

        public DocumentResult joinStream(List<InputStream> documentStreams)
                                  throws Exception

        Joins multiple document streams of unknown format into resultant document. Document format will be detected on the fly.

        Parameters:
        documentStreams - The document streams to join.
        Returns:
        Joined document.
        Throws:
        Exception
      • movePage

        public DocumentResult movePage(InputStream documentStream,
                              int pageNumberToMove,
                              int newPageNumber)
                                throws Exception

        Moves page to a new position within document of unknown format.

        Parameters:
        documentStream - The document stream.
        pageNumberToMove - The page number to move.
        newPageNumber - The new page number.
        Returns:
        Document.
        Throws:
        Exception
      • movePage

        public DocumentResult movePage(InputStream documentStream,
                              MoveOptions moveOptions)
                                throws Exception

        Moves page to a new position within document of known format.

        Parameters:
        documentStream - The document stream.
        moveOptions - The move options.
        Returns:
        Document.
        Throws:
        Exception
      • removePages

        public final DocumentResult removePages(InputStream documentStream,
                                 int startPageNumber,
                                 int endPageNumber,
                                 int mode)
                                         throws Exception

        Removes pages from document of unknown format.

        Parameters:
        documentStream - The document stream.
        startPageNumber - The start page number.
        endPageNumber - The end page number.
        mode - The page range mode.
        Returns:
        Document.
        Throws:
        Exception
      • removePages

        public DocumentResult removePages(InputStream documentStream,
                                 List<Integer> pageNumbers)
                                   throws Exception

        Removes pages from document of unknown format.

        Parameters:
        documentStream - The document stream.
        pageNumbers - The list of page numbers to be removed.
        Returns:
        Document.
        Throws:
        Exception
      • removePages

        public final DocumentResult removePages(InputStream documentStream,
                                 com.groupdocs.merger.domain.options.RemovePagesOptions removePagesOptions)
                                         throws Exception

        Removes pages from document of known format.

        Parameters:
        documentStream - The document stream.
        removePagesOptions - The options for specifying document format and numbers of pages to be removed.
        Returns:
        Document with removed pages
        Throws:
        Exception
      • removePassword

        public DocumentResult removePassword(InputStream documentStream,
                                    RemovePasswordOptions options)
                                      throws Exception

        Removes password from document of known format. Source document file format must be specified explicitly.

        Parameters:
        documentStream - The document stream.
        options - The options for specifying document file format and current password.
        Returns:
        Document without password protection.
        Throws:
        Exception
      • removePassword

        public DocumentResult removePassword(InputStream documentStream,
                                    String password)
                                      throws Exception

        Removes password from document of unknown format. Source document file format will be detected on the fly.

        Parameters:
        documentStream - The document stream.
        password - The current document password.
        Returns:
        Document without password protection.
        Throws:
        Exception
      • rotatePages

        public final DocumentResult rotatePages(InputStream documentStream,
                                 int mode)
                                         throws Exception

        Rotate pages in document of unknown format.

        Parameters:
        documentStream - Not password protected document stream.
        mode - Rotate mode RotateMode
        Returns:
        Document.
        Throws:
        Exception
      • rotatePages

        public final DocumentResult rotatePages(InputStream documentStream,
                                 com.groupdocs.merger.domain.options.RotateOptions rotateOptions)
                                         throws Exception

        Rotate pages in document of known format.

        Parameters:
        documentStream - The document stream.
        rotateOptions - The options for rotating.
        Returns:
        Document.
        Throws:
        Exception
      • split

        public MultiDocumentResult split(InputStream documentStream,
                                SplitOptions splitOptions)
                                  throws Exception

        Splits single document of known format to multiple documents.

        Parameters:
        documentStream - The document stream.
        splitOptions - The split options.
        Returns:
        Multiple documents.
        Throws:
        Exception
      • swapPages

        public DocumentResult swapPages(InputStream documentStream,
                               int firstPageNumber,
                               int secondPageNumber)
                                 throws Exception

        Swaps two pages within document of unknown format.

        Parameters:
        documentStream - The document stream.
        firstPageNumber - The first page to swap.
        secondPageNumber - The second page to swap.
        Returns:
        Document.
        Throws:
        Exception
      • swapPages

        public DocumentResult swapPages(InputStream documentStream,
                               SwapOptions options)
                                 throws Exception

        Swaps two pages within document of known format.

        Parameters:
        documentStream - The document stream.
        options - The swap options.
        Returns:
        The document.
        Throws:
        Exception
      • trim

        public DocumentResult trim(InputStream documentStream,
                          TrimOptions trimOptions)
                            throws Exception

        Makes new document with some pages from source document of known format.

        Parameters:
        documentStream - The document stream.
        trimOptions - The trim options.
        Returns:
        Document
        Throws:
        Exception
      • updatePassword

        public DocumentResult updatePassword(InputStream documentStream,
                                    String oldPassword,
                                    String newPassword)
                                      throws Exception

        Updates existing password for document of unknown format. Source document file format will be detected on the fly.

        Parameters:
        documentStream - The document stream.
        oldPassword - The current document password.
        newPassword - The new document password.
        Returns:
        Document without updated password.
        Throws:
        Exception
      • updatePassword

        public DocumentResult updatePassword(InputStream documentStream,
                                    UpdatePasswordOptions options)
                                      throws Exception

        Updates existing password for document of known format. Source document file format must be specified explicitly.

        Parameters:
        documentStream - The document stream.
        options - The options for specifying document file format and current/new passwords.
        Returns:
        Document with updated password.
        Throws:
        Exception