public interface IPdfFileEditor
Implements operations with PDF file: concatenation, splitting, extracting pages, making booklet, etc.
Modifier and Type | Interface and Description |
---|---|
static class |
IPdfFileEditor.ContentsResizeParameters
Class for specifing page resize parameters.
|
static class |
IPdfFileEditor.ContentsResizeValue
Value of margin or content size specified in percents of default space units.
|
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
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);
|
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'.
|
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. e.g.: document1 has 5 pages: p1, p2, p3, p4, p5. document2 has
3 pages: p1', p2', p3'.
|
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.
|
String getConversionLog()
Gets log of conversion process.
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.
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.
value
- boolean valueboolean getMergeDuplicateOutlines()
If true, duplicate outlines are merged.
void setMergeDuplicateOutlines(boolean value)
If true, duplicate outlines are merged.
value
- boolean valueboolean getPreserveUserRights()
If true, user rights of first document are applied to concatenated document. User rights of all other documents are ignored.
void setPreserveUserRights(boolean value)
If true, user rights of first document are applied to concatenated document. User rights of all other documents are ignored.
value
- boolean valueboolean getIncrementalUpdates()
If true, incremental updates are made during concatenation.
void setIncrementalUpdates(boolean value)
If true, incremental updates are made during concatenation.
value
- boolean valueint getCorruptedFileAction()
This property defines behavior when concatenating process met corrupted file. Possible values are: StopWithError and ConcatenateIgnoringCorrupted.
PdfFileEditor.ConcatenateCorruptedFileAction
void setCorruptedFileAction(int value)
This property defines behavior when concatenating process met corrupted file. Possible values are: StopWithError and ConcatenateIgnoringCorrupted.
value
- ConcatenateCorruptedFileAction elementPdfFileEditor.ConcatenateCorruptedFileAction
String getOwnerPassword()
Gets owner's password if the source input Pdf file is encrypted. This property is not implemented yet.
void setOwnerPassword(String value)
Sets owner's password if the source input Pdf file is encrypted. This property is not implemented yet.
value
- string valueboolean getAllowConcatenateExceptions()
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);
value
- boolean valuevoid 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.
value
- PdfFormat elementPdfFormat
boolean getCloseConcatenatedStreams()
If set to true, streams are closed after operation.
PdfFileEditor pfe = new PdfFileEditor(); pfe.setCloseConcatenatedStreams(true);
void setCloseConcatenatedStreams(boolean value)
If set to true, streams are closed after operation.
PdfFileEditor pfe = new PdfFileEditor(); pfe.setCloseConcatenatedStreams(true);
value
- boolean valueString 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.
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%");
value
- string valueboolean 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.
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.
value
- boolean valueboolean concatenate(String firstInputFile, String secInputFile, String outputFile)
Concatentates two files.
PdfFileEditor fileEditor = new PdfFileEditor(); fileEditor.concatenate("file1.pdf", "file2.pdf", "outfile.pdf");
firstInputFile
- First file to concatenate.secInputFile
- Second file to concatenate.outputFile
- Output file.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);
firstInputStream
- Stream of first file.secInputStream
- Stream of second file.outputStream
- Stream where result file will be stored.boolean concatenate(IDocument[] src, IDocument dest)
Concatenates documents.
src
- Array of source documents.dest
- Destination document.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");
inputFiles
- Array of files to concatenate.outputFile
- Name of output file.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);
inputStream
- Array of streams to be concatenated.outputStream
- Stream where result file will be stored.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");
firstInputFile
- First file.secInputFile
- Second file.blankPageFile
- PDF file with blank page.outputFile
- Result file.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);
firstInputStream
- The first Pdf Stream.secInputStream
- The second Pdf Stream.blankPageStream
- The Pdf Stream with blank pageoutputStream
- Output Pdf Stream.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);
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.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");
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.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");
inputFile
- Input Pdf file.portFile
- Pages from Pdf file.startPage
- Page starts in portFile.endPage
- Page ends in portFile.outputFile
- Output Pdf document.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);
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.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");
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.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);
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.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");
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.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);
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.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");
inputFile
- Input file path.pageNumber
- Index of page out of the input file.outputFile
- Output file path.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);
inputStream
- Input file Stream.pageNumber
- Index of page out of the input file.outputStream
- Output file stream.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");
inputFile
- Input Pdf file path.startPage
- Start page number.endPage
- End page number.outputFile
- Output Pdf file path.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");
inputFile
- Input file path.pageNumber
- Index of page out of the input file.outputFile
- Output file path.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);
inputStream
- Input file Stream.startPage
- Start page number.endPage
- End page number.outputStream
- Output Pdf file Stream.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);
inputStream
- Input file Stream.pageNumber
- Index of page out of the input file.outputStream
- Output file 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.
PdfFileEditor pfe = new PdfFileEditor(); pfe.splitFromFirst("input.pdf", 5, "out.pdf");
inputFile
- Source Pdf file.location
- The splitting point.outputFile
- Output Pdf file.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);
inputStream
- Source Pdf file Stream.location
- The splitting point.outputStream
- Output file Stream.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");
inputFile
- Source Pdf file.location
- The splitting position.outputFile
- Output Pdf file path.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);
inputStream
- Source Pdf file Stream.location
- The splitting position.outputStream
- Output Pdf file Stream.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");
inputFile
- Input pdf file path and name.outputFile
- Output pdf file path and name.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);
inputStream
- Input pdf stream.outputStream
- output pdf stream.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);
inputFile
- Input pdf file path and name.outputFile
- Output pdf file path and name.pageSize
- The page size of the output pdf file.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);
inputStream
- Input PDF stream.outputStream
- output pdf stream.pageSize
- The page size of the output pdf file.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 });
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.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 });
inputStream
- The input stream.outputStream
- output pdf stream.leftPages
- The left pages.rightPages
- The right pages.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 });
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.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 });
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.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);
inputFile
- Input pdf file path and name.outputFile
- Output pdf file path and name.x
- Number of columns.y
- Number of rows.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);
inputStream
- Input pdf stream.outputStream
- Output pdf stream.x
- Number of columns.y
- Number of rows.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);
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.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");
firstInputFile
- first input file.secondInputFile
- second input file.outputFile
- Output pdf file path and name.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);
firstInputStream
- first input stream.secondInputStream
- second input stream.outputStream
- Output pdf stream.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);
inputFiles
- Input Pdf files.outputFile
- Output pdf file path and name.isSidewise
- Piled up way, true for horizontally and flase for vertically.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);
inputStreams
- Input Pdf streams.outputStream
- Output pdf stream.isSidewise
- Piled up way, true for horizontally and flase for verticallyboolean 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);
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.ByteArrayInputStream[] splitToPages(String inputFile)
Splits the PDF file into single-page documents.
inputFile
- Input PDF file name.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.
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.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.
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.ByteArrayInputStream[] splitToPages(InputStream inputStream)
Splits the Pdf file into single-page documents.
inputStream
- Input Pdf stream.ByteArrayInputStream[] splitToBulks(String inputFile, int[][] numberOfPage)
Splits the Pdf file into several documents.The documents can be single-page or multi-pages.
inputFile
- Input PDF file.numberOfPage
- Array which contains array of double elements, which is start and end pages of document.ByteArrayInputStream[] splitToBulks(InputStream inputStream, int[][] numberOfPage)
Splits the Pdf file into several documents.The documents can be single-page or multi-pages.
inputStream
- Input PDF stream.numberOfPage
- The start page and the end page of each document.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()); } }
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
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.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.
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.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();
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.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();
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.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
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.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.
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.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);
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.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);
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.int getContentDisposition()
Gets how content will be stored when result of operation is stored into HttpServletResponse object. Possible value: inline / attachment. Default: inline.
ContentDisposition
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.
value
- ContentDisposition elementContentDisposition
SaveOptions getSaveOptions()
Gets or sets save options when result is stored as HttpServletResponse. Default value: PdfSaveOptions.
void setSaveOptions(SaveOptions value)
Sets save options when result is stored as HttpServletResponse. Default value: PdfSaveOptions.
value
- SaveOptions objectString getAttachmentName()
Gets name of attachment when result of operation is stored into HttpServletResponse objects as attachment.
void setAttachmentName(String value)
Sets name of attachment when result of operation is stored into HttpServletResponse objects as attachment.
value
- string value