PdfFileEditor

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

NameTypeAccessDescription
copyOutlinesbooleanReadReturns whether {@code concatenate(…)} should copy /Outlines from the
source documents into the destination.
copyLogicalStructurebooleanReadReturns whether {@code concatenate(…)} should preserve /StructTreeRoot
logical-structure information from the source documents.
keepActionsbooleanReadReturns whether page-level /AA (additional actions) entries should be
kept when copying pages.
lastExceptionExceptionReadReturns the last exception captured by a Try* wrapper, or {@code null} if none.
useDiskBufferbooleanReadReturns whether this editor should prefer disk-buffer-oriented
concatenation strategies for large workloads.

Methods

SignatureDescription
PdfFileEditor()Creates a new {@code PdfFileEditor} instance.
isCopyOutlines()booleanReturns whether {@code concatenate(…)} should copy /Outlines from the
source documents into the destination.
setCopyOutlines(copyOutlines: boolean)Enables or disables /Outlines copying during concatenation.
isCopyLogicalStructure()booleanReturns whether {@code concatenate(…)} should preserve /StructTreeRoot
logical-structure information from the source documents.
setCopyLogicalStructure(copyLogicalStructure: boolean)Enables or disables /StructTreeRoot copying during concatenation.
isKeepActions()booleanReturns 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()ExceptionReturns the last exception captured by a Try* wrapper, or {@code null} if none.
isUseDiskBuffer()booleanReturns 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)booleanBinds a PDF file to this editor.
bindPdf(inputStream: InputStream)booleanBinds a PDF from an input stream.
bindPdf(document: Document)booleanBinds an existing {@link Document} to this editor.
save(outputFile: String)booleanSaves the bound document to a file.
save(outputStream: OutputStream)booleanSaves the bound document to an output stream.
concatenate(inputFiles: String[], outputFile: String)booleanConcatenates multiple PDF files into one output file.
addPageBreak(src: Document, dst: Document, breaks: PageBreak[])booleanSplits each page in {@code src} at the configured {@link PageBreak} y-offset
and appends both halves to {@code dst}.
concatenate(inputStreams: InputStream[], outputStream: OutputStream)booleanConcatenates multiple PDF streams into one output stream.
concatenate(documents: Document[], result: Document)booleanConcatenates multiple documents, appending all pages to the result document.
extract(inputFile: String, startPage: int, endPage: int, outputFile: String)booleanExtracts a range of pages from a PDF file to an output file.
extract(inputFile: String, pageNumbers: int[], outputFile: String)booleanExtracts 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)booleanExtracts pages {@code 1..pageNum} from the input stream into the output stream.
splitToEnd(inputStream: InputStream, pageNum: int, outputStream: OutputStream)booleanExtracts 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)booleanInserts pages from a source file into a target file at the specified position.
delete(inputFile: String, pageNumbers: int[], outputFile: String)booleanDeletes specified pages from a PDF file and saves the result.
makeNUp(inputFile: String, outputFile: String, nX: int, nY: int)booleanArranges 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)booleanFile-path overload mirroring {@code PdfFileEditor.ResizeContents(string, string, ContentsResizeParameters)}
in Aspose.
makeBooklet(inputFile: String, outputFile: String)booleanArranges pages into a booklet layout.
makeBooklet(inputStream: InputStream, outputStream: OutputStream)booleanArranges pages from the input stream into a booklet layout saved to the output stream.
makeBooklet(inputFile: String, outputFile: String, pageSize: PageSize)booleanArranges pages into a booklet layout using the specified target page size.
makeBooklet(inputStream: InputStream, outputStream: OutputStream, pageSize: PageSize)booleanArranges pages from the input stream into a booklet layout with the specified target page size.
concatenate(firstInputFile: String, secondInputFile: String, outputFile: String)booleanConcatenates two PDF files into one output file.
append(inputFile: String, portFile: String, startPage: int, endPage: int, outputFile: String)booleanAppends 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)booleanExtracts pages {@code 1..pageNum} into {@code outputFile}.
splitToEnd(inputFile: String, pageNum: int, outputFile: String)booleanExtracts pages {@code pageNum..lastPage} into {@code outputFile}.
addMargins(inputFile: String, outputFile: String, pages: int[], left: double, right: double, top: double, bottom: double)booleanExpands 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)booleanTry-variant of {@link #concatenate(String[], String)}.
tryConcatenate(inputStreams: InputStream[], outputStream: OutputStream)booleanTry-variant of {@link #concatenate(InputStream[], OutputStream)}.
tryMakeBooklet(inputFile: String, outputFile: String)booleanTry-variant of {@link #makeBooklet(String, String)}.
tryMakeNUp(inputFile: String, outputFile: String, nX: int, nY: int)booleanTry-variant of {@link #makeNUp(String, String, int, int)}.
tryExtract(inputFile: String, startPage: int, endPage: int, outputFile: String)booleanTry-variant of {@link #extract(String, int, int, String)}.
tryExtract(inputFile: String, pageNumbers: int[], outputFile: String)booleanTry-variant of {@link #extract(String, int[], String)}.
tryResize(document: Document, parameters: ContentsResizeParameters)booleanTry-variant of {@link #resizeContents(Document, ContentsResizeParameters)}.
tryAppend(inputFile: String, portFile: String, startPage: int, endPage: int, outputFile: String)booleanTry-variant of {@link #append(String, String, int, int, String)}.
tryInsert(inputFile: String, insertPosition: int, portFile: String, startPage: int, endPage: int, outputFile: String)booleanTry-variant of {@link #insert(String, int, String, int, int, String)}.
tryDelete(inputFile: String, pageNumbers: int[], outputFile: String)booleanTry-variant of {@link #delete(String, int[], String)}.
trySplitFromFirst(inputFile: String, pageNum: int, outputFile: String)booleanTry-variant of {@link #splitFromFirst(String, int, String)}.
trySplitToEnd(inputFile: String, pageNum: int, outputFile: String)booleanTry-variant of {@link #splitToEnd(String, int, String)}.

See Also