public final class PdfFileEditor extends Object implements IPdfFileEditor
Implements operations with PDF file: concatenation, splitting, extracting pages, making booklet, etc.
Modifier and Type | Class and Description |
---|---|
static class |
APdfFileEditor.ContentsResizeParameters
Class for specifing page resize parameters.
|
static class |
APdfFileEditor.ContentsResizeValue
Value of margin or content size specified in percents of default space units.
|
static class |
PdfFileEditor.ConcatenateCorruptedFileAction
Action performed when corrupted file was met in concatenation process.
|
static class |
PdfFileEditor.CorruptedItem
Class which provides information about corrupted files in time of concatenation.
|
Modifier and Type | Field and Description |
---|---|
static String |
E_EMPTY_PAGE_RANGE |
static String |
E_SMALL_PAGE_RANGE |
static String |
E_WRONG_PAGE_RANGE |
E_EMPTY_PAGE_RANGE, E_SMALL_PAGE_RANGE, E_WRONG_PAGE_RANGE
Constructor and Description |
---|
PdfFileEditor()
PdfFileEditor constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addMargins(com.aspose.ms.System.IO.Stream source,
com.aspose.ms.System.IO.Stream 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(com.aspose.ms.System.IO.Stream source,
com.aspose.ms.System.IO.Stream 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(Document[] src,
Document dest)
Concatenates documents.
|
boolean |
concatenate(InputStream[] inputStream,
OutputStream outputStream)
Concatenates files
PdfFileEditor fileEditor = new PdfFileEditor();
Stream stream1 = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read);
Stream stream2 = new FileInputStream("file2.pdf", FileMode.Open, FileAccess.Read);
Stream outstream = new FileInputStream("outfile.pdf", FileMode.Create, FileAccess.Write);
fileEditor.concatenate(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.
|
boolean |
concatenate(InputStream firstInputStream,
InputStream secInputStream,
OutputStream outputStream)
Concatenates two files.
|
boolean |
concatenate(String[] inputFiles,
String outputFile)
Concatenates files into one file.
|
boolean |
concatenate(String firstInputFile,
String secInputFile,
String outputFile)
Concatentates two files.
|
boolean |
concatenate(String firstInputFile,
String secInputFile,
String blankPageFile,
String outputFile)
Merges two Pdf documents into a new Pdf document with pages in alternate ways and fill the blank places with blank pages.
|
boolean |
delete(InputStream inputStream,
int[] pageNumber,
OutputStream outputStream)
Deletes pages specified by number array from input file, saves as a new Pdf file.
|
boolean |
delete(String inputFile,
int[] pageNumber,
String outputFile)
Deletes pages specified by number array from input file, saves as a new Pdf file.
|
boolean |
extract(InputStream inputStream,
int[] pageNumber,
OutputStream outputStream)
Extracts pages specified by number array, saves as a new Pdf file.
|
boolean |
extract(InputStream inputStream,
int startPage,
int endPage,
OutputStream outputStream)
Extracts pages from input file,saves as a new Pdf file.
|
boolean |
extract(String inputFile,
int[] pageNumber,
String outputFile)
Extracts pages specified by number array, saves as a new PDF file.
|
boolean |
extract(String inputFile,
int startPage,
int endPage,
String outputFile)
Extracts pages from input file,saves as a new Pdf file.
|
boolean |
getAllowConcatenateExceptions()
If set to true, exceptions are thrown if error occured.
|
String |
getAttachmentName()
Gets name of attachment when result of operation is stored into HttpServletResponse objects as attachment.
|
boolean |
getCloseConcatenatedStreams() |
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.
|
PdfFileEditor.CorruptedItem[] |
getCorruptedItems()
Array of encountered problems when concatenation was performed.
|
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.
|
boolean |
getOptimizeSize()
Gets or sets optimization flag.
|
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.
|
void |
resizeContents(IDocument source,
int[] pages,
APdfFileEditor.ContentsResizeParameters parameters)
Resizes pages of document.
|
boolean |
resizeContents(com.aspose.ms.System.IO.Stream source,
com.aspose.ms.System.IO.Stream destination,
int[] pages,
APdfFileEditor.ContentsResizeParameters parameters)
Resizes contents of pages of the document.
|
boolean |
resizeContents(com.aspose.ms.System.IO.Stream source,
com.aspose.ms.System.IO.Stream destination,
int[] pages,
double newWidth,
double newHeight)
Resizes contents of document pages.
|
boolean |
resizeContents(String source,
String destination,
int[] pages,
APdfFileEditor.ContentsResizeParameters parameters)
Resizes contents of pages in document.
|
boolean |
resizeContents(String source,
String destination,
int[] pages,
double newWidth,
double newHeight)
Resizes contents of document pages.
|
boolean |
resizeContentsPct(com.aspose.ms.System.IO.Stream source,
com.aspose.ms.System.IO.Stream 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) |
void |
setKeepFieldsUnique(boolean value)
If true then field names will be made unique when forms are concatenated.
|
void |
setMergeDuplicateLayers(boolean value) |
void |
setMergeDuplicateOutlines(boolean value) |
void |
setOptimizeSize(boolean value) |
void |
setOwnerPassword(String value)
Sets owner's password if the source input Pdf file is encrypted.
|
void |
setPreserveUserRights(boolean value) |
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.
|
ByteArrayInputStream[] |
splitToPages(String inputFile)
Splits the PDF file into single-page documents.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCloseConcatenatedStreams, getConversionLog, getIncrementalUpdates, getMergeDuplicateLayers, getMergeDuplicateOutlines, getPreserveUserRights, setIncrementalUpdates, setMergeDuplicateLayers, setMergeDuplicateOutlines, setPreserveUserRights
public static final String E_EMPTY_PAGE_RANGE
public static final String E_SMALL_PAGE_RANGE
public static final String E_WRONG_PAGE_RANGE
public PdfFileEditor.CorruptedItem[] getCorruptedItems()
Array of encountered problems when concatenation was performed. For every corrupted document from passed to Concatenate() function new CorruptedItem entry is created. This property may be used only when CorruptedFileAction is ConcatenateIgnoringCorrupted.
//concatenate documents and show information about corrupted documents PdfFileEditor pfe = new PdfFileEditor(); pfe.corruptedFileAction = PdfFileEditor.concatenateCorruptedFileActions().concatenateIgnoringCorrupted(); if (pfe.CorruptedItems.Length >0) { foreach(PdfFileEditor.CorruptedItem item in pfe.CorruptedItems) { Console.WriteLine(item.Index + " reason: " + item.Exception); } }
public int getCorruptedFileAction()
This property defines behavior when concatenating process met corrupted file. Possible values are: StopWithError and ConcatenateIgnoringCorrupted.
getCorruptedFileAction
in interface IPdfFileEditor
public void setCorruptedFileAction(int value)
This property defines behavior when concatenating process met corrupted file. Possible values are: StopWithError and ConcatenateIgnoringCorrupted.
setCorruptedFileAction
in interface IPdfFileEditor
public String getOwnerPassword()
Gets owner's password if the source input Pdf file is encrypted. This property is not implemented yet.
getOwnerPassword
in interface IPdfFileEditor
public void setOwnerPassword(String value)
Sets owner's password if the source input Pdf file is encrypted. This property is not implemented yet.
setOwnerPassword
in interface IPdfFileEditor
public boolean getAllowConcatenateExceptions()
If set to true, exceptions are thrown if error occured. Else excetion are not thrown and methods return false if failed.
PdfFileEditor pfe = new PdfFileEditor(); pfe.setAllowConcatenatedException ( true);
getAllowConcatenateExceptions
in interface IPdfFileEditor
public void setAllowConcatenateExceptions(boolean value)
If set to true, exceptions are thrown if error occured. Else excetion are not thrown and methods return false if failed.
PdfFileEditor pfe = new PdfFileEditor(); pfe.setAllowConcatenatedException ( true);
setAllowConcatenateExceptions
in interface IPdfFileEditor
public void setConvertTo(int value)
Sets PDF file format. Result file will be saved in specified file format. If this property is not specified then file will be save in default PDF format without conversion.
setConvertTo
in interface IPdfFileEditor
public void setCloseConcatenatedStreams(boolean value)
If set to true, streams are closed after operation.
PdfFileEditor pfe = new PdfFileEditor(); pfe.CloseConcatenatedStreams = true;
setCloseConcatenatedStreams
in interface IPdfFileEditor
public String getUniqueSuffix()
Get format of the suffix which is added to field name to make it unique when forms are concatenated. This string must contain %NUM% substring which will be replaced with numbers. For example if UniqueSuffix = "ABC%NUM%" then for field "fieldName" names will be: fieldNameABC1, fieldNameABC2, fieldNameABC3 etc.
getUniqueSuffix
in interface IPdfFileEditor
public void setUniqueSuffix(String value)
Set format of the suffix which is added to field name to make it unique when forms are concatenated. This string must contain %NUM% substring which will be replaced with numbers. For example if UniqueSuffix = "ABC%NUM%" then for field "fieldName" names will be: fieldNameABC1, fieldNameABC2, fieldNameABC3 etc.
PdfFileEditor ed = new PdfFileEditor(); ed.setUniqueSuffix ( "_%NUM%");
setUniqueSuffix
in interface IPdfFileEditor
public boolean getKeepFieldsUnique()
If true then field names will be made unique when forms are concatenated. Suffixes will be added to field names, suffix template may be specified in UniqueSuffix property.
getKeepFieldsUnique
in interface IPdfFileEditor
public void setKeepFieldsUnique(boolean value)
If true then field names will be made unique when forms are concatenated. Suffixes will be added to field names, suffix template may be specified in UniqueSuffix property.
setKeepFieldsUnique
in interface IPdfFileEditor
public boolean concatenate(String firstInputFile, String secInputFile, String outputFile)
Concatentates two files.
PdfFileEditor fileEditor = new PdfFileEditor(); fileEditor.concatenate("file1.pdf", "file2.pdf", "outfile.pdf");
concatenate
in interface IPdfFileEditor
firstInputFile
- First file to concatenate.secInputFile
- Second file to concatenate.outputFile
- Output file.public boolean concatenate(InputStream firstInputStream, InputStream secInputStream, OutputStream outputStream)
Concatenates two files.
PdfFileEditor fileEditor = new PdfFileEditor(); Stream stream1 = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); Stream stream2 = new FileInputStream("file2.pdf", FileMode.Open, FileAccess.Read); Stream outstream = new FileInputStream("outfile.pdf", FileMode.Create, FileAccess.Write); fileEditor.concatenate(stream1, stream2, outstream);
concatenate
in interface IPdfFileEditor
firstInputStream
- Stream of first file.secInputStream
- Stream of second file.outputStream
- Stream where result file will be stored.public boolean concatenate(Document[] src, Document dest)
Concatenates documents.
concatenate
in interface IPdfFileEditor
src
- Array of source documents.dest
- Destination document.public boolean concatenate(String[] inputFiles, String outputFile)
Concatenates files into one file.
PdfFileEditor pfe = new PdfFileEditor(); pfe.concatenate(new string[] { "src1.pdf", "src2.pdf" }, "dest.pdf");
concatenate
in interface IPdfFileEditor
inputFiles
- Array of files to concatenate.outputFile
- Name of output file.public boolean concatenate(InputStream[] inputStream, OutputStream outputStream)
Concatenates files
PdfFileEditor fileEditor = new PdfFileEditor(); Stream stream1 = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); Stream stream2 = new FileInputStream("file2.pdf", FileMode.Open, FileAccess.Read); Stream outstream = new FileInputStream("outfile.pdf", FileMode.Create, FileAccess.Write); fileEditor.concatenate(new Stream[] { stream1, stream2 } , outstream);
concatenate
in interface IPdfFileEditor
inputStream
- Array of streams to be concatenated.outputStream
- Stream where result file will be stored.public boolean concatenate(String firstInputFile, String secInputFile, String blankPageFile, String outputFile)
Merges two Pdf documents into a new Pdf document with pages in alternate ways and fill the blank places with blank pages. e.g.: document1 has 5 pages: p1, p2, p3, p4, p5. document2 has 3 pages: p1', p2', p3'. Merging the two Pdf document will produce the result document with pages:p1, p1', p2, p2', p3, p3', p4, blankpage, p5, blankpage.
PdfFileEditor pfe = new PdfFileEditor(); pfe.concatenate("src1.pdf", "src2.pdf", "blank.pdf", "dest.pdf");
concatenate
in interface IPdfFileEditor
firstInputFile
- First file.secInputFile
- Second file.blankPageFile
- PDF file with blank page.outputFile
- Result file.public boolean concatenate(InputStream firstInputStream, InputStream secInputStream, InputStream blankPageStream, OutputStream outputStream)
Merges two Pdf documents into a new Pdf document with pages in alternate ways and fill the blank places with blank pages. e.g.: document1 has 5 pages: p1, p2, p3, p4, p5. document2 has 3 pages: p1', p2', p3'. Merging the two Pdf document will produce the result document with pages:p1, p1', p2, p2', p3, p3', p4, blankpage, p5, blankpage.
PdfFileEditor fileEditor = new PdfFileEditor(); Stream stream1 = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); Stream stream2 = new FileInputStream("file2.pdf", FileMode.Open, FileAccess.Read); Stream blank = new FileInputStream("blank.pdf", FileMode.Open, FileAccess.Read); Stream outstream = new FileInputStream("outfile.pdf", FileMode.Create, FileAccess.Write); fileEditor.concatenate(new Stream[] { stream1, stream2, blank } , outstream);
concatenate
in interface IPdfFileEditor
firstInputStream
- The first Pdf Stream.secInputStream
- The second Pdf Stream.blankPageStream
- The Pdf Stream with blank pageoutputStream
- Output Pdf Stream.public boolean append(InputStream inputStream, InputStream[] portStreams, int startPage, int endPage, OutputStream outputStream)
Appends pages, which are chosen from array of documents in portStreams. The result document includes firstInputFile and all portStreams documents pages in the range startPage to endPage.
PdfFileEditor fileEditor = new PdfFileEditor(); Stream instream = new FileInputStream("input.pdf", FileMode.Open, FileAccess.Read); Stream stream1 = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); Stream stream2 = new FileInputStream("file2.pdf", FileMode.Open, FileAccess.Read); Stream outstream = new FileInputStream("outfile.pdf", FileMode.Create, FileAccess.Write); fileEditor.append(instream, new Stream[] { stream1, stream2}, 3, 5, outstream);
append
in interface IPdfFileEditor
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.public boolean append(String inputFile, String[] portFiles, int startPage, int endPage, String outputFile)
Appends pages, which are chosen from portFiles documents. The result document includes firstInputFile and all portFiles documents pages in the range startPage to endPage.
PdfFileEditor fileEditor = new PdfFileEditor(); fileEditor.append("input.pdf", new string[] { "file1.pdf", "file2.pdf"}, 3, 5, "outfile.pdf");
append
in interface IPdfFileEditor
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.public boolean append(String inputFile, String portFile, int startPage, int endPage, String outputFile)
Appends pages, which are chosen from portFile within the range from startPage to endPage, in portFile at the end of firstInputFile.
PdfFileEditor fileEditor = new PdfFileEditor(); fileEditor.append("input.pdf", "file1.pdf", 3, 5, "outfile.pdf");
append
in interface IPdfFileEditor
inputFile
- Input Pdf file.portFile
- Pages from Pdf file.startPage
- Page starts in portFile.endPage
- Page ends in portFile.outputFile
- Output Pdf document.public boolean append(InputStream inputStream, InputStream portStream, int startPage, int endPage, OutputStream outputStream)
Appends pages,which are chosen from portStream within the range from startPage to endPage, in portStream at the end of firstInputStream.
PdfFileEditor fileEditor = new PdfFileEditor(); Stream instream = new FileInputStream("input.pdf", FileMode.Open, FileAccess.Read); Stream stream1 = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); Stream outstream = new FileInputStream("outfile.pdf", FileMode.Create, FileAccess.Write); fileEditor.append(instream, stream1, 3, 5, "outfile.pdf");
append
in interface IPdfFileEditor
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.public boolean insert(String inputFile, int insertLocation, String portFile, int startPage, int endPage, String outputFile)
Inserts pages from an other file into the Pdf file at a position.
PdfFileEditor pfe = new PdfFileEditor(); pfe.insert("file1.pdf", 1, "file2.pdf", 2, 6, "out.pdf");
insert
in interface IPdfFileEditor
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.public boolean insert(InputStream inputStream, int insertLocation, InputStream portStream, int startPage, int endPage, OutputStream outputStream)
Inserts pages from an other file into the input Pdf file.
PdfFileEditor pfe = new PdfFileEditor(); Stream sourceStream = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); Stream insertedStream = new FileInputStream("file2.pdf", FileMode.Open, FileAccess.Read); OutputStream outStream = new FileInputStream("out.pdf", FileMode.Create, FileAccess.Write); pfe.insert(sourceStream, 1, insertedStream, 2, 6, outStream);
insert
in interface IPdfFileEditor
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.public boolean insert(String inputFile, int insertLocation, String portFile, int[] pageNumber, String outputFile)
Inserts pages from an other file into the input Pdf file.
PdfFileEditor pfe = new PdfFileEditor(); Stream sourceStream = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); Stream insertedStream = new FileInputStream("file2.pdf", FileMode.Open, FileAccess.Read); OutputStream outStream = new FileInputStream("out.pdf", FileMode.Create, FileAccess.Write); pfe.insert(sourceStream, 1, insertedStream, 2, 6, outStream);
insert
in interface IPdfFileEditor
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.public boolean insert(InputStream inputStream, int insertLocation, InputStream portStream, int[] pageNumber, OutputStream outputStream)
Inserts pages from an other file into the input Pdf file.
PdfFileEditor pfe = new PdfFileEditor(); Stream sourceStream = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); Stream insertedStream = new FileInputStream("file2.pdf", FileMode.Open, FileAccess.Read); OutputStream outStream = new FileInputStream("out.pdf", FileMode.Create, FileAccess.Write); pfe.Insert(sourceStream, 1, insertedStream, new int[] { 3, 4, 5}, outStream);
insert
in interface IPdfFileEditor
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.public boolean delete(String inputFile, int[] pageNumber, String outputFile)
Deletes pages specified by number array from input file, saves as a new Pdf file.
PdfFileEditor pfe = new PdfFileEditor(); pfe.delete("input.pdf", new int[] { 2, 3 }, "out.pdf");
delete
in interface IPdfFileEditor
inputFile
- Input file path.pageNumber
- Index of page out of the input file.outputFile
- Output file path.public boolean delete(InputStream inputStream, int[] pageNumber, OutputStream outputStream)
Deletes pages specified by number array from input file, saves as a new Pdf file.
PdfFileEditor pfe = new PdfFileEditor(); Stream intputStream = new FileInputStream("input.pdf", FileMode.Open, FileAccess.Read); OutputStream outputStream = new FileInputStream("output.pdf", FileMode.Create, FileAccess.Write); pfe.Delete(inputStream, new int[] { 2, 3 }, outputStream);
delete
in interface IPdfFileEditor
inputStream
- Input file Stream.pageNumber
- Index of page out of the input file.outputStream
- Output file stream.public boolean extract(String inputFile, int startPage, int endPage, String outputFile)
Extracts pages from input file,saves as a new Pdf file.
PdfFileEditor pfe = new PdfFileEditor(); pfe.Extract("input.pdf", 3, 7, "output.pdf");
extract
in interface IPdfFileEditor
inputFile
- Input Pdf file path.startPage
- Start page number.endPage
- End page number.outputFile
- Output Pdf file path.public boolean extract(String inputFile, int[] pageNumber, String outputFile)
Extracts pages specified by number array, saves as a new PDF file.
PdfFileEditor pfe = new PdfFileEditor(); pfe.extract("input.pdf", new int[] { 3, 5, 7 }, "output.pdf");
extract
in interface IPdfFileEditor
inputFile
- Input file path.pageNumber
- Index of page out of the input file.outputFile
- Output file path.public boolean extract(InputStream inputStream, int startPage, int endPage, OutputStream outputStream)
Extracts pages from input file,saves as a new Pdf file.
PdfFileEditor pfe = new PdfFileEditor(); Stream sourceStream = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); OutputStream outStream = new FileInputStream("out.pdf", FileMode.Create, FileAccess.Write); pfe.extract(sourceStream, 1, 3, 6, outStream);
extract
in interface IPdfFileEditor
inputStream
- Input file Stream.startPage
- Start page number.endPage
- End page number.outputStream
- Output Pdf file Stream.public boolean extract(InputStream inputStream, int[] pageNumber, OutputStream outputStream)
Extracts pages specified by number array, saves as a new Pdf file.
PdfFileEditor pfe = new PdfFileEditor(); Stream sourceStream = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); OutputStream outStream = new FileInputStream("out.pdf", FileMode.Create, FileAccess.Write); pfe.extract(sourceStream, new int[] { 3, 5, 8 }, outStream);
extract
in interface IPdfFileEditor
inputStream
- Input file Stream.pageNumber
- Index of page out of the input file.outputStream
- Output file stream.public boolean splitFromFirst(String inputFile, int location, String outputFile)
Splits Pdf file from first page to specified location,and saves the front part as a new file.
PdfFileEditor pfe = new PdfFileEditor(); pfe.splitFromFirst("input.pdf", 5, "out.pdf");
splitFromFirst
in interface IPdfFileEditor
inputFile
- Source Pdf file.location
- The splitting point.outputFile
- Output Pdf file.public boolean splitFromFirst(InputStream inputStream, int location, OutputStream outputStream)
Splits from start to specified location,and saves the front part in output Stream.
PdfFileEditor pfe = new PdfFileEditor(); Stream sourceStream = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); OutputStream outStream = new FileInputStream("out.pdf", FileMode.Create, FileAccess.Write); pfe.splitFromFirst(sourceStream, 5, outStream);
splitFromFirst
in interface IPdfFileEditor
inputStream
- Source Pdf file Stream.location
- The splitting point.outputStream
- Output file Stream.
public boolean splitToEnd(String inputFile, int location, String outputFile)
Splits from location, and saves the rear part as a new file.
PdfFileEditor pfe = new PdfFileEditor(); pfe.splitToEnd("input.pdf", 5, "out.pdf");
splitToEnd
in interface IPdfFileEditor
inputFile
- Source Pdf file.location
- The splitting position.outputFile
- Output Pdf file path.public boolean splitToEnd(InputStream inputStream, int location, OutputStream outputStream)
Splits from specified location, and saves the rear part as a new file Stream.
PdfFileEditor pfe = new PdfFileEditor(); Stream sourceStream = new FileInputStream("file1.pdf", FileMode.Open, FileAccess.Read); OutputStream outStream = new FileInputStream("out.pdf", FileMode.Create, FileAccess.Write); pfe.splitToEnd(sourceStream, 5, outStream);
splitToEnd
in interface IPdfFileEditor
inputStream
- Source Pdf file Stream.location
- The splitting position.outputStream
- Output Pdf file Stream.
public boolean makeBooklet(String inputFile, String outputFile)
Makes booklet from the input file to output file.
PdfFileEditor pfe = new PdfFileEditor(); pfe.makeBooklet("input.pdf", "output.pdf");
makeBooklet
in interface IPdfFileEditor
inputFile
- Input pdf file path and name.outputFile
- Output pdf file path and name.public boolean makeBooklet(InputStream inputStream, OutputStream outputStream)
Makes booklet from the InputStream to outputStream.
PdfFileEditor pfe = new PdfFileEditor(); InputStream inputStream = new FileInputStream("input.pdf", FileMode.Open, FileAccess.Read); OutputStream outputStream = new FileInputStream("output.pdf", FileMode.Create, FileAccess.Write); pfe.makeBooklet(inputStream, outputStream);
makeBooklet
in interface IPdfFileEditor
inputStream
- Input pdf stream.outputStream
- output pdf stream.public boolean makeBooklet(String inputFile, String outputFile, PageSize pageSize)
Makes booklet from the inputFile to outputFile.
PdfFileEditor pfe = new PdfFileEditor(); pfe.makeBooklet("input.pdf", "output.pdf", PageSize.A4);
makeBooklet
in interface IPdfFileEditor
inputFile
- Input pdf file path and name.outputFile
- Output pdf file path and name.pageSize
- The page size of the output pdf file.public boolean makeBooklet(InputStream inputStream, OutputStream outputStream, PageSize pageSize)
Makes booklet from the input stream and save result into output stream.
PdfFileEditor pfe = new PdfFileEditor(); InputStream inputStream = new FileInputStream("input.pdf", FileMode.Open, FileAccess.Read); OutputStream outputStream = new FileInputStream("output.pdf", FileMode.Create, FileAccess.Write); pfe.makeBooklet(inputStream, outputStream, PageSize.A4);
makeBooklet
in interface IPdfFileEditor
inputStream
- Input PDF stream.outputStream
- output pdf stream.pageSize
- The page size of the output pdf file.public boolean makeBooklet(String inputFile, String outputFile, int[] leftPages, int[] rightPages)
Makes customized booklet from the firstInputFile to outputFile.
PdfFileEditor pfe = new PdfFileEditor(); pfe.makeBooklet("input.pdf", "output.pdf", new int[] { 2, 4, 6 }, new int[] 1, 3, 5, 7 });
makeBooklet
in interface IPdfFileEditor
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.public boolean makeBooklet(InputStream inputStream, OutputStream outputStream, int[] leftPages, int[] rightPages)
Makes customized booklet from the firstInputStream to outputStream.
PdfFileEditor pfe = new PdfFileEditor(); InputStream inputStream = new FileInputStream("input.pdf", FileMode.Open, FileAccess.Read); OutputStream outputStream = new FileInputStream("output.pdf", FileMode.Create, FileAccess.Write); pfe.makeBooklet(inputStream, outputStream, new int[] { 2, 4, 6 }, new int[] 1, 3, 5, 7 });
makeBooklet
in interface IPdfFileEditor
inputStream
- The input stream.outputStream
- output pdf stream.leftPages
- The left pages.rightPages
- The right pages.public boolean makeBooklet(String inputFile, String outputFile, PageSize pageSize, int[] leftPages, int[] rightPages)
Makes customized booklet from the firstInputFile to outputFile.
PdfFileEditor pfe = new PdfFileEditor(); pfe.makeBooklet("input.pdf", "output.pdf", PageSize.A4, new int[] { 2, 4, 6 }, new int[] 1, 3, 5, 7 });
makeBooklet
in interface IPdfFileEditor
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.public boolean makeBooklet(InputStream inputStream, OutputStream outputStream, PageSize pageSize, int[] leftPages, int[] rightPages)
Makes booklet from the firstInputStream to outputStream.
PdfFileEditor pfe = new PdfFileEditor(); InputStream inputStream = new FileInputStream("input.pdf", FileMode.Open, FileAccess.Read); OutputStream outputStream = new FileInputStream("output.pdf", FileMode.Create, FileAccess.Write); pfe.makeBooklet(inputStream, outputStream, PageSize.A4, new int[] { 2, 4, 6 }, new int[] 1, 3, 5, 7 });
makeBooklet
in interface IPdfFileEditor
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.public boolean makeNUp(String inputFile, String outputFile, int x, int y)
Makes N-Up document from the firstInputFile to outputFile.
PdfFileEditor pfe = new PdfFileEditor(); pfe.makeNUp("input.pdf", "output.pdf", 3, 3);
makeNUp
in interface IPdfFileEditor
inputFile
- Input pdf file path and name.outputFile
- Output pdf file path and name.x
- Number of columns.y
- Number of rows.public boolean makeNUp(InputStream inputStream, OutputStream outputStream, int x, int y)
Makes N-Up document from the input stream and saves result into output stream.
PdfFileEditor pfe = new PdfFileEditor(); InputStream inputStream = new FileInputStream("input.pdf", FileMode.Open, FileAccess.Read); OutputStream outputStream = new FileInputStream("output.pdf", FileMode.Create, FileAccess.Write); pfe.makeNUp(inputStream, outputStream, 3, 3);
makeNUp
in interface IPdfFileEditor
inputStream
- Input pdf stream.outputStream
- Output pdf stream.x
- Number of columns.y
- Number of rows.public boolean makeNUp(InputStream inputStream, OutputStream outputStream, int x, int y, PageSize pageSize)
Makes N-Up document from the first input stream to output stream.
PdfFileEditor pfe = new PdfFileEditor(); InputStream inputStream = new FileInputStream("input.pdf", FileMode.Open, FileAccess.Read); OutputStream outputStream = new FileInputStream("output.pdf", FileMode.Create, FileAccess.Write); pfe.MakeNUp(inputStream, outputStream, 3, 3, PageSize.A4);
makeNUp
in interface IPdfFileEditor
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.public boolean makeNUp(String firstInputFile, String secondInputFile, String outputFile)
Makes N-Up document from the two input PDF files to outputFile. Each page of outputFile will contain two pages, one page is from the first input file and another is from the second input file. The two pages are piled up horizontally.
PdfFileEditor pfe = new PdfFileEditor(); pfe.makeNUp("input1.pdf", "input2.pdf", "output.pdf");
makeNUp
in interface IPdfFileEditor
firstInputFile
- first input file.secondInputFile
- second input file.outputFile
- Output pdf file path and name.public boolean makeNUp(InputStream firstInputStream, InputStream secondInputStream, OutputStream outputStream)
Makes N-Up document from the two input PDF streams to outputStream.
PdfFileEditor pfe = new PdfFileEditor(); Stream input1 = new FileInputStream("input1.pdf", FileMode.Open, FileAccess.Read); Stream input2 = new FileInputStream("input2.pdf", FileMode.Open, FileAccess.Read); Stream output = new FileInputStream("output.pdf"); pfe.makeNUp(input1, input2, output);
makeNUp
in interface IPdfFileEditor
firstInputStream
- first input stream.secondInputStream
- second input stream.outputStream
- Output pdf stream.public boolean makeNUp(String[] inputFiles, String outputFile, boolean isSidewise)
Makes N-Up document from the multi input PDF files to outputFile. Each page of outputFile will contain multi pages, which are combination with pages in the input files of the same page number. The multi pages piled up horizontally if isSidewise is true and piled up vertically if isSidewise is false.
PdfFileEditor pfe = new PdfFileEditor(); pfe.makeNUp(new string[] { "input1.pdf", "input2.pdf", "input3.pdf" }, "output.pdf", false);
makeNUp
in interface IPdfFileEditor
inputFiles
- Input Pdf files.outputFile
- Output pdf file path and name.isSidewise
- Piled up way, true for horizontally and flase for vertically.public boolean makeNUp(InputStream[] inputStreams, OutputStream outputStream, boolean isSidewise)
Makes N-Up document from the multi input PDF streams to outputStream. Each page of outputStream will contain multi pages, which are combination with pages in the input streams of the same page number. The multi-pages piled up horizontally if isSidewise is true and piled up vertically if isSidewise is false.
PdfFileEditor pfe = new PdfFileEditor(); Stream stream1 = new FileInputStream("input1.pdf", FileMode.Open, FileAccess.Read); Stream stream2 = new FileInputStream("input2.pdf", FileMode.Open, FileAccess.Read); Stream stream3 = new FileInputStream("input3.pdf", FileMode.Open, FileAccess.Read); Stream output = new FileInputStream("output.pdf", FileMode.Create, FileAccess.Write); pfe.makeNUp(new Stream[] { stream1, stream2, stream3 }, output, false);
makeNUp
in interface IPdfFileEditor
inputStreams
- Input Pdf streams.outputStream
- Output pdf stream.isSidewise
- Piled up way, true for horizontally and flase for verticallypublic 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);
makeNUp
in interface IPdfFileEditor
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.public ByteArrayInputStream[] splitToPages(String inputFile)
Splits the PDF file into single-page documents.
splitToPages
in interface IPdfFileEditor
inputFile
- Input PDF file name.public ByteArrayInputStream[] splitToPages(InputStream inputStream)
Splits the Pdf file into single-page documents.
splitToPages
in interface IPdfFileEditor
inputStream
- Input Pdf stream.public ByteArrayInputStream[] splitToBulks(String inputFile, int[][] numberOfPage)
Splits the Pdf file into several documents.The documents can be single-page or multi-pages.
splitToBulks
in interface IPdfFileEditor
inputFile
- Input PDF file.numberOfPage
- Array which contains array of double elements, which is start and end pages of document.public ByteArrayInputStream[] splitToBulks(InputStream inputStream, int[][] numberOfPage)
Splits the Pdf file into several documents.The documents can be single-page or multi-pages.
splitToBulks
in interface IPdfFileEditor
inputStream
- Input PDF stream.numberOfPage
- The start page and the end page of each document.public Exception getLastException()
Gets last occured exception. May be used to check the reason of failure when AllowconcatenateExceptions = false.
PdfFileEditor pfe = new PdfFileEditor(); pfe.allowConcatenateExceptions = false; if (!pfe.concatenate("file1.pdf", "file2.pdf", "file3.pdf")) { System.out.println("Error occured:"); if (pfe.getLastException() != null) { System.out.println(pfe.getLastException().getMessage()); if (pfe.getLastException().getInnerException() != null) System.out.println(pfe.getLastException().getInnerException().getMessage); } }
getLastException
in interface IPdfFileEditor
public boolean resizeContents(com.aspose.ms.System.IO.Stream source, com.aspose.ms.System.IO.Stream destination, int[] pages, APdfFileEditor.ContentsResizeParameters parameters)
Resizes contents of pages of the document.
PdfFileEditor fileEditor = new PdfFileEditor(); Stream src = new Stream("input.pdf", FileMode.Open); Stream dest = new Stream("output.pdf", FileMode.Create); PdfFileEditor.contentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters( //left margin = 10% of page width PdfFileEditor.ContentsResizeValue.percents(10), //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%) null, //right margin is 10% of page PdfFileEditor.ContentsResizeValue.percents(10), //top margin = 10% of height PdfFileEditor.ContentsResizeValue.percents(10), //new contents height is calculated automatically (similar to width) null, //bottom margin is 10% PdfFileEditor.ContentsResizeValue.percents(10) ); fileEditor.resizeContents(src, dest, new int[] { 1, 2,.3}, parameters); dest.Close();
source
- Stream with source document.destination
- Stream with the destination document.pages
- Array of page indexes.parameters
- Resize parameters.public boolean resizeContents(com.aspose.ms.System.IO.Stream source, com.aspose.ms.System.IO.Stream 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(); Stream src = new Stream("input.pdf", FileMode.Open); Stream dest = new Stream("output.pdf", FileMode.Create); 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
resizeContents
in interface IPdfFileEditor
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.public boolean resizeContentsPct(com.aspose.ms.System.IO.Stream source, com.aspose.ms.System.IO.Stream 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(); Stream src = new Stream("input.pdf", FileMode.Open); Stream dest = new Stream("output.pdf", FileMode.Create); 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.
resizeContentsPct
in interface IPdfFileEditor
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.public boolean addMargins(com.aspose.ms.System.IO.Stream source, com.aspose.ms.System.IO.Stream 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(); Stream src = new Stream("input.pdf", FileMode.Open); Stream dest = new Stream("output.pdf", FileMode.Create); fileEditor.addMargins(src, dest, //process pages 1, 2, 3 new int[] { 1, 2, 3}, //left margin is 10 units 10, //right margin is 5 units 5, //top margin is 5 units 5, //bottom margin is 5 units 5); dest.Close();
addMargins
in interface IPdfFileEditor
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.public boolean addMarginsPct(com.aspose.ms.System.IO.Stream source, com.aspose.ms.System.IO.Stream 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(); Stream src = new Stream("input.pdf", FileMode.Open); Stream dest = new Stream("output.pdf", FileMode.Create); fileEditor.addMarginsPct(src, dest, //process pages 1, 2, 3 new int[] { 1, 2, 3}, //left margin is 15% of page width 15, //right margin is 10% of page width 10, //top margin is 20% of page width 20, //bottom margin is 5% of page width 5); dest.Close();
addMarginsPct
in interface IPdfFileEditor
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.public boolean resizeContents(String source, String destination, int[] pages, double newWidth, double newHeight)
Resizes contents of document pages. Shrinks contents of page and adds margins. New size of contents is specified in default space units.
PdfFileEditor fileEditor = new PdfFileEditor(); fileEditor.ResizeContents("input.pdf", "output.pdf", //resize all pages of document null, //new contents width = 200 200, //new contents height = 300 300); // rest area of page will be empty
resizeContents
in interface IPdfFileEditor
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.public boolean resizeContentsPct(String source, String destination, int[] pages, double newWidth, double newHeight)
Resizes contents of document pages. Shrinks contents of page and adds margins. New contents size is specified in percents.
PdfFileEditor fileEditor = new PdfFileEditor(); fileEditor.ResizePct("input.pdf", "output.pdf", //resize all pages of document null, //new contents width = 60% of initial size 60, //new contents height = 60% of initial size 60); // Rest area of page will be empty (page margins). Size of left and right margins is (100% - 60%) / 2 = 20% // The same for top and bottom margins.
resizeContentsPct
in interface IPdfFileEditor
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.public boolean addMargins(String source, String destination, int[] pages, double leftMargin, double rightMargin, double topMargin, double bottomMargin)
Resizes page contents and add specifed margins. Margins are specified in default space units.
PdfFileEditor fileEditor = new PdfFileEditor(); fileEditor.addMargins("input.pdf", "output.pdf", //process pages 1, 2, 3 new int[] { 1, 2, 3}, //left margin is 10 units 10, //right margin is 5 units 5, //top margin is 5 units 5, //bottom margin is 5 units 5);
addMargins
in interface IPdfFileEditor
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.public boolean addMarginsPct(String source, String destination, int[] pages, double leftMargin, double rightMargin, double topMargin, double bottomMargin)
Resizes page contents and add specified margins. Margins are specified in percents of intitial page size.
PdfFileEditor fileEditor = new PdfFileEditor(); fileEditor.addMarginsPct("input.pdf", "output.pdf", //process pages 1, 2, 3 new int[] { 1, 2, 3}, //left margin is 15% of page width 15, //right margin is 10% of page width 10, //top margin is 20% of page width 20, //bottom margin is 5% of page width 5);
addMarginsPct
in interface IPdfFileEditor
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.public boolean resizeContents(String source, String destination, int[] pages, APdfFileEditor.ContentsResizeParameters parameters)
Resizes contents of pages in document. If page is shrinked blank margins are added around the page.
PdfFileEditor fileEditor = new PdfFileEditor(); PdfFileEditor.contentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters( //left margin = 10% of page width PdfFileEditor.ContentsResizeValue.percents(10), //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%) null, //right margin is 10% of page PdfFileEditor.ContentsResizeValue.percents(10), //top margin = 10% of height PdfFileEditor.ContentsResizeValue.percents(10), //new contents height is calculated automatically (similar to width) null, //bottom margin is 10% PdfFileEditor.ContentsResizeValue.percents(10) ); fileEditor.ResizeContents("input.pdf", "output.pdf", new int[] { 1, 2,.3}, parameters);
source
- Source document path.destination
- Destination document path.pages
- Array of page indexes (page index starts from 1).parameters
- Parameters of page resize.public void resizeContents(IDocument source, int[] pages, APdfFileEditor.ContentsResizeParameters parameters)
Resizes pages of document. Blank margins are added around of shrinked page.
PdfFileEditor fileEditor = new PdfFileEditor(); Document doc = new Document("input.pdf"); PdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters( //left margin = 10% of page width PdfFileEditor.ContentsResizeValue.percents(10), //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%) null, //right margin is 10% of page PdfFileEditor.ContentsResizeValue.percents(10), //top margin = 10% of height PdfFileEditor.ContentsResizeValue.percents(10), //new contents height is calculated automatically (similar to width) null, //bottom margin is 10% PdfFileEditor.ContentsResizeValue.percents(10) ); fileEditor.resizeContents(doc, new int[] { 1, 2,.3}, parameters); doc.save("output.pdf");
source
- Source document.pages
- List of page indexes.parameters
- Resize parameters.public int getContentDisposition()
Gets how content will be stored when result of operation is stored into HttpServletResponse object. Possible value: inline / attachment. Default: inline.
public void setContentDisposition(int value)
Sets how content will be stored when result of operation is stored into HttpServletResponse object. Possible value: inline / attachment. Default: inline.
public SaveOptions getSaveOptions()
Gets or sets save options when result is stored as HttpServletResponse. Default value: PdfSaveOptions.
public void setSaveOptions(SaveOptions value)
Sets save options when result is stored as HttpServletResponse. Default value: PdfSaveOptions.
public String getAttachmentName()
Gets name of attachment when result of operation is stored into HttpServletResponse objects as attachment.
public void setAttachmentName(String value)
Sets name of attachment when result of operation is stored into HttpServletResponse objects as attachment.
public String getConversionLog()
Gets log of conversion process.
getConversionLog
in interface IPdfFileEditor
public boolean getMergeDuplicateLayers()
Optional contents of concatentated documents with equal names will be merged into one layer in resulstant document if this property is true. Else, layers with equal names will be save as different layers in resultant document.
getMergeDuplicateLayers
in interface IPdfFileEditor
public void setMergeDuplicateLayers(boolean value)
setMergeDuplicateLayers
in interface IPdfFileEditor
public boolean getMergeDuplicateOutlines()
If true, duplicate outlines are merged.
getMergeDuplicateOutlines
in interface IPdfFileEditor
public void setMergeDuplicateOutlines(boolean value)
setMergeDuplicateOutlines
in interface IPdfFileEditor
public boolean getPreserveUserRights()
If true, user rights of first document are applied to concatenated document. User rights of all other documents are ignored.
getPreserveUserRights
in interface IPdfFileEditor
public void setPreserveUserRights(boolean value)
setPreserveUserRights
in interface IPdfFileEditor
public boolean getIncrementalUpdates()
If true, incremental updates are made during concatenation.
getIncrementalUpdates
in interface IPdfFileEditor
public void setIncrementalUpdates(boolean value)
setIncrementalUpdates
in interface IPdfFileEditor
public boolean getOptimizeSize()
Gets or sets optimization flag. Equal resource streams in resultant file are merged into one PDF object if this flag set. This allows to decrease resultant file size but may cause slower execution and larger memory requirements. Default value: false.
public void setOptimizeSize(boolean value)
public boolean getCloseConcatenatedStreams()
getCloseConcatenatedStreams
in interface IPdfFileEditor
Copyright © 2017 Aspose. All Rights Reserved.