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 options)
                                   throws Exception

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

        Parameters:
        documentStream - Unprotected document.
        options -
        Returns:
        Password-protected document.
        Throws:
        Exception
      • addPassword

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

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

        Parameters:
        documentStream - Unprotected document.
        password -
        Returns:
        Password-protected document.
        Throws:
        Exception
      • isPasswordSet

        public boolean isPasswordSet(InputStream documentStream)
                              throws Exception

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

        Parameters:
        documentStream -
        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 is password protected. Source document file format must be specified explicitly.

        Parameters:
        documentStream -
        fileFormat -
        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 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 documents into the one 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.

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

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

        Removes pages from document.

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

        public DocumentResult removePages(InputStream documentStream,
                                 PagesOptions options)
                                   throws Exception

        Removes pages from document. Page numbers for removing have to be specified.

        Parameters:
        documentStream - The document stream.
        options - The options.
        Returns:
        Document.
        Throws:
        Exception
      • removePassword

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

        Removes document password. Source document file format must be specified explicitly.

        Parameters:
        documentStream -
        options -
        Returns:
        Document without password protection.
        Throws:
        Exception
      • removePassword

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

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

        Parameters:
        documentStream -
        password -
        Returns:
        Document without password protection.
        Throws:
        Exception
      • swapPages

        public DocumentResult swapPages(InputStream documentStream,
                               int firstOfPair,
                               int secondOfPair)
                                 throws Exception

        Swaps two pages within document.

        Parameters:
        documentStream - The document stream.
        firstOfPair - The first page to swap.
        secondOfPair - The second page to swap.
        Returns:
        Document.
        Throws:
        Exception
      • trim

        public DocumentResult trim(InputStream documentStream,
                          PagesOptions pagesOptions)
                            throws Exception

        Makes new document with some pages from source document.

        Parameters:
        documentStream - The document stream.
        pagesOptions - The pages options.
        Returns:
        Document
        Throws:
        Exception
      • trim

        public DocumentResult trim(InputStream documentStream,
                          RangeOptions rangeOptions)
                            throws Exception

        Makes new document with some pages from source document.

        Parameters:
        documentStream - The document stream.
        rangeOptions - The range options.
        Returns:
        Document
        Throws:
        Exception
      • updatePassword

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

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

        Parameters:
        documentStream -
        oldPassword -
        newPassword -
        Returns:
        Document without updated password.
        Throws:
        Exception
      • updatePassword

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

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

        Parameters:
        documentStream -
        options -
        Returns:
        Document without updated password.
        Throws:
        Exception