com.pspdfkit.document.editor.PdfDocumentEditor |
Editor for PDF documents. A document editor can perform operations on a PDF document for page
manipulation, reordering and importing documents. Document editor won't directly manipulate the
returned document instance but will keep track of all editing steps internally, allowing them to
save them back once editing is complete. To create a document editor use createForDocument(PdfDocument)
.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract Single<List<EditingChange>> |
addPage(int pageIndex, NewPage newPageConfiguration)
Adds a new page at the specified
pageIndex , with the configuration options specified
in newPageConfiguration . | ||||||||||
abstract Single<List<EditingChange>> |
addPages(int pageIndex, List<NewPage> newPageConfigurations)
Adds a new collection of pages at the specified
pageIndex , with the configuration
options specified in newPageConfigurations for every page. | ||||||||||
abstract void |
beginTransaction()
Begins a batch of document editor operations, undoable/redoable as a single unit.
| ||||||||||
abstract boolean |
canRedo()
Checks if redo operation is possible on document editor.
| ||||||||||
abstract boolean |
canUndo()
Checks if undo operation is possible on document editor.
| ||||||||||
abstract List<EditingChange> |
commitTransaction()
Ends a batch of document editor operations and commits them immediately.
| ||||||||||
abstract List<EditingChange> |
discardTransaction()
Discards the current batch of document operations.
| ||||||||||
abstract Single<List<EditingChange>> |
duplicatePages(Set<Integer> pageIndexes)
Duplicates pages of the document.
| ||||||||||
abstract Completable |
exportPages(Context context, OutputStream outputStream, Set<Integer> pageIndexes, DocumentSaveOptions options)
Exports selected pages to an output stream.
| ||||||||||
abstract PdfDocument |
getDocument()
Returns the original document being edited.
| ||||||||||
abstract int |
getPageCount()
Returns the page count of the edited document.
| ||||||||||
abstract Size |
getRotatedPageSize(int pageIndex)
Returns page size of a given page already rotated.
| ||||||||||
abstract Single<List<EditingChange>> |
importDocument(Context context, DocumentSource documentSource, int destinationIndex)
Imports all the pages from a given document source to a destination index.
| ||||||||||
abstract boolean |
isTransactionActive()
Checks if there's currently an active document editor transaction.
| ||||||||||
abstract Single<List<EditingChange>> |
movePages(Set<Integer> fromPositions, int toPosition)
Moves a given set of pages of the document to a specific index.
| ||||||||||
abstract List<EditingChange> |
redo()
Perform redo changes on document editor.
| ||||||||||
abstract Single<List<EditingChange>> |
removePages(Set<Integer> pageIndexes)
Removes pages from the document.
| ||||||||||
abstract Completable |
renderPageToBitmap(int pageIndex, Bitmap buffer, PageRenderConfiguration configuration)
Renders the given page into a Bitmap buffer.
| ||||||||||
abstract Single<List<EditingChange>> |
rotatePages(Set<Integer> pageIndexes, int rotation)
Rotate pages of the document.
| ||||||||||
abstract Completable |
saveDocument(Context context, DocumentSaveOptions options)
Saves all changes made to the document.
| ||||||||||
abstract Completable |
saveDocument(Context context, OutputStream outputStream, DocumentSaveOptions options)
Saves all changes made to the document to a given output stream.
| ||||||||||
abstract void |
setPageLabel(int pageIndex, String label)
Sets a new page label for the edited document.
| ||||||||||
abstract List<EditingChange> |
undo()
Perform undo changes on document editor.
|
Adds a new page at the specified pageIndex
, with the configuration options specified
in newPageConfiguration
.
addPage(int, NewPage)
does not operate by default on a particular Scheduler.
pageIndex | Index where the new page will be added. |
---|---|
newPageConfiguration | Configuration options specified for the new page. |
Adds a new collection of pages at the specified pageIndex
, with the configuration
options specified in newPageConfigurations
for every page.
addPage(int, NewPage)
does not operate by default on a particular Scheduler.
pageIndex | Index where the new pages will be added. |
---|---|
newPageConfigurations | List of configuration options specified for the new pages. |
Begins a batch of document editor operations, undoable/redoable as a single unit.
Checks if redo operation is possible on document editor.
true
if redo operation is allowed.
Checks if undo operation is possible on document editor.
true
if undo operation is allowed.
Ends a batch of document editor operations and commits them immediately.
Discards the current batch of document operations.
Duplicates pages of the document. The duplicated pages will be inserted exactly after the original page.
duplicatePages(Set<Integer>)
does not operate by default on a particular Scheduler.
pageIndexes | Page indexes to duplicate, may not be empty. |
---|
Exports selected pages to an output stream.
exportPages(OutputStream, Set<Integer>, DocumentSaveOptions)
does not operate
by default on a particular Scheduler.
context | The context to use. |
---|---|
outputStream | Output stream where the pages will be exported. |
pageIndexes | Page indexes to export, may not be empty. |
options | Document saving options, default saving options will be used when null |
Returns the original document being edited.
Returns the page count of the edited document. If a page is added or removed, the count will
reflect the change. It will always reflect the number of committed pages in the editor after
a call to commitTransaction()
if this is called inside a group.
Returns page size of a given page already rotated.
pageIndex | Page index whose size will be returned. |
---|
Imports all the pages from a given document source to a destination index.
importDocument(int, DocumentSource)
does not operate by default on a particular
Scheduler.
context | The context to use. |
---|---|
documentSource | Document source with the pages to import. |
destinationIndex | Destination index where the pages will be imported. |
Checks if there's currently an active document editor transaction.
true
if there's an active document editor transaction, false
otherwise.
Moves a given set of pages of the document to a specific index.
movePages(Set<Integer>, int)
does not operate by default on a particular Scheduler.
fromPositions | Set of page indexes that will be moved, may not be empty. |
---|---|
toPosition | Destination index where the pages will be moved. |
Perform redo changes on document editor.
Removes pages from the document.
removePages(Set<Integer>)
does not operate by default on a particular Scheduler.
pageIndexes | Page indexes to remove, may not be empty. |
---|
Renders the given page into a Bitmap buffer.
renderPageToBitmap(int, Bitmap, PageRenderConfiguration)
does not operate by
default on a particular Scheduler.
pageIndex | Page index to render. |
---|---|
buffer | Bitmap buffer where the given page will be rendered. |
configuration | Configuration rendering options. |
Rotate pages of the document.
rotatePages(Set<Integer>, int)
does not operate by default on a particular
Scheduler.
pageIndexes | Page indexes to rotate, may not be empty. |
---|---|
rotation | One of NO_ROTATION , ROTATION_90 ,
ROTATION_180 , ROTATION_270 . |
Saves all changes made to the document. Saving will start as soon as the Completable
is subscribed.
saveDocument()
does not operate by default on a particular Scheduler.
context | The context to use. |
---|---|
options | Document saving options, default saving options will be used when null . |
Saves all changes made to the document to a given output stream. Saving will start as soon as
the Completable
is subscribed.
saveDocument(OutputStream)
does not operate by default on a particular Scheduler.
context | The context to use. |
---|---|
outputStream | Destination stream where the document will be saved. |
options | Document saving options, default saving options will be used when null . |
Sets a new page label for the edited document.
pageIndex | Page index whose label to set. |
---|---|
label | Label to set for a given page, null to clear it.
|
Perform undo changes on document editor.