com.aspose.pdf.facades

Interface IPdfFileEditor

  • All Known Implementing Classes:
    PdfFileEditor, PdfFileEditorWeb


    public interface IPdfFileEditor

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

    • Method Summary

      Methods 
      Modifier and Type Method and Description
      boolean addMargins(InputStream source, OutputStream destination, int[] pages, double leftMargin, double rightMargin, double topMargin, double bottomMargin)
      Resizes page contents and add specifed margins.
      boolean addMargins(String source, String destination, int[] pages, double leftMargin, double rightMargin, double topMargin, double bottomMargin)
      Resizes page contents and add specifed margins.
      boolean addMarginsPct(InputStream source, OutputStream destination, int[] pages, double leftMargin, double rightMargin, double topMargin, double bottomMargin)
      Resizes page contents and add specified margins.
      boolean addMarginsPct(String source, String destination, int[] pages, double leftMargin, double rightMargin, double topMargin, double bottomMargin)
      Resizes page contents and add specified margins.
      boolean append(InputStream inputStream, InputStream[] portStreams, int startPage, int endPage, OutputStream outputStream)
      Appends pages, which are chosen from array of documents in portStreams.
      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.
      boolean append(String inputFile, String[] portFiles, int startPage, int endPage, String outputFile)
      Appends pages, which are chosen from portFiles documents.
      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.
      boolean concatenate(IDocument[] src, IDocument dest)
      Concatenates documents.
      boolean concatenate(InputStream[] inputStream, OutputStream outputStream)
      Concatenates files
      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.
      boolean concatenate(InputStream firstInputStream, InputStream secInputStream, OutputStream outputStream)
      Concatenates two files.
      boolean concatenate(String[] inputFiles, String outputFile)
      Concatenates files into one file.
      boolean concatenate(String firstInputFile, String secInputFile, String outputFile)
      Concatentates two files.
      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.
      boolean delete(InputStream inputStream, int[] pageNumber, OutputStream outputStream)
      Deletes pages specified by number array from input file, saves as a new Pdf file.
      boolean delete(String inputFile, int[] pageNumber, String outputFile)
      Deletes pages specified by number array from input file, saves as a new Pdf file.
      boolean extract(InputStream inputStream, int[] pageNumber, OutputStream outputStream)
      Extracts pages specified by number array, saves as a new Pdf file.
      boolean extract(InputStream inputStream, int startPage, int endPage, OutputStream outputStream)
      Extracts pages from input file,saves as a new Pdf file.
      boolean extract(String inputFile, int[] pageNumber, String outputFile)
      Extracts pages specified by number array, saves as a new PDF file.
      boolean extract(String inputFile, int startPage, int endPage, String outputFile)
      Extracts pages from input file,saves as a new Pdf file.
      boolean getAllowConcatenateExceptions()
      is Allow Concatenate Exceptions
      String getAttachmentName()
      Gets name of attachment when result of operation is stored into HttpServletResponse objects as attachment.
      boolean getCloseConcatenatedStreams()
      If set to true, streams are closed after operation.
      int getContentDisposition()
      Gets how content will be stored when result of operation is stored into HttpServletResponse object.
      String getConversionLog()
      Gets log of conversion process.
      int getCorruptedFileAction()
      This property defines behavior when concatenating process met corrupted file.
      boolean getIncrementalUpdates()
      If true, incremental updates are made during concatenation.
      boolean getKeepFieldsUnique()
      If true then field names will be made unique when forms are concatenated.
      Exception getLastException()
      Gets last occured exception.
      boolean getMergeDuplicateLayers()
      Optional contents of concatentated documents with equal names will be merged into one layer in resulstant document if this property is true.
      boolean getMergeDuplicateOutlines()
      If true, duplicate outlines are merged.
      String getOwnerPassword()
      Gets owner's password if the source input Pdf file is encrypted.
      boolean getPreserveUserRights()
      If true, user rights of first document are applied to concatenated document.
      SaveOptions getSaveOptions()
      Gets or sets save options when result is stored as HttpServletResponse.
      String getUniqueSuffix()
      Get format of the suffix which is added to field name to make it unique when forms are concatenated.
      boolean insert(InputStream inputStream, int insertLocation, InputStream portStream, int[] pageNumber, OutputStream outputStream)
      Inserts pages from an other file into the input Pdf file.
      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.
      boolean insert(String inputFile, int insertLocation, String portFile, int[] pageNumber, String outputFile)
      Inserts pages from an other file into the input Pdf file.
      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.
      boolean makeBooklet(InputStream inputStream, OutputStream outputStream)
      Makes booklet from the InputStream to outputStream.
      boolean makeBooklet(InputStream inputStream, OutputStream outputStream, int[] leftPages, int[] rightPages)
      Makes customized booklet from the firstInputStream to outputStream.
      boolean makeBooklet(InputStream inputStream, OutputStream outputStream, PageSize pageSize)
      Makes booklet from the input stream and save result into output stream.
      boolean makeBooklet(InputStream inputStream, OutputStream outputStream, PageSize pageSize, int[] leftPages, int[] rightPages)
      Makes booklet from the firstInputStream to outputStream.
      boolean makeBooklet(String inputFile, String outputFile)
      Makes booklet from the input file to output file.
      boolean makeBooklet(String inputFile, String outputFile, int[] leftPages, int[] rightPages)
      Makes customized booklet from the firstInputFile to outputFile.
      boolean makeBooklet(String inputFile, String outputFile, PageSize pageSize)
      Makes booklet from the inputFile to outputFile.
      boolean makeBooklet(String inputFile, String outputFile, PageSize pageSize, int[] leftPages, int[] rightPages)
      Makes customized booklet from the firstInputFile to outputFile.
      boolean makeNUp(InputStream[] inputStreams, OutputStream outputStream, boolean isSidewise)
      Makes N-Up document from the multi input PDF streams to outputStream.
      boolean makeNUp(InputStream firstInputStream, InputStream secondInputStream, OutputStream outputStream)
      Makes N-Up document from the two input PDF streams to outputStream.
      boolean makeNUp(InputStream inputStream, OutputStream outputStream, int x, int y)
      Makes N-Up document from the input stream and saves result into output stream.
      boolean makeNUp(InputStream inputStream, OutputStream outputStream, int x, int y, PageSize pageSize)
      Makes N-Up document from the first input stream to output stream.
      boolean makeNUp(String[] inputFiles, String outputFile, boolean isSidewise)
      Makes N-Up document from the multi input PDF files to outputFile.
      boolean makeNUp(String inputFile, String outputFile, int x, int y)
      Makes N-Up document from the firstInputFile to outputFile.
      boolean makeNUp(String inputFile, String outputFile, int x, int y, PageSize pageSize)
      Makes N-Up document from the input file to outputFile.
      boolean makeNUp(String firstInputFile, String secondInputFile, String outputFile)
      Makes N-Up document from the two input PDF files to outputFile.
      boolean resizeContents(InputStream source, OutputStream destination, int[] pages, double newWidth, double newHeight)
      Resizes contents of document pages.
      boolean resizeContents(String source, String destination, int[] pages, double newWidth, double newHeight)
      Resizes contents of document pages.
      boolean resizeContentsPct(InputStream source, OutputStream destination, int[] pages, double newWidth, double newHeight)
      Resizes contents of document pages.
      boolean resizeContentsPct(String source, String destination, int[] pages, double newWidth, double newHeight)
      Resizes contents of document pages.
      void setAllowConcatenateExceptions(boolean value)
      If set to true, exceptions are thrown if error occured.
      void setAttachmentName(String value)
      Sets name of attachment when result of operation is stored into HttpServletResponse objects as attachment.
      void setCloseConcatenatedStreams(boolean value)
      If set to true, streams are closed after operation.
      void setContentDisposition(int value)
      Sets how content will be stored when result of operation is stored into HttpServletResponse object.
      void setConvertTo(int value)
      Sets PDF file format.
      void setCorruptedFileAction(int value)
      This property defines behavior when concatenating process met corrupted file.
      void setIncrementalUpdates(boolean value)
      If true, incremental updates are made during concatenation.
      void setKeepFieldsUnique(boolean value)
      If true then field names will be made unique when forms are concatenated.
      void setMergeDuplicateLayers(boolean value)
      Optional contents of concatentated documents with equal names will be merged into one layer in resulstant document if this property is true.
      void setMergeDuplicateOutlines(boolean value)
      If true, duplicate outlines are merged.
      void setOwnerPassword(String value)
      Sets owner's password if the source input Pdf file is encrypted.
      void setPreserveUserRights(boolean value)
      If true, user rights of first document are applied to concatenated document.
      void setSaveOptions(SaveOptions value)
      Sets save options when result is stored as HttpServletResponse.
      void setUniqueSuffix(String value)
      Set format of the suffix which is added to field name to make it unique when forms are concatenated.
      boolean splitFromFirst(InputStream inputStream, int location, OutputStream outputStream)
      Splits from start to specified location,and saves the front part in output Stream.
      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.
      ByteArrayInputStream[] splitToBulks(InputStream inputStream, int[][] numberOfPage)
      Splits the Pdf file into several documents.The documents can be single-page or multi-pages.
      ByteArrayInputStream[] splitToBulks(String inputFile, int[][] numberOfPage)
      Splits the Pdf file into several documents.The documents can be single-page or multi-pages.
      boolean splitToEnd(InputStream inputStream, int location, OutputStream outputStream)
      Splits from specified location, and saves the rear part as a new file Stream.
      boolean splitToEnd(String inputFile, int location, String outputFile)
      Splits from location, and saves the rear part as a new file.
      ByteArrayInputStream[] splitToPages(InputStream inputStream)
      Splits the Pdf file into single-page documents.
      void splitToPages(InputStream inputStream, String fileNameTemplate)
      Split the Pdf file into single-page documents and saves it into specified path.
      ByteArrayInputStream[] splitToPages(String inputFile)
      Splits the PDF file into single-page documents.
      void splitToPages(String inputFile, String fileNameTemplate)
      Split the Pdf file into single-page documents and saves it into specified path.
    • Method Detail

      • getConversionLog

        String getConversionLog()

        Gets log of conversion process.

        Returns:
        string value
      • getMergeDuplicateLayers

        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.

        Returns:
        boolean value
      • setMergeDuplicateLayers

        void setMergeDuplicateLayers(boolean value)

        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.

        Parameters:
        value - boolean value
      • getMergeDuplicateOutlines

        boolean getMergeDuplicateOutlines()

        If true, duplicate outlines are merged.

        Returns:
        boolean value
      • setMergeDuplicateOutlines

        void setMergeDuplicateOutlines(boolean value)

        If true, duplicate outlines are merged.

        Parameters:
        value - boolean value
      • getPreserveUserRights

        boolean getPreserveUserRights()

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

        Returns:
        boolean value
      • setPreserveUserRights

        void setPreserveUserRights(boolean value)

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

        Parameters:
        value - boolean value
      • getIncrementalUpdates

        boolean getIncrementalUpdates()

        If true, incremental updates are made during concatenation.

        Returns:
        boolean value
      • setIncrementalUpdates

        void setIncrementalUpdates(boolean value)

        If true, incremental updates are made during concatenation.

        Parameters:
        value - boolean value
      • getCorruptedFileAction

        int getCorruptedFileAction()

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

        Returns:
        ConcatenateCorruptedFileAction element
        See Also:
        PdfFileEditor.ConcatenateCorruptedFileAction
      • setCorruptedFileAction

        void setCorruptedFileAction(int value)

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

        Parameters:
        value - ConcatenateCorruptedFileAction element
        See Also:
        PdfFileEditor.ConcatenateCorruptedFileAction
      • getOwnerPassword

        String getOwnerPassword()

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

        Returns:
        string value
      • setOwnerPassword

        void setOwnerPassword(String value)

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

        Parameters:
        value - string value
      • getAllowConcatenateExceptions

        boolean getAllowConcatenateExceptions()
        is Allow Concatenate Exceptions
        Returns:
        boolean value
      • setAllowConcatenateExceptions

        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);
         
        Parameters:
        value - boolean value
      • setConvertTo

        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.

        Parameters:
        value - PdfFormat element
        See Also:
        PdfFormat
      • getCloseConcatenatedStreams

        boolean getCloseConcatenatedStreams()

        If set to true, streams are closed after operation.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.setCloseConcatenatedStreams(true);
         
        Returns:
        boolean value
      • setCloseConcatenatedStreams

        void setCloseConcatenatedStreams(boolean value)

        If set to true, streams are closed after operation.


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.setCloseConcatenatedStreams(true);
         
        Parameters:
        value - boolean value
      • getUniqueSuffix

        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.

        Returns:
        string value
      • setUniqueSuffix

        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%");
         
        Parameters:
        value - string value
      • getKeepFieldsUnique

        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.

        Returns:
        boolean value
      • setKeepFieldsUnique

        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.

        Parameters:
        value - boolean value
      • concatenate

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

        Concatentates two files.


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

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

        Concatenates two 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(stream1, stream2, outstream);
         
        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

        boolean concatenate(IDocument[] src,
                          IDocument dest)

        Concatenates documents.

        Parameters:
        src - Array of source documents.
        dest - Destination document.
        Returns:
        True if concatenation is successful.
      • concatenate

        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");
         
        Parameters:
        inputFiles - Array of files to concatenate.
        outputFile - Name of output file.
        Returns:
        True if operation was succeeded.
      • concatenate

        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 Stream[]
         { stream1, stream2 }, outstream);
         
        Parameters:
        inputStream - Array of streams to be concatenated.
        outputStream - Stream where result file will be stored.
        Returns:
        True if operation was succeeded.
      • concatenate

        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");
         
        Parameters:
        firstInputFile - First file.
        secInputFile - Second file.
        blankPageFile - PDF file with blank page.
        outputFile - Result file.
        Returns:
        True if operation was succeeded.
      • concatenate

        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 Stream[]
         { stream1, stream2, blank }, outstream);
         
        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

        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 Stream[]
         { stream1, stream2 }, 3, 5, outstream);
         
        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

        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");
         
        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

        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");
         
        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

        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, outstream);
         
        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

        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");
         
        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

        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);
         
        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

        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();
         pfe.insert("file1.pdf", 1, "out.pdf", 2, 6, "out.pdf");
         
        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

        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);
         
        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

        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");
         
        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

        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);
         
        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

        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");
         
        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

        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");
         
        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

        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);
         
        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

        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);
         
        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

        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");
         
        Parameters:
        inputFile - Source Pdf file.
        location - The splitting point.
        outputFile - Output Pdf file.
        Returns:
        True for success, or false.
      • splitFromFirst

        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.
        Parameters:
        inputStream - Source Pdf file Stream.
        location - The splitting point.
        outputStream - Output file Stream.
        Returns:
        True for success, or false.
      • splitToEnd

        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");
         
        Parameters:
        inputFile - Source Pdf file.
        location - The splitting position.
        outputFile - Output Pdf file path.
        Returns:
        True for success, or false.
      • splitToEnd

        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.
        Parameters:
        inputStream - Source Pdf file Stream.
        location - The splitting position.
        outputStream - Output Pdf file Stream.
        Returns:
        True for success, or false.
      • makeBooklet

        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");
         
        Parameters:
        inputFile - Input pdf file path and name.
        outputFile - Output pdf file path and name.
        Returns:
        boolean - True for success, or false.
      • makeBooklet

        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);
         
        Parameters:
        inputStream - Input pdf stream.
        outputStream - output pdf stream.
        Returns:
        True if operation was succeeded.
      • makeBooklet

        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);
         
        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

        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);
         
        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

        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 });
         
        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

        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 });
         
        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

        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 });
         
        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

        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 });
         
        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

        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);
         
        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

        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 FileInputStream("output.pdf");
         pfe.makeNUp(inputStream, outputStream, 3, 3);
         
        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

        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 FileOutputStream("output.pdf");
         pfe.makeNUp(inputStream, outputStream, 3, 3, PageSize.A4);
         
        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

        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");
         
        Parameters:
        firstInputFile - first input file.
        secondInputFile - second input file.
        outputFile - Output pdf file path and name.
        Returns:
        boolean - True for success, or false.
      • makeNUp

        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);
         
        Parameters:
        firstInputStream - first input stream.
        secondInputStream - second input stream.
        outputStream - Output pdf stream.
        Returns:
        boolean - True for success, or false.
      • makeNUp

        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);
         
        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

        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 Stream[]
         { stream1, stream2, stream3 }, output, false);
         
        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

        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);
         
        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

        ByteArrayInputStream[] splitToPages(String inputFile)

        Splits the PDF file into single-page documents.

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

        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.

        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

        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.

        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

        ByteArrayInputStream[] splitToPages(InputStream inputStream)

        Splits the Pdf file into single-page documents.

        Parameters:
        inputStream - Input Pdf stream.
        Returns:
        ByteArrayInputStream[] array
      • splitToBulks

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

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

        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

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

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

        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

        Exception getLastException()

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


         
         
         PdfFileEditor pfe = new PdfFileEditor();
         pfe.setAllowConcatenateExceptions(false);
         if (!pfe.concatenate("", "", ""))
         {
             System.out.println("");
             if (pfe.getLastException() != null)
             {
                System.out.println(pfe.getLastException().getMessage());
                if (pfe.getLastException().getCause() != null)
                    System.out.println(pfe.getLastException().getCause().getMessage());
             }
         }
         
        Returns:
        java.lang.Exception object
      • resizeContents

        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
         
        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

        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.
         
        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 resize was successful.
      • addMargins

        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");
         OutputStream dest = new FileOutputStream("output.pdf");
         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();
         
        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:
        boolean value
      • addMarginsPct

        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");
         OutputStream dest = new FileOutputStream("output.pdf");
         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();
         
        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 resize was successful
      • resizeContents

        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
         
        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

        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.resizeContentsPct("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.
         
        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

        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);
         
        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

        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);
         
        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
      • getContentDisposition

        int getContentDisposition()

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

        Returns:
        ContentDisposition element
        See Also:
        ContentDisposition
      • setContentDisposition

        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.

        Parameters:
        value - ContentDisposition element
        See Also:
        ContentDisposition
      • getSaveOptions

        SaveOptions getSaveOptions()

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

        Returns:
        SaveOptions object
      • setSaveOptions

        void setSaveOptions(SaveOptions value)

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

        Parameters:
        value - SaveOptions object
      • getAttachmentName

        String getAttachmentName()

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

        Returns:
        string value
      • setAttachmentName

        void setAttachmentName(String value)

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

        Parameters:
        value - string value