com.aspose.pdf.facades

Class PdfFileEditorWeb

  • All Implemented Interfaces:
    IPdfFileEditor


    public final class PdfFileEditorWeb
    extends Object
    implements IPdfFileEditor
    Represents PdfFileEditorWeb class

    Implements operations with PDF file: concatenation, splitting, extracting pages, making booklet, etc.

    • Field Detail

      • TryMergeAdjacentSameBackgroundImages

        public boolean TryMergeAdjacentSameBackgroundImages

        Sometimes PDFs contain background images (of pages or table cells) constructed from several same tiling background images put one near other. In such case renderers of target formats (f.e MsWord for DOCS format) sometimes generates visible boundaries beetween parts of background images, cause their techniques of image edge smoothing (anti-aliasing) is different from Acrobat Reader. If it looks like exported document contains such visible boundaries between parts of same background images, please try use this setting to get rid of that unwanted effect. ATTENTION! This optimization of quality usually essentially slows down conversion, so, please, use this option only when it's really necessary.

      • customProgressConcatenationHandler

        public PdfFileEditor.ConcatenationProgressHandler customProgressConcatenationHandler

        Representation of internal progress events processor that works during concatenation and translates concatenation events of internal concatenation stages into external customer's code. This field uses different types of events.

        Simple concatenation has 8 events :
        1)AllPagesCopied
        2)DocumentEmbeddedFiles
        3)DocumentForms
        4)DocumentOutlines
        5)DocumentJavaScript
        6)DocumentLogicalStructure
        7)DocumentConcated.
        8)TotalPercentage.

        Parallel concatenation informs about every page concatenation and has 3 events:
        1)PageConcatenated
        2)BlankPage
        3)TotalPercentage

        See Also:
        PdfFileEditor.ProgressEventType
    • Constructor Detail

      • PdfFileEditorWeb

        public PdfFileEditorWeb()

        PdfFileEditorWeb constructor.

    • Method Detail

      • concatenate

        public boolean concatenate(String[] inputFiles,
                                   javax.servlet.http.HttpServletResponse response)

        Concatenates files and saves reslt into HttpResposnse object.

        Parameters:
        inputFiles - Array of files to concatenate.
        response - Response object.
        Returns:
        true if concatenation was successful.
      • concatenate

        public boolean concatenate(InputStream[] inputStream,
                                   javax.servlet.http.HttpServletResponse response)

        Concatenates files and stores result into HttpServletResponse object.

        Parameters:
        inputStream - Streams array which contain files to concatenate.
        response - Response object/
        Returns:
        true if operation was succeeded.
      • append

        public boolean append(InputStream inputStream,
                              InputStream[] portStreams,
                              int startPage,
                              int endPage,
                              javax.servlet.http.HttpServletResponse response)

        Appends documents to source document and saves result into response object.

        Parameters:
        inputStream - Stream which contains source document.
        portStreams - Array of streams with documents to be appended.
        startPage - Start page of appended page.
        endPage - End page of appended pages.
        response - Response object where document will be saved.
        Returns:
        true if operation was successful.
      • append

        public boolean append(String inputFile,
                              String[] portFiles,
                              int startPage,
                              int endPage,
                              javax.servlet.http.HttpServletResponse response)

        Appends documents to source document and saves result into HttpServletResponse object.

        Parameters:
        inputFile - Name of file containing source document.
        portFiles - Array of file names containing appended documents
        startPage - Start page of appended pages.
        endPage - End page of appended pages.
        response - Response object where document will be saved.
        Returns:
        true if operation was succeeded.
      • insert

        public boolean insert(String inputFile,
                              int insertLocation,
                              String portFile,
                              int[] pageNumber,
                              javax.servlet.http.HttpServletResponse response)

        Inserts contents of file into source file and stores result into HttpServletResponse object.

        Parameters:
        inputFile - Source file name.
        insertLocation - Page number where second file will be inserted.
        portFile - Path to file which will be inserted.
        pageNumber - Array of page numbers in source file wihich will be inserted.
        response - Response object where result will be stored.
        Returns:
        true of inserting was successful.
      • insert

        public boolean insert(InputStream inputStream,
                              int insertLocation,
                              InputStream portStream,
                              int[] pageNumber,
                              javax.servlet.http.HttpServletResponse response)

        Inserts document into other document and stores result into response object.

        Parameters:
        inputStream - Stream with source document
        insertLocation - Location where other document will be inserted.
        portStream - Document to be inserted.
        pageNumber - Array of page numbers in second document which will be inserted.
        response - Response object where result will be stored.
        Returns:
        True if operation was succeeded.
      • delete

        public boolean delete(String inputFile,
                              int[] pageNumber,
                              javax.servlet.http.HttpServletResponse response)

        Deletes specified pages from document and stores result into HttpServletResponse object.

        Parameters:
        inputFile - Path of source file.
        pageNumber - Array of page numbers which must be deleted.
        response - Response object where result document will be stored.
        Returns:
        True if operation was succeeded.
      • delete

        public boolean delete(InputStream inputStream,
                              int[] pageNumber,
                              javax.servlet.http.HttpServletResponse response)

        Deletes specified pages from document and saves result into HttpServletResponse object.

        Parameters:
        inputStream - Source document stream.
        pageNumber - Array of page numbers which will be deleted.
        response - HttpServletResponse object
        Returns:
        True if operation succeded.
      • extract

        public boolean extract(InputStream inputStream,
                               int[] pageNumber,
                               javax.servlet.http.HttpServletResponse response)

        Extracts specified pages form source file and stores result into HttpServletResponse object.

        Parameters:
        inputStream - Stream of source document.
        pageNumber - Array of page numbers which will be extracted.
        response - HttpServletResponse object where result will be stored.
        Returns:
        True if operation was succeeded.
      • extract

        public boolean extract(String inputFile,
                               int[] pageNumber,
                               javax.servlet.http.HttpServletResponse response)

        Extracts specified pages from source file and stores result into HttpServletResponse object.

        Parameters:
        inputFile - Source file path.
        pageNumber - Array of page numbers which will be extracted.
        response - HttpServletResponse object where result will be stored.
        Returns:
        true if pages were extracted successfully.
      • splitFromFirst

        public boolean splitFromFirst(String inputFile,
                                      int location,
                                      javax.servlet.http.HttpServletResponse response)

        Splits document from first page to location and saves result into HttpServletResponse objects.

        Parameters:
        inputFile - Source file name.
        location - Split point.
        response - HttpServletResponse objects.
        Returns:
        True if operation was succeeded.
      • splitFromFirst

        public boolean splitFromFirst(InputStream inputStream,
                                      int location,
                                      javax.servlet.http.HttpServletResponse response)

        Splits document from start to specified location and stores result into HttpServletResponse object.

        Parameters:
        inputStream - Stream of source document.
        location - The splitting point.
        response - HttpServletResponse object where result will be stored.
        Returns:
        True if operation was succeeded.
      • splitToEnd

        public boolean splitToEnd(InputStream inputStream,
                                  int location,
                                  javax.servlet.http.HttpServletResponse response)

        Splits from specified location, and saves the rear part into HttpServletResponse object.

        Parameters:
        inputStream - Source document stream.
        location - Split point.
        response - HttpServletResponse object.
        Returns:
        true if splitting was successful.
      • splitToEnd

        public boolean splitToEnd(String inputFile,
                                  int location,
                                  javax.servlet.http.HttpServletResponse response)

        Splits from specified location, and saves the rear part into HttpServletResponse object.

        Parameters:
        inputFile - source file name.
        location - Split point.
        response - HttpServletResponse objects.
        Returns:
        True if operation was succeeded.
      • makeBooklet

        public boolean makeBooklet(String inputFile,
                                   PageSize pageSize,
                                   int[] leftPages,
                                   int[] rightPages,
                                   javax.servlet.http.HttpServletResponse response)

        Makes booklet from source file and stores result into HttpServletResponse objects.

        Parameters:
        inputFile - Source file path.
        pageSize - Desired page size.
        leftPages - Aray of page numbers to be placed in left.
        rightPages - Array of page numbers to be placed in right.
        response - HttpServletResponse object where result will be stored.
        Returns:
        True if operation was succeeded.
      • makeBooklet

        public boolean makeBooklet(InputStream inputStream,
                                   PageSize pageSize,
                                   int[] leftPages,
                                   int[] rightPages,
                                   javax.servlet.http.HttpServletResponse response)

        Make booklet from PDF file and stores it into HttpServletResponse.

        Parameters:
        inputStream - Input document stream.
        pageSize - Desired page size.
        leftPages - Array of page numbers which will be placed in left.
        rightPages - Array of page numbers which will b eplaced in right.
        response - HttpServletResponse object.
        Returns:
        True if operation was succeeded.
      • makeBooklet

        public boolean makeBooklet(String inputFile,
                                   PageSize pageSize,
                                   javax.servlet.http.HttpServletResponse response)

        Makes booklet from source file and stores result into HttpServletResponse objects.

        Parameters:
        inputFile - Source file path.
        pageSize - Desired page size in output file.
        response - HttpServletResponse object where result will be stored.
        Returns:
        True if operation is succeeded.
      • makeBooklet

        public boolean makeBooklet(InputStream inputStream,
                                   PageSize pageSize,
                                   javax.servlet.http.HttpServletResponse response)

        Makes booklet from source file and stores result into HttpServletResponse.

        Parameters:
        inputStream - Input document stream.
        pageSize - Desired page size in output file.
        response - Respose object where resut will be saved.
        Returns:
        true if booklet was built successfully.
      • makeNUp

        public boolean makeNUp(InputStream inputStream,
                               int x,
                               int y,
                               PageSize pageSize,
                               javax.servlet.http.HttpServletResponse response)

        Makes N-up document and stores result into HttpServletResponse object.

        Parameters:
        inputStream - Stream of source document.
        x - Number of columns.
        y - Number of rows.
        pageSize - Page size in result file.
        response - HttpServletResponse object where result will be stored.
        Returns:
        True if operation was succeeded.
      • makeNUp

        public boolean makeNUp(String inputFile,
                               int x,
                               int y,
                               PageSize pageSize,
                               javax.servlet.http.HttpServletResponse response)

        Makes N-up document and stores result into HttpServletResponse object.

        Parameters:
        inputFile - Path to source file.
        x - Number of columns.
        y - Number of rows.
        pageSize - Page size in result file.
        response - HttpServletResponse object where result will be stored.
        Returns:
        True if operation was succeeded.
      • makeNUp

        public boolean makeNUp(String inputFile,
                               int x,
                               int y,
                               javax.servlet.http.HttpServletResponse response)

        Makes N-up document and stores result into HttpServletResponse.

        Parameters:
        inputFile - Source file name.
        x - Number of columns.
        y - Number of rows.
        response - HttpServletResponse object where result will be stored.
        Returns:
        True if operation was succeeded.
      • makeNUp

        public boolean makeNUp(InputStream inputStream,
                               int x,
                               int y,
                               javax.servlet.http.HttpServletResponse response)

        Makes N-up document and stores result into HttpServletResponse.

        Parameters:
        inputStream - Stream of input document.
        x - Number of columns.
        y - Number of rows.
        response - HttpServletResponse where result will be stored.
        Returns:
        True if operation was succeeded.
      • resizeContents

        public boolean resizeContents(String source,
                                      int[] pages,
                                      IPdfFileEditor.ContentsResizeParameters parameters,
                                      javax.servlet.http.HttpServletResponse response)

        Resizes contents of pages in document. If page is shrinked blank margins are added around the page.Result is stored into HttpServletResponse object.

        Parameters:
        source - Path to source file.
        pages - Array of pages to be resized.
        parameters - Resize parameters.
        response - HttpServletResponse object where result is saved.
        Returns:
        True if operation was succeeded.
      • resizeContents

        public boolean resizeContents(com.aspose.ms.System.IO.Stream source,
                                      int[] pages,
                                      IPdfFileEditor.ContentsResizeParameters parameters,
                                      javax.servlet.http.HttpServletResponse response)

        Resizes contents of pages in document. If page is shrinked blank margins are added around the page.Result is stored into HttpServletResponse object.

        Parameters:
        source - Stream of source file.
        pages - Array of pages to be resized.
        parameters - Resize parameters.
        response - HttpServletResponse object where result is saved.
        Returns:
        True if operation was succeeded.
      • getMergeDuplicateLayers

        public boolean getMergeDuplicateLayers()

        Optional contents of concatentated documents with equal names will be merged into one layer in resulstant document if this property is true. Else, layers with equal names will be save as different layers in resultant document.

        Specified by:
        getMergeDuplicateLayers in interface IPdfFileEditor
        Returns:
        boolean value
      • setMergeDuplicateLayers

        public void setMergeDuplicateLayers(boolean value)
        Description copied from interface: IPdfFileEditor

        Optional contents of concatentated documents with equal names will be merged into one layer in resulstant document if this property is true. Else, layers with equal names will be save as different layers in resultant document.

        Specified by:
        setMergeDuplicateLayers in interface IPdfFileEditor
        Parameters:
        value - boolean value
      • getCopyOutlines

        public boolean getCopyOutlines()

        If true then outlines will be copied.

        Returns:
        boolean value
      • setCopyOutlines

        public void setCopyOutlines(boolean value)

        If true then outlines will be copied.

        Parameters:
        value - boolean value
      • getCopyLogicalStructure

        public boolean getCopyLogicalStructure()

        If true then logical structure of the file is copied when concatenation is performed.

        Returns:
        boolean value
      • setCopyLogicalStructure

        public void setCopyLogicalStructure(boolean value)

        If true then logical structure of the file is copied when concatenation is performed.

        Parameters:
        value - boolean value
      • getMergeDuplicateOutlines

        public boolean getMergeDuplicateOutlines()

        If true, duplicate outlines are merged.

        Specified by:
        getMergeDuplicateOutlines in interface IPdfFileEditor
        Returns:
        boolean value
      • setMergeDuplicateOutlines

        public void setMergeDuplicateOutlines(boolean value)

        If true, duplicate outlines are merged.

        Specified by:
        setMergeDuplicateOutlines in interface IPdfFileEditor
        Parameters:
        value - boolean value
      • getPreserveUserRights

        public boolean getPreserveUserRights()

        If true, user rights of first document are applied to concatenated document. User rights of all other documents are ignored.

        Specified by:
        getPreserveUserRights in interface IPdfFileEditor
        Returns:
        boolean value
      • setPreserveUserRights

        public void setPreserveUserRights(boolean value)

        If true, user rights of first document are applied to concatenated document. User rights of all other documents are ignored.

        Specified by:
        setPreserveUserRights in interface IPdfFileEditor
        Parameters:
        value - boolean value
      • getIncrementalUpdates

        public boolean getIncrementalUpdates()

        If true, incremental updates are made during concatenation.

        Specified by:
        getIncrementalUpdates in interface IPdfFileEditor
        Returns:
        boolean value
      • setIncrementalUpdates

        public void setIncrementalUpdates(boolean value)

        If true, incremental updates are made during concatenation.

        Specified by:
        setIncrementalUpdates in interface IPdfFileEditor
        Parameters:
        value - boolean value
      • getOptimizeSize

        public boolean getOptimizeSize()

        Gets or sets optimization flag. Equal resource streams in resultant file are merged into one PDF object if this flag set. This allows to decrease resultant file size but may cause slower execution and larger memory requirements. Default value: false.

        Returns:
        boolean value
      • setOptimizeSize

        public void setOptimizeSize(boolean value)

        Gets or sets optimization flag. Equal resource streams in resultant file are merged into one PDF object if this flag set. This allows to decrease resultant file size but may cause slower execution and larger memory requirements. Default value: false.

        Parameters:
        value - boolean value
      • getCorruptedItems

        public PdfFileEditor.CorruptedItem[] getCorruptedItems()

        Array of encountered problems when concatenation was performed. For every corrupted document from passed to Concatenate() function new CorruptedItem entry is created. This property may be used only when CorruptedFileAction is ConcatenateIgnoringCorrupted.


         
         
         //concatenate documents and show information about corrupted documents
                      PdfFileEditor pfe = new PdfFileEditor();
                      pfe.setCorruptedFileAction( PdfFileEditor.ConcatenateCorruptedFileAction.ConcatenateIgnoringCorrupted);
                       if (pfe.getCorruptedItems().length >0)
                      {
                        for(PdfFileEditor.CorruptedItem item : pfe.getCorruptedItems())
                        {
                           System.out.println(item.getIndex() + " reason: " + item.getException());
                        }
                      }
         
        Returns:
        PdfFileEditor.CorruptedItem array
      • setCorruptedFileAction

        public void setCorruptedFileAction(int value)

        This property defines behavior when concatenating process met corrupted file. Possible values are: StopWithError and ConcatenateIgnoringCorrupted.

        Specified by:
        setCorruptedFileAction in interface IPdfFileEditor
        Parameters:
        value - ConcatenateCorruptedFileAction element
        See Also:
        PdfFileEditor.ConcatenateCorruptedFileAction
      • getOwnerPassword

        public String getOwnerPassword()

        Gets owner's password if the source input Pdf file is encrypted. This property is not implemented yet.

        Specified by:
        getOwnerPassword in interface IPdfFileEditor
        Returns:
        String object
      • setOwnerPassword

        public void setOwnerPassword(String value)

        Sets owner's password if the source input Pdf file is encrypted. This property is not implemented yet.

        Specified by:
        setOwnerPassword in interface IPdfFileEditor
        Parameters:
        value - String object
      • getAllowConcatenateExceptions

        public boolean getAllowConcatenateExceptions()

        If set to true, exceptions are thrown if error occured. Else excetion are not thrown and methods return false if failed.


         
         
          PdfFileEditor pfe = new PdfFileEditor();
          pfe.setAllowConcatenatedException ( true);
         
        Specified by:
        getAllowConcatenateExceptions in interface IPdfFileEditor
        Returns:
        Boolean value
      • setAllowConcatenateExceptions

        public void setAllowConcatenateExceptions(boolean value)

        If set to true, exceptions are thrown if error occured. Else excetion are not thrown and methods return false if failed.


         
         
          PdfFileEditor pfe = new PdfFileEditor();
          pfe.setAllowConcatenatedException ( true);
         
        Specified by:
        setAllowConcatenateExceptions in interface IPdfFileEditor
        Parameters:
        value - Boolean value
      • setConvertTo

        public void setConvertTo(int value)

        Sets PDF file format. Result file will be saved in specified file format. If this property is not specified then file will be save in default PDF format without conversion.

        Specified by:
        setConvertTo in interface IPdfFileEditor
        Parameters:
        value - PdfFormat element
        See Also:
        PdfFormat
      • getCloseConcatenatedStreams

        public boolean getCloseConcatenatedStreams()

        If set to true, streams are closed after operation.


         
         
          PdfFileEditor pfe = new PdfFileEditor();
          pfe.setCloseConcatenatedStreams ( true);
         
        Specified by:
        getCloseConcatenatedStreams in interface IPdfFileEditor
        Returns:
        boolean value
      • setCloseConcatenatedStreams

        public void setCloseConcatenatedStreams(boolean value)

        If set to true, streams are closed after operation.


         
         
          PdfFileEditor pfe = new PdfFileEditor();
          pfe.setCloseConcatenatedStreams ( true);
         
        Specified by:
        setCloseConcatenatedStreams in interface IPdfFileEditor
        Parameters:
        value - boolean value
      • getUniqueSuffix

        public String getUniqueSuffix()

        Get format of the suffix which is added to field name to make it unique when forms are concatenated. This string must contain %NUM% substring which will be replaced with numbers. For example if UniqueSuffix = "ABC%NUM%" then for field "fieldName" names will be: fieldNameABC1, fieldNameABC2, fieldNameABC3 etc.

        Specified by:
        getUniqueSuffix in interface IPdfFileEditor
        Returns:
        String object
      • setUniqueSuffix

        public void setUniqueSuffix(String value)

        Set format of the suffix which is added to field name to make it unique when forms are concatenated. This string must contain %NUM% substring which will be replaced with numbers. For example if UniqueSuffix = "ABC%NUM%" then for field "fieldName" names will be: fieldNameABC1, fieldNameABC2, fieldNameABC3 etc.


         
         
           PdfFileEditor ed = new PdfFileEditor();
           ed.setUniqueSuffix ( "_%NUM%");
         
        Specified by:
        setUniqueSuffix in interface IPdfFileEditor
        Parameters:
        value - String object
      • getKeepFieldsUnique

        public boolean getKeepFieldsUnique()

        If true then field names will be made unique when forms are concatenated. Suffixes will be added to field names, suffix template may be specified in UniqueSuffix property.

        Specified by:
        getKeepFieldsUnique in interface IPdfFileEditor
        Returns:
        boolean value
      • setKeepFieldsUnique

        public void setKeepFieldsUnique(boolean value)

        If true then field names will be made unique when forms are concatenated. Suffixes will be added to field names, suffix template may be specified in UniqueSuffix property.

        Specified by:
        setKeepFieldsUnique in interface IPdfFileEditor
        Parameters:
        value - boolean value
      • concatenate

        public boolean concatenate(String firstInputFile,
                                   String secInputFile,
                                   String outputFile)

        Concatenates two files.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         fileEditor.concatenate("file1.pdf", "file2.pdf", "outfile.pdf");
         
        Specified by:
        concatenate in interface IPdfFileEditor
        Parameters:
        firstInputFile - First file to concatenate.
        secInputFile - Second file to concatenate.
        outputFile - Output file.
        Returns:
        True if operation was succeeded.
      • concatenate

        public boolean concatenate(InputStream firstInputStream,
                                   InputStream secInputStream,
                                   OutputStream outputStream)

        Concatenates two files.

        *
         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         Stream stream1 = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read);
         Stream stream2 = new FileInputStream("file2.pdf", FileMode.Open, FileAccess.Read);
         Stream outstream = new FileInputStream("outfile.pdf", FileMode.Create, FileAccess.Write);
         fileEditor.concatenate(stream1, stream2, outstream);
         
        Specified by:
        concatenate in interface IPdfFileEditor
        Parameters:
        firstInputStream - Stream of first file.
        secInputStream - Stream of second file.
        outputStream - Stream where result file will be stored.
        Returns:
        True if operation was succeeded.
      • concatenate

        public boolean concatenate(IDocument[] src,
                                   IDocument dest)

        Concatenates documents.

        Specified by:
        concatenate in interface IPdfFileEditor
        Parameters:
        src - Array of source documents.
        dest - Destination document.
        Returns:
        True if concatenation is successful.
      • getUseDiskBuffer

        public boolean getUseDiskBuffer()

        If this option used then destination document will be saved on disk periodically and further concatenation will appllied to it as incremental updates.

        Returns:
        boolean value
      • setUseDiskBuffer

        public void setUseDiskBuffer(boolean value)

        If this option used then destination document will be saved on disk periodically and further concatenation will appllied to it as incremental updates.

        Parameters:
        value - boolean value
      • getConcatenationPacketSize

        public int getConcatenationPacketSize()

        Number of documents concatenated before new incremental update was made during concatenation when UseDiskBuffer is set to true.

        Returns:
        int value
      • setConcatenationPacketSize

        public void setConcatenationPacketSize(int value)

        Number of documents concatenated before new incremental update was made during concatenation when UseDiskBuffer is set to true.

        Parameters:
        value - int value
      • concatenate

        public boolean concatenate(String[] inputFiles,
                                   String outputFile)

        Concatenates files into one file.


         
         
          PdfFileEditor pfe = new PdfFileEditor();
          pfe.concatenate(new String[]  { "src1.pdf", "src2.pdf" }, "dest.pdf");
         
        Specified by:
        concatenate in interface IPdfFileEditor
        Parameters:
        inputFiles - Array of files to concatenate.
        outputFile - Name of output file.
        Returns:
        True if operation was succeeded.
      • concatenate

        public boolean concatenate(InputStream[] inputStream,
                                   OutputStream outputStream)

        Concatenates files


         
         
                      PdfFileEditor fileEditor = new PdfFileEditor();
                      InputStream stream1 = new FileInputStream("file1.pdf");
                      InputStream stream2 = new FileInputStream("file2.pdf");
                      OutputStream outstream = new FileOutputStream("outfile.pdf");
                      fileEditor.concatenate(new InputStream[] { stream1, stream2 } , outstream);
         
        Specified by:
        concatenate in interface IPdfFileEditor
        Parameters:
        inputStream - Array of streams to be concatenated.
        outputStream - Stream where result file will be stored.
        Returns:
        True if operation was succeeded.
      • concatenate

        public boolean concatenate(String firstInputFile,
                                   String secInputFile,
                                   String blankPageFile,
                                   String outputFile)

        Merges two Pdf documents into a new Pdf document with pages in alternate ways and fill the blank places with blank pages. e.g.: document1 has 5 pages: p1, p2, p3, p4, p5. document2 has 3 pages: p1', p2', p3'. Merging the two Pdf document will produce the result document with pages:p1, p1', p2, p2', p3, p3', p4, blankpage, p5, blankpage.


         
         
          PdfFileEditor pfe = new PdfFileEditor();
          pfe.concatenate("src1.pdf", "src2.pdf", "blank.pdf", "dest.pdf");
         
        Specified by:
        concatenate in interface IPdfFileEditor
        Parameters:
        firstInputFile - First file.
        secInputFile - Second file.
        blankPageFile - PDF file with blank page.
        outputFile - Result file.
        Returns:
        True if operation was succeeded.
      • concatenate

        public boolean concatenate(InputStream firstInputStream,
                                   InputStream secInputStream,
                                   InputStream blankPageStream,
                                   OutputStream outputStream)

        Merges two Pdf documents into a new Pdf document with pages in alternate ways and fill the blank places with blank pages. e.g.: document1 has 5 pages: p1, p2, p3, p4, p5. document2 has 3 pages: p1', p2', p3'. Merging the two Pdf document will produce the result document with pages:p1, p1', p2, p2', p3, p3', p4, blankpage, p5, blankpage.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         InputStream stream1 = new FileInputStream("file1.pdf");
         InputStream stream2 = new FileInputStream("file2.pdf");
         InputStream blank = new FileInputStream("blank.pdf");
         OutputStream outstream = new FileOutputStream("outfile.pdf");
         fileEditor.concatenate(new InputStream[] { stream1, stream2, blank } , outstream);
         
        Specified by:
        concatenate in interface IPdfFileEditor
        Parameters:
        firstInputStream - The first Pdf Stream.
        secInputStream - The second Pdf Stream.
        blankPageStream - The Pdf Stream with blank page
        outputStream - Output Pdf Stream.
        Returns:
        True if operation was succeeded.
      • append

        public boolean append(InputStream inputStream,
                              InputStream[] portStreams,
                              int startPage,
                              int endPage,
                              OutputStream outputStream)

        Appends pages, which are chosen from array of documents in portStreams. The result document includes firstInputFile and all portStreams documents pages in the range startPage to endPage.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         InputStream instream = new FileInputStream("input.pdf");
         InputStream stream1 = new FileInputStream("file1.pdf");
         InputStream stream2 = new FileInputStream("file2.pdf");
         OutputStream outstream = new FileOutputStream("outfile.pdf");
         fileEditor.append(instream, new InputStream[] { stream1, stream2}, 3, 5, outstream);
         
        Specified by:
        append in interface IPdfFileEditor
        Parameters:
        inputStream - Input Pdf stream.
        portStreams - Documents to copy pages from.
        startPage - Page starts in portStreams documents.
        endPage - Page ends in portStreams documents .
        outputStream - Output Pdf stream.
        Returns:
        True for success, or false.
      • append

        public boolean append(String inputFile,
                              String[] portFiles,
                              int startPage,
                              int endPage,
                              String outputFile)

        Appends pages, which are chosen from portFiles documents. The result document includes firstInputFile and all portFiles documents pages in the range startPage to endPage.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         fileEditor.append("input.pdf", new String[] { "file1.pdf", "file2.pdf"}, 3, 5, "outfile.pdf");
         
        Specified by:
        append in interface IPdfFileEditor
        Parameters:
        inputFile - Input Pdf file.
        portFiles - Documents to copy pages from.
        startPage - Page starts in portFiles documents.
        endPage - Page ends in portFiles documents .
        outputFile - Output Pdf document.
        Returns:
        True if operation was succeeded.
      • append

        public boolean append(String inputFile,
                              String portFile,
                              int startPage,
                              int endPage,
                              String outputFile)

        Appends pages, which are chosen from portFile within the range from startPage to endPage, in portFile at the end of firstInputFile.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         fileEditor.append("input.pdf", "file1.pdf",  3, 5, "outfile.pdf");
         
        Specified by:
        append in interface IPdfFileEditor
        Parameters:
        inputFile - Input Pdf file.
        portFile - Pages from Pdf file.
        startPage - Page starts in portFile.
        endPage - Page ends in portFile.
        outputFile - Output Pdf document.
        Returns:
        True if operation was succeeded.
      • append

        public boolean append(InputStream inputStream,
                              InputStream portStream,
                              int startPage,
                              int endPage,
                              OutputStream outputStream)

        Appends pages,which are chosen from portStream within the range from startPage to endPage, in portStream at the end of firstInputStream.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         InputStream instream = new FileInputStream("input.pdf");
         InputStream stream1 = new FileInputStream("file1.pdf");
         OutputStream outstream = new FileOutputStream("outfile.pdf");
         fileEditor.append(instream, stream1,  3, 5, "outfile.pdf");
         
        Specified by:
        append in interface IPdfFileEditor
        Parameters:
        inputStream - Input file Stream.
        portStream - Pages from Pdf file Stream.
        startPage - Page starts in portFile Stream.
        endPage - Page ends in portFile Stream.
        outputStream - Output Pdf file Stream.
        Returns:
        True for success, or false.
      • insert

        public boolean insert(String inputFile,
                              int insertLocation,
                              String portFile,
                              int startPage,
                              int endPage,
                              String outputFile)

        Inserts pages from an other file into the Pdf file at a position.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.insert("file1.pdf", 1, "file2.pdf", 2, 6, "out.pdf");
         
        Specified by:
        insert in interface IPdfFileEditor
        Parameters:
        inputFile - Input Pdf file.
        insertLocation - Position in input file.
        portFile - The porting Pdf file.
        startPage - Start position in portFile.
        endPage - End position in portFile.
        outputFile - Output Pdf file.
        Returns:
        True for success, or false.
      • insert

        public boolean insert(InputStream inputStream,
                              int insertLocation,
                              InputStream portStream,
                              int startPage,
                              int endPage,
                              OutputStream outputStream)

        Inserts pages from an other file into the input Pdf file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream sourceStream = new FileInputStream("file1.pdf");
         InputStream insertedStream = new FileInputStream("file2.pdf");
         OutputStream outStream = new FileOutputStream("out.pdf");
         pfe.insert(sourceStream, 1, insertedStream, 2, 6, outStream);
         
        Specified by:
        insert in interface IPdfFileEditor
        Parameters:
        inputStream - Input Stream of Pdf file.
        insertLocation - Insert position in input file.
        portStream - Stream of Pdf file for pages.
        startPage - From which page to start.
        endPage - To which page to end.
        outputStream - Output Stream.
        Returns:
        True for success, or false.
      • insert

        public boolean insert(String inputFile,
                              int insertLocation,
                              String portFile,
                              int[] pageNumber,
                              String outputFile)

        Inserts pages from an other file into the input Pdf file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream sourceStream = new FileInputStream("file1.pdf");
         InputStream insertedStream = new FileInputStream("file2.pdf");
         OutputStream outStream = new FileOutputStream("out.pdf");
         pfe.insert(sourceStream, 1, insertedStream, 2, 6, outStream);
         
        Specified by:
        insert in interface IPdfFileEditor
        Parameters:
        inputFile - Input Pdf file.
        insertLocation - Insert position in input file.
        portFile - Pages from the Pdf file.
        pageNumber - The page number of the ported in portFile.
        outputFile - Output Pdf file.
        Returns:
        True for success, or false.
      • insert

        public boolean insert(InputStream inputStream,
                              int insertLocation,
                              InputStream portStream,
                              int[] pageNumber,
                              OutputStream outputStream)

        Inserts pages from an other file into the input Pdf file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream sourceStream = new FileInputStream("file1.pdf");
         InputStream insertedStream = new FileInputStream("file2.pdf");
         OutputStream outStream = new FileOutputStream("out.pdf");
         pfe.Insert(sourceStream, 1, insertedStream, new int[] { 3, 4, 5}, outStream);
         
        Specified by:
        insert in interface IPdfFileEditor
        Parameters:
        inputStream - Input Stream of Pdf file.
        insertLocation - Insert position in input file.
        portStream - Stream of Pdf file for pages.
        pageNumber - The page number of the ported in portFile.
        outputStream - Output Stream.
        Returns:
        True if operation was succeeded.
      • delete

        public boolean delete(String inputFile,
                              int[] pageNumber,
                              String outputFile)

        Deletes pages specified by number array from input file, saves as a new Pdf file.


         
         
          PdfFileEditor pfe = new PdfFileEditor();
          pfe.delete("input.pdf", new int[] { 2, 3 }, "out.pdf");
          
        Specified by:
        delete in interface IPdfFileEditor
        Parameters:
        inputFile - Input file path.
        pageNumber - Index of page out of the input file.
        outputFile - Output file path.
        Returns:
        True if operation was succeeded.
      • delete

        public boolean delete(InputStream inputStream,
                              int[] pageNumber,
                              OutputStream outputStream)

        Deletes pages specified by number array from input file, saves as a new Pdf file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream intputStream = new FileInputStream("input.pdf");
         OutputStream outputStream = new FileOutputStream("output.pdf");
         pfe.delete(inputStream, new int[] { 2, 3 }, outputStream);
         
        Specified by:
        delete in interface IPdfFileEditor
        Parameters:
        inputStream - Input file Stream.
        pageNumber - Index of page out of the input file.
        outputStream - Output file stream.
        Returns:
        True for success, or false.
      • extract

        public boolean extract(String inputFile,
                               int startPage,
                               int endPage,
                               String outputFile)

        Extracts pages from input file,saves as a new Pdf file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.extract("input.pdf", 3, 7, "output.pdf");
         
        Specified by:
        extract in interface IPdfFileEditor
        Parameters:
        inputFile - Input Pdf file path.
        startPage - Start page number.
        endPage - End page number.
        outputFile - Output Pdf file path.
        Returns:
        True for success, or false.
      • extract

        public boolean extract(String inputFile,
                               int[] pageNumber,
                               String outputFile)

        Extracts pages specified by number array, saves as a new PDF file.


         
         
          PdfFileEditor pfe = new PdfFileEditor();
          pfe.extract("input.pdf", new int[] { 3, 5, 7 }, "output.pdf");
          
        Specified by:
        extract in interface IPdfFileEditor
        Parameters:
        inputFile - Input file path.
        pageNumber - Index of page out of the input file.
        outputFile - Output file path.
        Returns:
        True if operation was succeeded.
      • extract

        public boolean extract(InputStream inputStream,
                               int startPage,
                               int endPage,
                               OutputStream outputStream)

        Extracts pages from input file,saves as a new Pdf file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream sourceStream = new FileInputStream("file1.pdf");
         OutputStream outStream = new FileOutputStream("out.pdf");
         pfe.extract(sourceStream, 1, 3, 6, outStream);
         
        Specified by:
        extract in interface IPdfFileEditor
        Parameters:
        inputStream - Input file Stream.
        startPage - Start page number.
        endPage - End page number.
        outputStream - Output Pdf file Stream.
        Returns:
        True for success, or false.
      • extract

        public boolean extract(InputStream inputStream,
                               int[] pageNumber,
                               OutputStream outputStream)

        Extracts pages specified by number array, saves as a new Pdf file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream sourceStream = new FileInputStream("file1.pdf");
         OutputStream outStream = new FileOutputStream("out.pdf");
         pfe.extract(sourceStream, new int[] { 3, 5, 8 }, outStream);
         
        Specified by:
        extract in interface IPdfFileEditor
        Parameters:
        inputStream - Input file Stream.
        pageNumber - Index of page out of the input file.
        outputStream - Output file stream.
        Returns:
        True for success, or false.
      • splitFromFirst

        public boolean splitFromFirst(String inputFile,
                                      int location,
                                      String outputFile)

        Splits Pdf file from first page to specified location,and saves the front part as a new file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.splitFromFirst("input.pdf", 5, "out.pdf");
         
        Specified by:
        splitFromFirst in interface IPdfFileEditor
        Parameters:
        inputFile - Source Pdf file.
        location - The splitting point.
        outputFile - Output Pdf file.
        Returns:
        True for success, or false.
      • splitFromFirst

        public boolean splitFromFirst(InputStream inputStream,
                                      int location,
                                      OutputStream outputStream)

        Splits from start to specified location,and saves the front part in output Stream.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream sourceStream = new FileInputStream("file1.pdf");
         OutputStream outStream = new FileOutputStream("out.pdf");
         pfe.splitFromFirst(sourceStream, 5, outStream);
         

        The streams are NOT closed after this operation.
        Specified by:
        splitFromFirst in interface IPdfFileEditor
        Parameters:
        inputStream - Source Pdf file Stream.
        location - The splitting point.
        outputStream - Output file Stream.
        Returns:
        True for success, or false.
      • splitToEnd

        public boolean splitToEnd(String inputFile,
                                  int location,
                                  String outputFile)

        Splits from location, and saves the rear part as a new file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.splitToEnd("input.pdf", 5, "out.pdf");
         
        Specified by:
        splitToEnd in interface IPdfFileEditor
        Parameters:
        inputFile - Source Pdf file.
        location - The splitting position.
        outputFile - Output Pdf file path.
        Returns:
        True for success, or false.
      • splitToEnd

        public boolean splitToEnd(InputStream inputStream,
                                  int location,
                                  OutputStream outputStream)

        Splits from specified location, and saves the rear part as a new file Stream.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream sourceStream = new FileInputStream("file1.pdf");
         OutputStream outStream = new FileOutputStream("out.pdf");
         pfe.splitToEnd(sourceStream, 5, outStream);
         

        The streams are NOT closed after this operation unless CloseConcatedStreams is specified.
        Specified by:
        splitToEnd in interface IPdfFileEditor
        Parameters:
        inputStream - Source Pdf file Stream.
        location - The splitting position.
        outputStream - Output Pdf file Stream.
        Returns:
        True for success, or false.
      • makeBooklet

        public boolean makeBooklet(String inputFile,
                                   String outputFile)

        Makes booklet from the input file to output file.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.makeBooklet("input.pdf", "output.pdf");
         
        Specified by:
        makeBooklet in interface IPdfFileEditor
        Parameters:
        inputFile - Input pdf file path and name.
        outputFile - Output pdf file path and name.
        Returns:
        boolean - True for success, or false.
      • makeBooklet

        public boolean makeBooklet(InputStream inputStream,
                                   OutputStream outputStream)

        Makes booklet from the InputStream to outputStream.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream inputStream = new FileInputStream("input.pdf");
         OutputStream outputStream = new FileOutputStream("output.pdf");
         pfe.makeBooklet(inputStream, outputStream);
         
        Specified by:
        makeBooklet in interface IPdfFileEditor
        Parameters:
        inputStream - Input pdf stream.
        outputStream - output pdf stream.
        Returns:
        True if operation was succeeded.
      • makeBooklet

        public boolean makeBooklet(String inputFile,
                                   String outputFile,
                                   PageSize pageSize)

        Makes booklet from the inputFile to outputFile.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.makeBooklet("input.pdf", "output.pdf", PageSize.A4);
         
        Specified by:
        makeBooklet in interface IPdfFileEditor
        Parameters:
        inputFile - Input pdf file path and name.
        outputFile - Output pdf file path and name.
        pageSize - The page size of the output pdf file.
        Returns:
        True if operation is succeeded.
      • makeBooklet

        public boolean makeBooklet(InputStream inputStream,
                                   OutputStream outputStream,
                                   PageSize pageSize)

        Makes booklet from the input stream and save result into output stream.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream inputStream = new FileInputStream("input.pdf");
         OutputStream outputStream = new FileOutputStream("output.pdf");
         pfe.makeBooklet(inputStream, outputStream, PageSize.A4);
         
        Specified by:
        makeBooklet in interface IPdfFileEditor
        Parameters:
        inputStream - Input PDF stream.
        outputStream - output pdf stream.
        pageSize - The page size of the output pdf file.
        Returns:
        True if operation was succeeded.
      • makeBooklet

        public boolean makeBooklet(String inputFile,
                                   String outputFile,
                                   int[] leftPages,
                                   int[] rightPages)

        Makes customized booklet from the firstInputFile to outputFile.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.makeBooklet("input.pdf", "output.pdf", new int[] { 2, 4, 6 }, new int[] 1, 3, 5, 7 });
         
        Specified by:
        makeBooklet in interface IPdfFileEditor
        Parameters:
        inputFile - The input file.
        outputFile - Output pdf file path and name.
        leftPages - The left pages of the booklet.
        rightPages - The right pages of the booklet.
        Returns:
        boolean - True for success, or false.
      • makeBooklet

        public boolean makeBooklet(InputStream inputStream,
                                   OutputStream outputStream,
                                   int[] leftPages,
                                   int[] rightPages)

        Makes customized booklet from the firstInputStream to outputStream.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream inputStream = new FileInputStream("input.pdf");
         OutputStream outputStream = new FileOutputStream("output.pdf");
         pfe.makeBooklet(inputStream, outputStream, new int[] { 2, 4, 6 }, new int[] 1, 3, 5, 7 });
         
        Specified by:
        makeBooklet in interface IPdfFileEditor
        Parameters:
        inputStream - The input stream.
        outputStream - output pdf stream.
        leftPages - The left pages.
        rightPages - The right pages.
        Returns:
        boolean - True for success, or false.
      • makeBooklet

        public boolean makeBooklet(String inputFile,
                                   String outputFile,
                                   PageSize pageSize,
                                   int[] leftPages,
                                   int[] rightPages)

        Makes customized booklet from the firstInputFile to outputFile.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.makeBooklet("input.pdf", "output.pdf", PageSize.A4, new int[] { 2, 4, 6 }, new int[] 1, 3, 5, 7 });
         
        Specified by:
        makeBooklet in interface IPdfFileEditor
        Parameters:
        inputFile - The input file.
        outputFile - Output pdf file path and name.
        pageSize - The page size of the output pdf file.
        leftPages - The left pages.
        rightPages - The right pages.
        Returns:
        boolean - True for success, or false.
      • makeBooklet

        public boolean makeBooklet(InputStream inputStream,
                                   OutputStream outputStream,
                                   PageSize pageSize,
                                   int[] leftPages,
                                   int[] rightPages)

        Makes booklet from the firstInputStream to outputStream.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream inputStream = new FileInputStream("input.pdf");
         OutputStream outputStream = new FileOutputStream("output.pdf");
         pfe.makeBooklet(inputStream, outputStream, PageSize.A4, new int[] { 2, 4, 6 }, new int[] 1, 3, 5, 7 });
         
        Specified by:
        makeBooklet in interface IPdfFileEditor
        Parameters:
        inputStream - The input stream.
        outputStream - output pdf stream.
        pageSize - The page size of the output pdf file.
        leftPages - The left pages.
        rightPages - The right pages.
        Returns:
        boolean - True for success, or false.
      • makeNUp

        public boolean makeNUp(String inputFile,
                               String outputFile,
                               int x,
                               int y)

        Makes N-Up document from the firstInputFile to outputFile.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.makeNUp("input.pdf", "output.pdf", 3, 3);
         
        Specified by:
        makeNUp in interface IPdfFileEditor
        Parameters:
        inputFile - Input pdf file path and name.
        outputFile - Output pdf file path and name.
        x - Number of columns.
        y - Number of rows.
        Returns:
        boolean - True for success, or false.
      • makeNUp

        public boolean makeNUp(InputStream inputStream,
                               OutputStream outputStream,
                               int x,
                               int y)

        Makes N-Up document from the input stream and saves result into output stream.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream inputStream = new FileInputStream("input.pdf");
         OutputStream outputStream = new FileOutputStream("output.pdf");
         pfe.makeNUp(inputStream, outputStream, 3, 3);
         
        Specified by:
        makeNUp in interface IPdfFileEditor
        Parameters:
        inputStream - Input pdf stream.
        outputStream - Output pdf stream.
        x - Number of columns.
        y - Number of rows.
        Returns:
        boolean - True for success, or false.
      • makeNUp

        public boolean makeNUp(InputStream inputStream,
                               OutputStream outputStream,
                               int x,
                               int y,
                               PageSize pageSize)

        Makes N-Up document from the first input stream to output stream.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream inputStream = new FileInputStream("input.pdf");
         OutputStream outputStream = new FileInputStream("output.pdf");
         pfe.MakeNUp(inputStream, outputStream, 3, 3, PageSize.A4);
         
        Specified by:
        makeNUp in interface IPdfFileEditor
        Parameters:
        inputStream - Input pdf stream.
        outputStream - Output pdf stream.
        x - Number of columns.
        y - Number of rows.
        pageSize - The page size of the output pdf file.
        Returns:
        True if operation was succeeded.
      • makeNUp

        public boolean makeNUp(String firstInputFile,
                               String secondInputFile,
                               String outputFile)

        Makes N-Up document from the two input PDF files to outputFile. Each page of outputFile will contain two pages, one page is from the first input file and another is from the second input file. The two pages are piled up horizontally.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.makeNUp("input1.pdf", "input2.pdf", "output.pdf");
         
        Specified by:
        makeNUp in interface IPdfFileEditor
        Parameters:
        firstInputFile - first input file.
        secondInputFile - second input file.
        outputFile - Output pdf file path and name.
        Returns:
        boolean - True for success, or false.
      • makeNUp

        public boolean makeNUp(InputStream firstInputStream,
                               InputStream secondInputStream,
                               OutputStream outputStream)

        Makes N-Up document from the two input PDF streams to outputStream.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream input1 = new FileInputStream("input1.pdf");
         InputStream input2 = new FileInputStream("input2.pdf");
         OutputStream output = new FileOutputStream("output.pdf");
         pfe.makeNUp(input1, input2, output);
         
        Specified by:
        makeNUp in interface IPdfFileEditor
        Parameters:
        firstInputStream - first input stream.
        secondInputStream - second input stream.
        outputStream - Output pdf stream.
        Returns:
        boolean - True for success, or false.
      • makeNUp

        public boolean makeNUp(String[] inputFiles,
                               String outputFile,
                               boolean isSidewise)

        Makes N-Up document from the multi input PDF files to outputFile. Each page of outputFile will contain multi pages, which are combination with pages in the input files of the same page number. The multi pages piled up horizontally if isSidewise is true and piled up vertically if isSidewise is false.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.makeNUp(new string[] { "input1.pdf", "input2.pdf", "input3.pdf" }, "output.pdf", false);
         
        Specified by:
        makeNUp in interface IPdfFileEditor
        Parameters:
        inputFiles - Input Pdf files.
        outputFile - Output pdf file path and name.
        isSidewise - Piled up way, true for horizontally and flase for vertically.
        Returns:
        boolean - True for success, or false.
      • makeNUp

        public boolean makeNUp(InputStream[] inputStreams,
                               OutputStream outputStream,
                               boolean isSidewise)

        Makes N-Up document from the multi input PDF streams to outputStream. Each page of outputStream will contain multi pages, which are combination with pages in the input streams of the same page number. The multi-pages piled up horizontally if isSidewise is true and piled up vertically if isSidewise is false.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         InputStream stream1 = new FileInputStream("input1.pdf");
         InputStream stream2 = new FileInputStream("input2.pdf");
         InputStream stream3 = new FileInputStream("input3.pdf");
         OutputStream output = new FileOutputStream("output.pdf");
         pfe.makeNUp(new InputStream[] { stream1, stream2, stream3 }, output, false);
         
        Specified by:
        makeNUp in interface IPdfFileEditor
        Parameters:
        inputStreams - Input Pdf streams.
        outputStream - Output pdf stream.
        isSidewise - Piled up way, true for horizontally and flase for vertically
        Returns:
        boolean - True for success, or false.
      • makeNUp

        public boolean makeNUp(String inputFile,
                               String outputFile,
                               int x,
                               int y,
                               PageSize pageSize)

        Makes N-Up document from the input file to outputFile.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.makeNUp("input.pdf", "output.pdf", 3, 3, PageSize.A4);
         
        Specified by:
        makeNUp in interface IPdfFileEditor
        Parameters:
        inputFile - Input pdf file path and name.
        outputFile - Output pdf file path and name.
        x - Number of columns.
        y - Number of rows.
        pageSize - The page size of the output pdf file.
        Returns:
        boolean - True for success, or false.
      • splitToPages

        public ByteArrayInputStream[] splitToPages(String inputFile)

        Splits the PDF file into single-page documents.

        Specified by:
        splitToPages in interface IPdfFileEditor
        Parameters:
        inputFile - Input PDF file name.
        Returns:
        Output PDF streams, each stream buffers a single-page PDF document.
      • splitToPages

        public void splitToPages(String inputFile,
                                 String fileNameTemplate)

        Split the Pdf file into single-page documents and saves it into specified path. Path is specifield by field name temaplate.

        Specified by:
        splitToPages in interface IPdfFileEditor
        Parameters:
        inputFile - Input file name.
        fileNameTemplate - Template of resultant file name. Must contain %NUM% which is replaced with page number. For example, if c:/dir/page%NUM%.pdf is specified, resultant files will have the following names: c:/dir/page1.pdf, c:/dir/page2.pdf etc.
      • splitToPages

        public void splitToPages(InputStream inputStream,
                                 String fileNameTemplate)

        Split the Pdf file into single-page documents and saves it into specified path. Path is specifield by field name temaplate.

        Specified by:
        splitToPages in interface IPdfFileEditor
        Parameters:
        inputStream - Stream of the soruce document.
        fileNameTemplate - Template of resultant file name. Must contain %NUM% which is replaced with page number. For example, if c:/dir/page%NUM%.pdf is specified, resultant files will have the following names: c:/dir/page1.pdf, c:/dir/page2.pdf etc.
      • splitToPages

        public ByteArrayInputStream[] splitToPages(InputStream inputStream)

        Splits the Pdf file into single-page documents.

        Specified by:
        splitToPages in interface IPdfFileEditor
        Parameters:
        inputStream - Input Pdf stream.
        Returns:
        Array of memory streams which contain pages of the document.
      • splitToBulks

        public ByteArrayInputStream[] splitToBulks(String inputFile,
                                                   int[][] numberOfPage)

        Splits the Pdf file into several documents.The documents can be single-page or multi-pages.

        Specified by:
        splitToBulks in interface IPdfFileEditor
        Parameters:
        inputFile - Input PDF file.
        numberOfPage - Array which contains array of double elements, which is start and end pages of document.
        Returns:
        Output PDF streams, each stream buffers a PDF document.
      • splitToBulks

        public ByteArrayInputStream[] splitToBulks(InputStream inputStream,
                                                   int[][] numberOfPage)

        Splits the Pdf file into several documents.The documents can be single-page or multi-pages.

        Specified by:
        splitToBulks in interface IPdfFileEditor
        Parameters:
        inputStream - Input PDF stream.
        numberOfPage - The start page and the end page of each document.
        Returns:
        Output PDF streams, each stream buffers a PDF document.
      • getLastException

        public Exception getLastException()

        Gets last occured exception. May be used to check the reason of failure when AllowconcatenateExceptions = false.


         
         
          PdfFileEditor pfe = new PdfFileEditor();
            pfe.allowConcatenateExceptions = false;
            if (!pfe.concatenate("file1.pdf", "file2.pdf", "file3.pdf"))
            {
               System.out.println("Error occured:");
               if (pfe.getLastException() != null)
               {
                  System.out.println(pfe.getLastException().getMessage());
                  if (pfe.getLastException().getInnerException() != null)
                    System.out.println(pfe.getLastException().getInnerException().getMessage);
               }
            }
         
        Specified by:
        getLastException in interface IPdfFileEditor
        Returns:
        java.lang.Exception object
      • resizeContents

        public boolean resizeContents(InputStream source,
                                      OutputStream destination,
                                      int[] pages,
                                      IPdfFileEditor.ContentsResizeParameters parameters)

        Resizes contents of pages of the document.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
                      InputStream src = new FileInputStream("input.pdf");
                      OutputStream dest = new fileOutputStream("output.pdf");
                      APdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
                          //left margin = 10% of page width
                          PdfFileEditor.ContentsResizeValue.percents(10),
                          //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
                          null,
                          //right margin is 10% of page 
                          PdfFileEditor.ContentsResizeValue.percents(10),
                          //top margin = 10% of height
                          PdfFileEditor.ContentsResizeValue.percents(10),
                         //new contents height is calculated automatically (similar to width)
                          null,
                          //bottom margin is 10%
                          PdfFileEditor.ContentsResizeValue.percents(10)
                             );
                      fileEditor.resizeContents(src, dest, new int[] { 1, 2, 3}, parameters);
                      dest.close();
         
        Parameters:
        source - Stream with source document.
        destination - Stream with the destination document.
        pages - Array of page indexes.
        parameters - Resize parameters.
        Returns:
        Returns true if success.
      • resizeContents

        public boolean resizeContents(InputStream source,
                                      OutputStream destination,
                                      int[] pages,
                                      double newWidth,
                                      double newHeight)

        Resizes contents of document pages. Shrinks contents of page and adds margins. New size of contents is specified in default space units.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         InputStream src = new FileInputStream("input.pdf");
         OutputStream dest = new FileOutputStream("output.pdf");
         fileEditor.resizeContents(src, dest, 
         //resize all pages of document
         null, 
         //new contents width = 200
         200, 
         //new contents height = 300
         300);
         // rest area of page will be empty
         
        Specified by:
        resizeContents in interface IPdfFileEditor
        Parameters:
        source - Stream which contains source document.
        destination - Stream where resultant document will be saved.
        pages - Array of page indexes. If null then all document pages will be processed.
        newWidth - New width of page contents in default space units.
        newHeight - New height of page contents in default space units.
        Returns:
        True if resize was successful.
      • resizeContentsPct

        public boolean resizeContentsPct(InputStream source,
                                         OutputStream destination,
                                         int[] pages,
                                         double newWidth,
                                         double newHeight)

        Resizes contents of document pages. Shrinks contents of page and adds margins. New contents size is specified in percents.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         InputStream src = new FileInputStream("input.pdf");
         OutputStream dest = new FileOutputStream("output.pdf");
         fileEditor.resizePct(src, dest, 
         //resize all pages of document
         null, 
         //new contents width = 60% of initial size
         60, 
         //new contents height = 60% of initial size
         60);
         // Rest area of page will be empty (page margins).  Size of left and right margins is (100% - 60%) / 2 = 20%
         // The same for top and bottom margins.
         
        Specified by:
        resizeContentsPct in interface IPdfFileEditor
        Parameters:
        source - Stream which contains source document.
        destination - Stream where resultant document will be saved.
        pages - Array of page indexes. If null then all document pages will be processed.
        newWidth - New width of page contents in percents.
        newHeight - New height of page contents in percetns.
        Returns:
        true if resized sucessfully.
      • addMargins

        public boolean addMargins(InputStream source,
                                  OutputStream destination,
                                  int[] pages,
                                  double leftMargin,
                                  double rightMargin,
                                  double topMargin,
                                  double bottomMargin)

        Resizes page contents and add specifed margins. Margins are specified in default space units.


         
         
          PdfFileEditor fileEditor = new PdfFileEditor();
          InputStream src = new FileInputStream("input.pdf", FileMode.Open);
          OutputStream dest = new FileOutputStream("output.pdf", FileMode.Create);
          fileEditor.addMargins(src, dest, 
              //process pages 1, 2, 3
              new int[] { 1, 2, 3}, 
              //left margin is 10 units
              10, 
              //right margin is 5 units
              5, 
              //top margin is 5 units
              5, 
              //bottom margin is 5 units
              5);
              dest.Close();
         
        Specified by:
        addMargins in interface IPdfFileEditor
        Parameters:
        source - Stream which contains source document.
        destination - Stream where resultant document will be saved.
        pages - Array of page indexes. If null then all document pages will be processed.
        leftMargin - Left margin.
        rightMargin - Right margin.
        topMargin - Top margin.
        bottomMargin - Bottom margin.
        Returns:
        true if operation was successful.
      • addMarginsPct

        public boolean addMarginsPct(InputStream source,
                                     OutputStream destination,
                                     int[] pages,
                                     double leftMargin,
                                     double rightMargin,
                                     double topMargin,
                                     double bottomMargin)

        Resizes page contents and add specified margins. Margins are specified in percents of intitial page size.


         
         
          PdfFileEditor fileEditor = new PdfFileEditor();
          InputStream src = new FileInputStream("input.pdf", FileMode.Open);
          OutputStream dest = new FileOutputStream("output.pdf", FileMode.Create);
          fileEditor.addMarginsPct(src, dest, 
              //process pages 1, 2, 3
              new int[] { 1, 2, 3}, 
              //left margin is 15% of page width 
              15, 
              //right margin is 10% of page width
              10, 
              //top margin is 20% of page width
              20, 
              //bottom margin is 5% of page width
              5);
              dest.Close();
         
        Specified by:
        addMarginsPct in interface IPdfFileEditor
        Parameters:
        source - Stream which contains source document.
        destination - Stream where resultant document will be saved.
        pages - Array of page indexes. If null then all document pages will be processed.
        leftMargin - Left margin in percents of initial page size.
        rightMargin - Right margin in percents of initial page size.
        topMargin - Top margin in percents of initial page size.
        bottomMargin - Bottom margin in percents of initial page size.
        Returns:
        true if action was performed successfully.
      • resizeContents

        public boolean resizeContents(String source,
                                      String destination,
                                      int[] pages,
                                      double newWidth,
                                      double newHeight)

        Resizes contents of document pages. Shrinks contents of page and adds margins. New size of contents is specified in default space units.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         fileEditor.resizeContents("input.pdf", "output.pdf", 
         //resize all pages of document
         null, 
         //new contents width = 200
         200, 
         //new contents height = 300
         300);
         // rest area of page will be empty
         
        Specified by:
        resizeContents in interface IPdfFileEditor
        Parameters:
        source - Path to source document.
        destination - Path where resultant document will be saved.
        pages - Array of page indexes. If null then all document pages will be processed.
        newWidth - New width of page contents in default space units.
        newHeight - New height of page contents in default space units.
        Returns:
        true if resize was successful.
      • resizeContentsPct

        public boolean resizeContentsPct(String source,
                                         String destination,
                                         int[] pages,
                                         double newWidth,
                                         double newHeight)

        Resizes contents of document pages. Shrinks contents of page and adds margins. New contents size is specified in percents.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         fileEditor.resizePct("input.pdf", "output.pdf",
         //resize all pages of document
         null, 
         //new contents width = 60% of initial size
         60, 
         //new contents height = 60% of initial size
         60);
         // Rest area of page will be empty (page margins).  Size of left and right margins is (100% - 60%) / 2 = 20%
         // The same for top and bottom margins.
         
        Specified by:
        resizeContentsPct in interface IPdfFileEditor
        Parameters:
        source - Path to source document.
        destination - Path where resultant document will be saved.
        pages - Array of page indexes. If null then all document pages will be processed.
        newWidth - New width of page contents in percents.
        newHeight - New height of page contents in percetns.
        Returns:
        true if resize was successful.
      • addMargins

        public boolean addMargins(String source,
                                  String destination,
                                  int[] pages,
                                  double leftMargin,
                                  double rightMargin,
                                  double topMargin,
                                  double bottomMargin)

        Resizes page contents and add specifed margins. Margins are specified in default space units.


         
         
          PdfFileEditor fileEditor = new PdfFileEditor();
          fileEditor.addMargins("input.pdf", "output.pdf", 
              //process pages 1, 2, 3
              new int[] { 1, 2, 3}, 
              //left margin is 10 units
              10, 
              //right margin is 5 units
              5, 
              //top margin is 5 units
              5, 
              //bottom margin is 5 units
              5);
         
        Specified by:
        addMargins in interface IPdfFileEditor
        Parameters:
        source - Path to source document.
        destination - Path where resultant document will be saved.
        pages - Array of page indexes. If null then all document pages will be processed.
        leftMargin - Left margin.
        rightMargin - Right margin.
        topMargin - Top margin.
        bottomMargin - Bottom margin.
        Returns:
        true if resize was successful.
      • addMarginsPct

        public boolean addMarginsPct(String source,
                                     String destination,
                                     int[] pages,
                                     double leftMargin,
                                     double rightMargin,
                                     double topMargin,
                                     double bottomMargin)

        Resizes page contents and add specified margins. Margins are specified in percents of intitial page size.


         
         
          PdfFileEditor fileEditor = new PdfFileEditor();
          fileEditor.addMarginsPct("input.pdf", "output.pdf", 
              //process pages 1, 2, 3
              new int[] { 1, 2, 3}, 
              //left margin is 15% of page width 
              15, 
              //right margin is 10% of page width
              10, 
              //top margin is 20% of page width
              20, 
              //bottom margin is 5% of page width
              5);
         
        Specified by:
        addMarginsPct in interface IPdfFileEditor
        Parameters:
        source - Path to source document.
        destination - Path where resultant document will be saved.
        pages - Array of page indexes. If null then all document pages will be processed.
        leftMargin - Left margin in percents of initial page size.
        rightMargin - Right margin in percents of initial page size.
        topMargin - Top margin in percents of initial page size.
        bottomMargin - Bottom margin in percents of initial page size.
        Returns:
        true if resize was successful
      • resizeContents

        public boolean resizeContents(String source,
                                      String destination,
                                      int[] pages,
                                      IPdfFileEditor.ContentsResizeParameters parameters)

        Resizes contents of pages in document. If page is shrinked blank margins are added around the page.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         APdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
             //left margin = 10% of page width
             PdfFileEditor.ContentsResizeValue.percents(10),
             //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
             null,
             //right margin is 10% of page 
             PdfFileEditor.ContentsResizeValue.percents(10),
             //top margin = 10% of height
             PdfFileEditor.ContentsResizeValue.percents(10),
             //new contents height is calculated automatically (similar to width)
             null,
             //bottom margin is 10%
             PdfFileEditor.ContentsResizeValue.percents(10)
                );
         fileEditor.ResizeContents("input.pdf", "output.pdf", new int[] { 1, 2,.3}, parameters);
         
        Parameters:
        source - Source document path.
        destination - Destination document path.
        pages - Array of page indexes (page index starts from 1).
        parameters - Parameters of page resize.
        Returns:
        trure if resize was successful.
      • resizeContents

        public void resizeContents(IDocument source,
                                   int[] pages,
                                   IPdfFileEditor.ContentsResizeParameters parameters)

        Resizes pages of document. Blank margins are added around of shrinked page.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         Document doc = new Document("input.pdf");
         APdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
             //left margin = 10% of page width
             PdfFileEditor.ContentsResizeValue.percents(10),
             //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
             null,
             //right margin is 10% of page 
             PdfFileEditor.ContentsResizeValue.percents(10),
             //top margin = 10% of height
             PdfFileEditor.ContentsResizeValue.percents(10),
             //new contents height is calculated automatically (similar to width)
             null,
             //bottom margin is 10%
             PdfFileEditor.ContentsResizeValue.percents(10)
                );
         fileEditor.resizeContents(doc, new int[] { 1, 2,.3}, parameters);
         doc.save("output.pdf");
         
        Parameters:
        source - Source document.
        pages - List of page indexes.
        parameters - Resize parameters.
      • resizeContents

        public void resizeContents(Document source,
                                   IPdfFileEditor.ContentsResizeParameters parameters)

        Resizes pages of document. Blank margins are added around of shrinked page.


         
         
         PdfFileEditor fileEditor = new PdfFileEditor();
         Document src = new Document("input.pdf");
         Document dest = new Document();
         APdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
             //left margin = 10% of page width
             PdfFileEditor.ContentsResizeValue.percents(10),
             //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
             null,
             //right margin is 10% of page 
             PdfFileEditor.ContentsResizeValue.percents(10),
             //top margin = 10% of height
             PdfFileEditor.ContentsResizeValue.percents(10),
             //new contents height is calculated automatically (similar to width)
             null,
             //bottom margin is 10%
             PdfFileEditor.ContentsResizeValue.percents(10)
                );
         fileEditor.resizeContents(doc, parameters);
         dest.save("output.pdf");
         
         
        Parameters:
        source - Source document.
        parameters - Resize parameters.
      • getContentDisposition

        public int getContentDisposition()

        Gets how content will be stored when result of operation is stored into HttpServletResponse object. Possible value: inline / attachment. Default: inline.

        Specified by:
        getContentDisposition in interface IPdfFileEditor
        Returns:
        ContentDisposition element
        See Also:
        ContentDisposition
      • setContentDisposition

        public void setContentDisposition(int value)

        Sets how content will be stored when result of operation is stored into HttpServletResponse object. Possible value: inline / attachment. Default: inline.

        Specified by:
        setContentDisposition in interface IPdfFileEditor
        Parameters:
        value - ContentDisposition element
        See Also:
        ContentDisposition
      • getSaveOptions

        public SaveOptions getSaveOptions()

        Gets or sets save options when result is stored as HttpServletResponse. Default value: PdfSaveOptions.

        Specified by:
        getSaveOptions in interface IPdfFileEditor
        Returns:
        SaveOptions object
      • setSaveOptions

        public void setSaveOptions(SaveOptions value)

        Sets save options when result is stored as HttpServletResponse. Default value: PdfSaveOptions.

        Specified by:
        setSaveOptions in interface IPdfFileEditor
        Parameters:
        value - SaveOptions object
      • getAttachmentName

        public String getAttachmentName()

        Gets name of attachment when result of operation is stored into HttpServletResponse objects as attachment.

        Specified by:
        getAttachmentName in interface IPdfFileEditor
        Returns:
        string value
      • setAttachmentName

        public void setAttachmentName(String value)

        Sets name of attachment when result of operation is stored into HttpServletResponse objects as attachment.

        Specified by:
        setAttachmentName in interface IPdfFileEditor
        Parameters:
        value - string value
      • addPageBreak

        public void addPageBreak(IDocument src,
                                 IDocument dest,
                                 PdfFileEditor.PageBreak[] pageBreaks)

        Adds page breaks into document pages.

        Parameters:
        src - Source document.
        dest - Destination document.
        pageBreaks - Array of PageBreak objects which describe places of page breaks.
      • addPageBreak

        public void addPageBreak(String src,
                                 String dest,
                                 PdfFileEditor.PageBreak[] pageBreaks)

        Adds page breaks into document pages.

        Parameters:
        src - Path to source document.
        dest - Path to destination document.
        pageBreaks - Array of PageBreak object describing pages and places where page break will be added.