PdfFileEditor
Overview
PdfFileEditor is a class in Aspose.Pdf FOSS for Java.
Provides methods for manipulating PDF files: concatenating, extracting pages, splitting, inserting, and deleting pages.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
copyOutlines | boolean | Read | Returns whether {@code concatenate(…)} should copy /Outlines from the |
| source documents into the destination. | |||
copyLogicalStructure | boolean | Read | Returns whether {@code concatenate(…)} should preserve /StructTreeRoot |
| logical-structure information from the source documents. | |||
keepActions | boolean | Read | Returns whether page-level /AA (additional actions) entries should be |
| kept when copying pages. | |||
lastException | Exception | Read | Returns the last exception captured by a Try* wrapper, or {@code null} if none. |
useDiskBuffer | boolean | Read | Returns whether this editor should prefer disk-buffer-oriented |
| concatenation strategies for large workloads. |
Methods
| Signature | Description |
|---|---|
PdfFileEditor() | Creates a new {@code PdfFileEditor} instance. |
isCopyOutlines() → boolean | Returns whether {@code concatenate(…)} should copy /Outlines from the |
| source documents into the destination. | |
setCopyOutlines(copyOutlines: boolean) | Enables or disables /Outlines copying during concatenation. |
isCopyLogicalStructure() → boolean | Returns whether {@code concatenate(…)} should preserve /StructTreeRoot |
| logical-structure information from the source documents. | |
setCopyLogicalStructure(copyLogicalStructure: boolean) | Enables or disables /StructTreeRoot copying during concatenation. |
isKeepActions() → boolean | Returns whether page-level /AA (additional actions) entries should be |
| kept when copying pages. | |
setKeepActions(keepActions: boolean) | Enables or disables /AA preservation when copying pages. |
getLastException() → Exception | Returns the last exception captured by a Try* wrapper, or {@code null} if none. |
isUseDiskBuffer() → boolean | Returns whether this editor should prefer disk-buffer-oriented |
| concatenation strategies for large workloads. | |
setUseDiskBuffer(useDiskBuffer: boolean) | Enables or disables disk-buffer-oriented concatenation strategies. |
bindPdf(inputFile: String) → boolean | Binds a PDF file to this editor. |
bindPdf(inputStream: InputStream) → boolean | Binds a PDF from an input stream. |
bindPdf(document: Document) → boolean | Binds an existing {@link Document} to this editor. |
save(outputFile: String) → boolean | Saves the bound document to a file. |
save(outputStream: OutputStream) → boolean | Saves the bound document to an output stream. |
concatenate(inputFiles: String[], outputFile: String) → boolean | Concatenates multiple PDF files into one output file. |
addPageBreak(src: Document, dst: Document, breaks: PageBreak[]) → boolean | Splits each page in {@code src} at the configured {@link PageBreak} y-offset |
| and appends both halves to {@code dst}. | |
concatenate(inputStreams: InputStream[], outputStream: OutputStream) → boolean | Concatenates multiple PDF streams into one output stream. |
concatenate(documents: Document[], result: Document) → boolean | Concatenates multiple documents, appending all pages to the result document. |
extract(inputFile: String, startPage: int, endPage: int, outputFile: String) → boolean | Extracts a range of pages from a PDF file to an output file. |
extract(inputFile: String, pageNumbers: int[], outputFile: String) → boolean | Extracts specific pages from a PDF file to an output file. |
splitToPages(inputFile: String) → java.io.ByteArrayOutputStream[] | Splits the input PDF into one byte-array per page, returned as an |
| array of {@link java.io.ByteArrayOutputStream}. | |
splitToPages(inputFile: String, outputDir: String) → boolean | |
splitFromFirst(inputStream: InputStream, pageNum: int, outputStream: OutputStream) → boolean | Extracts pages {@code 1..pageNum} from the input stream into the output stream. |
splitToEnd(inputStream: InputStream, pageNum: int, outputStream: OutputStream) → boolean | Extracts pages {@code pageNum..lastPage} from the input stream into the output stream. |
insert(inputFile: String, insertPosition: int, portFile: String, startPage: int, endPage: int, outputFile: String) → boolean | Inserts pages from a source file into a target file at the specified position. |
delete(inputFile: String, pageNumbers: int[], outputFile: String) → boolean | Deletes specified pages from a PDF file and saves the result. |
makeNUp(inputFile: String, outputFile: String, nX: int, nY: int) → boolean | Arranges pages into an N-up layout. |
resizeContents(document: Document, parameters: ContentsResizeParameters) | Resizes contents of all pages in the document by wrapping each page’s |
| content stream in a {@code q scaleX 0 0 scaleY tx ty cm … | |
resizeContents(document: Document, pageNumbers: int[], parameters: ContentsResizeParameters) | Resizes contents of specific pages in the document by wrapping each |
| targeted page’s content stream in a {@code q … | |
resizeContents(inputFile: String, outputFile: String, parameters: ContentsResizeParameters) → boolean | File-path overload mirroring {@code PdfFileEditor.ResizeContents(string, string, ContentsResizeParameters)} |
| in Aspose. | |
makeBooklet(inputFile: String, outputFile: String) → boolean | Arranges pages into a booklet layout. |
makeBooklet(inputStream: InputStream, outputStream: OutputStream) → boolean | Arranges pages from the input stream into a booklet layout saved to the output stream. |
makeBooklet(inputFile: String, outputFile: String, pageSize: PageSize) → boolean | Arranges pages into a booklet layout using the specified target page size. |
makeBooklet(inputStream: InputStream, outputStream: OutputStream, pageSize: PageSize) → boolean | Arranges pages from the input stream into a booklet layout with the specified target page size. |
concatenate(firstInputFile: String, secondInputFile: String, outputFile: String) → boolean | Concatenates two PDF files into one output file. |
append(inputFile: String, portFile: String, startPage: int, endPage: int, outputFile: String) → boolean | Appends a range of pages from {@code portFile} to the end of {@code inputFile}, |
| writing the result to {@code outputFile}. | |
splitFromFirst(inputFile: String, pageNum: int, outputFile: String) → boolean | Extracts pages {@code 1..pageNum} into {@code outputFile}. |
splitToEnd(inputFile: String, pageNum: int, outputFile: String) → boolean | Extracts pages {@code pageNum..lastPage} into {@code outputFile}. |
addMargins(inputFile: String, outputFile: String, pages: int[], left: double, right: double, top: double, bottom: double) → boolean | Expands the MediaBox and CropBox of the specified pages by the given margins (in points), |
| preserving the original content position (content shifts by {@code left} and {@code bottom}). | |
tryConcatenate(inputFiles: String[], outputFile: String) → boolean | Try-variant of {@link #concatenate(String[], String)}. |
tryConcatenate(inputStreams: InputStream[], outputStream: OutputStream) → boolean | Try-variant of {@link #concatenate(InputStream[], OutputStream)}. |
tryMakeBooklet(inputFile: String, outputFile: String) → boolean | Try-variant of {@link #makeBooklet(String, String)}. |
tryMakeNUp(inputFile: String, outputFile: String, nX: int, nY: int) → boolean | Try-variant of {@link #makeNUp(String, String, int, int)}. |
tryExtract(inputFile: String, startPage: int, endPage: int, outputFile: String) → boolean | Try-variant of {@link #extract(String, int, int, String)}. |
tryExtract(inputFile: String, pageNumbers: int[], outputFile: String) → boolean | Try-variant of {@link #extract(String, int[], String)}. |
tryResize(document: Document, parameters: ContentsResizeParameters) → boolean | Try-variant of {@link #resizeContents(Document, ContentsResizeParameters)}. |
tryAppend(inputFile: String, portFile: String, startPage: int, endPage: int, outputFile: String) → boolean | Try-variant of {@link #append(String, String, int, int, String)}. |
tryInsert(inputFile: String, insertPosition: int, portFile: String, startPage: int, endPage: int, outputFile: String) → boolean | Try-variant of {@link #insert(String, int, String, int, int, String)}. |
tryDelete(inputFile: String, pageNumbers: int[], outputFile: String) → boolean | Try-variant of {@link #delete(String, int[], String)}. |
trySplitFromFirst(inputFile: String, pageNum: int, outputFile: String) → boolean | Try-variant of {@link #splitFromFirst(String, int, String)}. |
trySplitToEnd(inputFile: String, pageNum: int, outputFile: String) → boolean | Try-variant of {@link #splitToEnd(String, int, String)}. |