IPdfFileEditor

public interface IPdfFileEditor

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

Methods

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

getConversionLog()

public abstract String getConversionLog()

Gets log of conversion process.

Returns: java.lang.String - string value

getMergeDuplicateLayers()

public abstract 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 - boolean value

setMergeDuplicateLayers(boolean value)

public abstract 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:

ParameterTypeDescription
valuebooleanboolean value

getMergeDuplicateOutlines()

public abstract boolean getMergeDuplicateOutlines()

If true, duplicate outlines are merged.

Returns: boolean - boolean value

setMergeDuplicateOutlines(boolean value)

public abstract void setMergeDuplicateOutlines(boolean value)

If true, duplicate outlines are merged.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getPreserveUserRights()

public abstract boolean getPreserveUserRights()

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

Returns: boolean - boolean value

setPreserveUserRights(boolean value)

public abstract 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:

ParameterTypeDescription
valuebooleanboolean value

getIncrementalUpdates()

public abstract boolean getIncrementalUpdates()

If true, incremental updates are made during concatenation.

Returns: boolean - boolean value

setIncrementalUpdates(boolean value)

public abstract void setIncrementalUpdates(boolean value)

If true, incremental updates are made during concatenation.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getCorruptedFileAction()

public abstract int getCorruptedFileAction()

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

Returns: int - ConcatenateCorruptedFileAction element

setCorruptedFileAction(int value)

public abstract void setCorruptedFileAction(int value)

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

Parameters:

ParameterTypeDescription
valueintConcatenateCorruptedFileAction element

getOwnerPassword()

public abstract String getOwnerPassword()

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

Returns: java.lang.String - string value

setOwnerPassword(String value)

public abstract void setOwnerPassword(String value)

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

Parameters:

ParameterTypeDescription
valuejava.lang.Stringstring value

getAllowConcatenateExceptions()

public abstract boolean getAllowConcatenateExceptions()

is Allow Concatenate Exceptions

Returns: boolean - boolean value

setAllowConcatenateExceptions(boolean value)

public abstract 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:

ParameterTypeDescription
valuebooleanboolean value

setConvertTo(PdfFormat value)

public abstract void setConvertTo(PdfFormat 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:

ParameterTypeDescription
valuePdfFormatPdfFormat element

getCloseConcatenatedStreams()

public abstract boolean getCloseConcatenatedStreams()

If set to true, streams are closed after operation.


PdfFileEditor pfe = new PdfFileEditor();
 pfe.setCloseConcatenatedStreams(true);

Returns: boolean - boolean value

setCloseConcatenatedStreams(boolean value)

public abstract void setCloseConcatenatedStreams(boolean value)

If set to true, streams are closed after operation.


PdfFileEditor pfe = new PdfFileEditor();
 pfe.setCloseConcatenatedStreams(true);

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getUniqueSuffix()

public abstract 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: java.lang.String - string value

setUniqueSuffix(String value)

public abstract 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:

ParameterTypeDescription
valuejava.lang.Stringstring value

getKeepFieldsUnique()

public abstract 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 - boolean value

setKeepFieldsUnique(boolean value)

public abstract 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:

ParameterTypeDescription
valuebooleanboolean value

getRemoveSignatures()

public abstract boolean getRemoveSignatures()

If true, all signatures will be removed from fields (fields will remain); otherwise, you can get invalid signatures.

Returns: boolean - boolean value

setRemoveSignatures(boolean value)

public abstract void setRemoveSignatures(boolean value)

If true, all signatures will be removed from fields (fields will remain); otherwise, you can get invalid signatures.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

concatenate(String firstInputFile, String secInputFile, String outputFile)

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

Concatentates two files.


PdfFileEditor fileEditor = new PdfFileEditor();
 fileEditor.concatenate("file1.pdf", "file2.pdf", "outfile.pdf");

Parameters:

ParameterTypeDescription
firstInputFilejava.lang.StringFirst file to concatenate.
secInputFilejava.lang.StringSecond file to concatenate.
outputFilejava.lang.StringOutput file.

Returns: boolean - True if operation was succeeded.

concatenate(InputStream firstInputStream, InputStream secInputStream, OutputStream outputStream)

public abstract 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:

ParameterTypeDescription
firstInputStreamjava.io.InputStreamStream of first file.
secInputStreamjava.io.InputStreamStream of second file.
outputStreamjava.io.OutputStreamStream where result file will be stored.

Returns: boolean - True if operation was succeeded.

concatenate(IDocument[] src, IDocument dest)

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

Concatenates documents.

Parameters:

ParameterTypeDescription
srcIDocument[]Array of source documents.
destIDocumentDestination document.

Returns: boolean - True if concatenation is successful.

concatenate(String[] inputFiles, String outputFile)

public abstract 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:

ParameterTypeDescription
inputFilesjava.lang.String[]Array of files to concatenate.
outputFilejava.lang.StringName of output file.

Returns: boolean - True if operation was succeeded.

concatenate(InputStream[] inputStream, OutputStream outputStream)

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStream[]Array of streams to be concatenated.
outputStreamjava.io.OutputStreamStream where result file will be stored.

Returns: boolean - True if operation was succeeded.

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

public abstract 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:

ParameterTypeDescription
firstInputFilejava.lang.StringFirst file.
secInputFilejava.lang.StringSecond file.
blankPageFilejava.lang.StringPDF file with blank page.
outputFilejava.lang.StringResult file.

Returns: boolean - True if operation was succeeded.

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

public abstract 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:

ParameterTypeDescription
firstInputStreamjava.io.InputStreamThe first Pdf Stream.
secInputStreamjava.io.InputStreamThe second Pdf Stream.
blankPageStreamjava.io.InputStreamThe Pdf Stream with blank page
outputStreamjava.io.OutputStreamOutput Pdf Stream.

Returns: boolean - True if operation was succeeded.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput Pdf stream.
portStreamsjava.io.InputStream[]Documents to copy pages from.
startPageintPage starts in portStreams documents.
endPageintPage ends in portStreams documents .
outputStreamjava.io.OutputStreamOutput Pdf stream.

Returns: boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput Pdf file.
portFilesjava.lang.String[]Documents to copy pages from.
startPageintPage starts in portFiles documents.
endPageintPage ends in portFiles documents .
outputFilejava.lang.StringOutput Pdf document.

Returns: boolean - True if operation was succeeded.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput Pdf file.
portFilejava.lang.StringPages from Pdf file.
startPageintPage starts in portFile.
endPageintPage ends in portFile.
outputFilejava.lang.StringOutput Pdf document.

Returns: boolean - True if operation was succeeded.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput file Stream.
portStreamjava.io.InputStreamPages from Pdf file Stream.
startPageintPage starts in portFile Stream.
endPageintPage ends in portFile Stream.
outputStreamjava.io.OutputStreamOutput Pdf file Stream.

Returns: boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput Pdf file.
insertLocationintPosition in input file.
portFilejava.lang.StringThe porting Pdf file.
startPageintStart position in portFile.
endPageintEnd position in portFile.
outputFilejava.lang.StringOutput Pdf file.

Returns: boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput Stream of Pdf file.
insertLocationintInsert position in input file.
portStreamjava.io.InputStreamStream of Pdf file for pages.
startPageintFrom which page to start.
endPageintTo which page to end.
outputStreamjava.io.OutputStreamOutput Stream.

Returns: boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput Pdf file.
insertLocationintInsert position in input file.
portFilejava.lang.StringPages from the Pdf file.
pageNumberint[]The page number of the ported in portFile.
outputFilejava.lang.StringOutput Pdf file.

Returns: boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput Stream of Pdf file.
insertLocationintInsert position in input file.
portStreamjava.io.InputStreamStream of Pdf file for pages.
pageNumberint[]The page number of the ported in portFile.
outputStreamjava.io.OutputStreamOutput Stream.

Returns: boolean - True if operation was succeeded.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput file path.
pageNumberint[]Index of page out of the input file.
outputFilejava.lang.StringOutput file path.

Returns: boolean - True if operation was succeeded.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput file Stream.
pageNumberint[]Index of page out of the input file.
outputStreamjava.io.OutputStreamOutput file stream.

Returns: boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput Pdf file path.
startPageintStart page number.
endPageintEnd page number.
outputFilejava.lang.StringOutput Pdf file path.

Returns: boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput file path.
pageNumberint[]Index of page out of the input file.
outputFilejava.lang.StringOutput file path.

Returns: boolean - True if operation was succeeded.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput file Stream.
startPageintStart page number.
endPageintEnd page number.
outputStreamjava.io.OutputStreamOutput Pdf file Stream.

Returns: boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput file Stream.
pageNumberint[]Index of page out of the input file.
outputStreamjava.io.OutputStreamOutput file stream.

Returns: boolean - True for success, or false.

splitFromFirst(String inputFile, int location, String outputFile)

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringSource Pdf file.
locationintThe splitting point.
outputFilejava.lang.StringOutput Pdf file.

Returns: boolean - True for success, or false.

splitFromFirst(InputStream inputStream, int location, OutputStream outputStream)

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamSource Pdf file Stream.
locationintThe splitting point.
outputStreamjava.io.OutputStreamOutput file Stream.

Returns: boolean - True for success, or false.

splitToEnd(String inputFile, int location, String outputFile)

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringSource Pdf file.
locationintThe splitting position.
outputFilejava.lang.StringOutput Pdf file path.

Returns: boolean - True for success, or false.

splitToEnd(InputStream inputStream, int location, OutputStream outputStream)

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamSource Pdf file Stream.
locationintThe splitting position.
outputStreamjava.io.OutputStreamOutput Pdf file Stream.

Returns: boolean - True for success, or false.

makeBooklet(String inputFile, String outputFile)

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput pdf file path and name.
outputFilejava.lang.StringOutput pdf file path and name.

Returns: boolean - boolean - True for success, or false.

makeBooklet(InputStream inputStream, OutputStream outputStream)

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput pdf stream.
outputStreamjava.io.OutputStreamoutput pdf stream.

Returns: boolean - True if operation was succeeded.

makeBooklet(String inputFile, String outputFile, PageSize pageSize)

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput pdf file path and name.
outputFilejava.lang.StringOutput pdf file path and name.
pageSizePageSizeThe page size of the output pdf file.

Returns: boolean - True if operation is succeeded.

makeBooklet(InputStream inputStream, OutputStream outputStream, PageSize pageSize)

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput PDF stream.
outputStreamjava.io.OutputStreamoutput pdf stream.
pageSizePageSizeThe page size of the output pdf file.

Returns: boolean - True if operation was succeeded.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringThe input file.
outputFilejava.lang.StringOutput pdf file path and name.
leftPagesint[]The left pages of the booklet.
rightPagesint[]The right pages of the booklet.

Returns: boolean - boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamThe input stream.
outputStreamjava.io.OutputStreamoutput pdf stream.
leftPagesint[]The left pages.
rightPagesint[]The right pages.

Returns: boolean - boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringThe input file.
outputFilejava.lang.StringOutput pdf file path and name.
pageSizePageSizeThe page size of the output pdf file.
leftPagesint[]The left pages.
rightPagesint[]The right pages.

Returns: boolean - boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamThe input stream.
outputStreamjava.io.OutputStreamoutput pdf stream.
pageSizePageSizeThe page size of the output pdf file.
leftPagesint[]The left pages.
rightPagesint[]The right pages.

Returns: boolean - boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput pdf file path and name.
outputFilejava.lang.StringOutput pdf file path and name.
xintNumber of columns.
yintNumber of rows.

Returns: boolean - boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput pdf stream.
outputStreamjava.io.OutputStreamOutput pdf stream.
xintNumber of columns.
yintNumber of rows.

Returns: boolean - boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput pdf stream.
outputStreamjava.io.OutputStreamOutput pdf stream.
xintNumber of columns.
yintNumber of rows.
pageSizePageSizeThe page size of the output pdf file.

Returns: boolean - True if operation was succeeded.

makeNUp(String firstInputFile, String secondInputFile, String outputFile)

public abstract 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:

ParameterTypeDescription
firstInputFilejava.lang.Stringfirst input file.
secondInputFilejava.lang.Stringsecond input file.
outputFilejava.lang.StringOutput pdf file path and name.

Returns: boolean - boolean - True for success, or false.

makeNUp(InputStream firstInputStream, InputStream secondInputStream, OutputStream outputStream)

public abstract 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:

ParameterTypeDescription
firstInputStreamjava.io.InputStreamfirst input stream.
secondInputStreamjava.io.InputStreamsecond input stream.
outputStreamjava.io.OutputStreamOutput pdf stream.

Returns: boolean - boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputFilesjava.lang.String[]Input Pdf files.
outputFilejava.lang.StringOutput pdf file path and name.
isSidewisebooleanPiled up way, true for horizontally and flase for vertically.

Returns: boolean - boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputStreamsjava.io.InputStream[]Input Pdf streams.
outputStreamjava.io.OutputStreamOutput pdf stream.
isSidewisebooleanPiled up way, true for horizontally and flase for vertically

Returns: boolean - boolean - True for success, or false.

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

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput pdf file path and name.
outputFilejava.lang.StringOutput pdf file path and name.
xintNumber of columns.
yintNumber of rows.
pageSizePageSizeThe page size of the output pdf file.

Returns: boolean - boolean - True for success, or false.

splitToPages(String inputFile)

public abstract ByteArrayInputStream[] splitToPages(String inputFile)

Splits the PDF file into single-page documents.

Parameters:

ParameterTypeDescription
inputFilejava.lang.StringInput PDF file name.

Returns: java.io.ByteArrayInputStream[] - Output PDF streams, each stream buffers a single-page PDF document.

splitToPages(String inputFile, String fileNameTemplate)

public abstract 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:

ParameterTypeDescription
inputFilejava.lang.StringInput file name.
fileNameTemplatejava.lang.StringTemplate 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(InputStream inputStream, String fileNameTemplate)

public abstract 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:

ParameterTypeDescription
inputStreamjava.io.InputStreamStream of the soruce document.
fileNameTemplatejava.lang.StringTemplate 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(InputStream inputStream)

public abstract ByteArrayInputStream[] splitToPages(InputStream inputStream)

Splits the Pdf file into single-page documents.

Parameters:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput Pdf stream.

Returns: java.io.ByteArrayInputStream[] - ByteArrayInputStream[] array

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

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

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

Parameters:

ParameterTypeDescription
inputFilejava.lang.StringInput PDF file.
numberOfPageint[][]Array which contains array of double elements, which is start and end pages of document.

Returns: java.io.ByteArrayInputStream[] - Output PDF streams, each stream buffers a PDF document.

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

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

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

Parameters:

ParameterTypeDescription
inputStreamjava.io.InputStreamInput PDF stream.
numberOfPageint[][]The start page and the end page of each document.

Returns: java.io.ByteArrayInputStream[] - Output PDF streams, each stream buffers a PDF document.

getLastException()

public abstract 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 - java.lang.Exception object

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

public abstract 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:

ParameterTypeDescription
sourcejava.io.InputStreamStream which contains source document.
destinationjava.io.OutputStreamStream where resultant document will be saved.
pagesint[]Array of page indexes. If null then all document pages will be processed.
newWidthdoubleNew width of page contents in default space units.
newHeightdoubleNew height of page contents in default space units.

Returns: boolean - True if resize was successful.

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

public abstract 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:

ParameterTypeDescription
sourcejava.io.InputStreamStream which contains source document.
destinationjava.io.OutputStreamStream where resultant document will be saved.
pagesint[]Array of page indexes. If null then all document pages will be processed.
newWidthdoubleNew width of page contents in percents.
newHeightdoubleNew height of page contents in percetns.

Returns: boolean - True if resize was successful.

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

public abstract 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:

ParameterTypeDescription
sourcejava.io.InputStreamStream which contains source document.
destinationjava.io.OutputStreamStream where resultant document will be saved.
pagesint[]Array of page indexes. If null then all document pages will be processed.
leftMargindoubleLeft margin.
rightMargindoubleRight margin.
topMargindoubleTop margin.
bottomMargindoubleBottom margin.

Returns: boolean - boolean value

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

public abstract 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:

ParameterTypeDescription
sourcejava.io.InputStreamStream which contains source document.
destinationjava.io.OutputStreamStream where resultant document will be saved.
pagesint[]Array of page indexes. If null then all document pages will be processed.
leftMargindoubleLeft margin in percents of initial page size.
rightMargindoubleRight margin in percents of initial page size.
topMargindoubleTop margin in percents of initial page size.
bottomMargindoubleBottom margin in percents of initial page size.

Returns: boolean - true if resize was successful

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

public abstract 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:

ParameterTypeDescription
sourcejava.lang.StringPath to source document.
destinationjava.lang.StringPath where resultant document will be saved.
pagesint[]Array of page indexes. If null then all document pages will be processed.
newWidthdoubleNew width of page contents in default space units.
newHeightdoubleNew height of page contents in default space units.

Returns: boolean - True if resize was successful.

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

public abstract 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:

ParameterTypeDescription
sourcejava.lang.StringPath to source document.
destinationjava.lang.StringPath where resultant document will be saved.
pagesint[]Array of page indexes. If null then all document pages will be processed.
newWidthdoubleNew width of page contents in percents.
newHeightdoubleNew height of page contents in percetns.

Returns: boolean - true if resize was successful.

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

public abstract 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:

ParameterTypeDescription
sourcejava.lang.StringPath to source document.
destinationjava.lang.StringPath where resultant document will be saved.
pagesint[]Array of page indexes. If null then all document pages will be processed.
leftMargindoubleLeft margin.
rightMargindoubleRight margin.
topMargindoubleTop margin.
bottomMargindoubleBottom margin.

Returns: boolean - true if resize was successful.

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

public abstract 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:

ParameterTypeDescription
sourcejava.lang.StringPath to source document.
destinationjava.lang.StringPath where resultant document will be saved.
pagesint[]Array of page indexes. If null then all document pages will be processed.
leftMargindoubleLeft margin in percents of initial page size.
rightMargindoubleRight margin in percents of initial page size.
topMargindoubleTop margin in percents of initial page size.
bottomMargindoubleBottom margin in percents of initial page size.

Returns: boolean - true if resize was successful

getContentDisposition()

public abstract int getContentDisposition()

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

Returns: int - ContentDisposition element

setContentDisposition(int value)

public abstract 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:

ParameterTypeDescription
valueintContentDisposition element

getSaveOptions()

public abstract SaveOptions getSaveOptions()

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

Returns: SaveOptions - SaveOptions object

setSaveOptions(SaveOptions value)

public abstract void setSaveOptions(SaveOptions value)

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

Parameters:

ParameterTypeDescription
valueSaveOptionsSaveOptions object

getAttachmentName()

public abstract String getAttachmentName()

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

Returns: java.lang.String - string value

setAttachmentName(String value)

public abstract void setAttachmentName(String value)

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

Parameters:

ParameterTypeDescription
valuejava.lang.Stringstring value