com.groupdocs.merger.handler

Class DocumentHandler



  • public class DocumentHandler
    extends Object

    Handler for manipulating documents.

    • Constructor Detail

      • DocumentHandler

        public DocumentHandler()
    • Method Detail

      • addPassword

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

        Protects document of known format with password. Source document file format should 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 final 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 applies 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
      • getPagePreview

        public final List<PageImage> getPagePreview(InputStream documentStream,
                                     com.groupdocs.merger.domain.options.ImageOptions imageOptions)
                                             throws Exception

        Get list of page image representations for document of known format. Source document file format should be specified. If format is not specified or "Undefined" then it will be detected on the fly.

        Parameters:
        documentStream - The document stream.
        imageOptions - The image options.
        Returns:
        Throws:
        Exception
      • getPagePreview

        public final List<PageImage> getPagePreview(InputStream documentStream,
                                     List<Integer> pageNumbers)
                                             throws Exception

        Get list of page image representations for document of unknown format. Source document file format will be detected on the fly.

        Parameters:
        documentStream - The document stream.
        pageNumbers - List of page number. First page is 1.
        Returns:
        Throws:
        Exception
      • getSupportedFormats

        public final Map<String,Long> getSupportedFormats()

        Get list of supported document formats.

        Returns:
      • isPasswordSet

        public final 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 final boolean isPasswordSet(InputStream documentStream,
                            long fileFormat)
                                    throws Exception

        Checks whether document of known format is password protected. Source document file format should 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 final 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
      • joinImage

        public final ImageJoinItem joinImage(List<ImageJoinItem> joinItems,
                              com.groupdocs.merger.domain.options.ImageJoinOptions imageJoinOptions)
                                      throws Exception

        Joins multiple images into the one image.

        Parameters:
        joinItems - The images to join.
        imageJoinOptions - The join options.
        Returns:
        Throws:
        Exception
      • joinImageStream

        public final ImageJoinItem joinImageStream(List<InputStream> joinItems,
                                    com.groupdocs.merger.domain.options.ImageJoinOptions imageJoinOptions)

        Joins multiple images into the one image.

        Parameters:
        joinItems - The images to join.
        imageJoinOptions - The join options.
        Returns:
      • joinStream

        public final 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 final 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 final 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 final 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 final DocumentResult removePassword(InputStream documentStream,
                                    RemovePasswordOptions removePasswordOptions)
                                            throws Exception

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

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

        public final 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 final MultiDocumentResult split(InputStream documentStream,
                                com.groupdocs.merger.domain.options.PageSplitOptions 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
      • split

        public final MultiDocumentResult split(InputStream documentStream,
                                com.groupdocs.merger.domain.options.TextSplitOptions splitOptions)
                                        throws Exception

        Splits single document of known format to multiple documents.

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

        public final 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 final DocumentResult swapPages(InputStream documentStream,
                               SwapOptions swapOptions)
                                       throws Exception

        Swaps two pages within document of known format.

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

        public final 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 final 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 final DocumentResult updatePassword(InputStream documentStream,
                                    UpdatePasswordOptions updatePasswordOptions)
                                            throws Exception

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

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