public class

DocumentEditor

extends Object
java.lang.Object
   ↳ com.pspdfkit.api.DocumentEditor

Class Overview

A class to perform editing operations on a document to export.

Summary

Nested Classes
enum DocumentEditor.IndexPosition The position to place the item relative to the index. 
Public Constructors
DocumentEditor()
Constructs a `DocumentEditor` with a blank document with 0 pages to work with.
Public Methods
void addOperations(JSONArray jsonArray)
Form a custom operation from JSON and append to the operations to be performed.
void addPage(int pageIndex, DocumentEditor.IndexPosition indexPosition, int height, int width, Rotation rotation, Color color, Insets inset)
Add a single new page with the given configuration.
void clearPageLabels()
Clear labels from all of the pages.
void duplicatePages(Set<Integer> pageIndices)
Duplicate and insert after the referenced page indices.
void importDocument(int pageIndex, DocumentEditor.IndexPosition indexPosition, DataProvider documentProvider)
Import a document from another data source and insert into the document.
void keepPages(Set<Integer> pageIndices)
Keep all the pages referenced and remove the remaining.
void movePages(Set<Integer> pagesToMove, int moveToIndex, DocumentEditor.IndexPosition indexPosition)
Move the referenced pages to a new location.
void removePages(Set<Integer> pageIndices)
Remove the referenced pages.
void rotatePages(Set<Integer> pagesToRotate, Rotation rotation)
Rotate the reference pages by the rotation given.
void saveDocument(WritableDataProvider dataProvider)
Apply the staged operations and export to the given data provider.
void setPageLabel(Set<Integer> pageIndices, String label)
Set a label on the given pages.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public DocumentEditor ()

Constructs a `DocumentEditor` with a blank document with 0 pages to work with.

Public Methods

public void addOperations (JSONArray jsonArray)

Form a custom operation from JSON and append to the operations to be performed. For information on how to form an operation, please see https://pspdfkit.com/guides/web/current/features/document-editor/#operations.

Parameters
jsonArray An array of operations to perform.

public void addPage (int pageIndex, DocumentEditor.IndexPosition indexPosition, int height, int width, Rotation rotation, Color color, Insets inset)

Add a single new page with the given configuration.

Parameters
pageIndex The index in which to place the new page.
indexPosition Place the page before or after the given page index.
height The height of the new page.
width The width of the new page.
rotation The rotation of the new page in 90 degree increments.
color The background color of the new page.
inset The edit insets for the new page.

public void clearPageLabels ()

Clear labels from all of the pages.

public void duplicatePages (Set<Integer> pageIndices)

Duplicate and insert after the referenced page indices.

Parameters
pageIndices The pages to duplicate.

public void importDocument (int pageIndex, DocumentEditor.IndexPosition indexPosition, DataProvider documentProvider)

Import a document from another data source and insert into the document.

Parameters
pageIndex The index to insert the document into.
indexPosition Place the page before or after the given page index.
documentProvider The document to import.

public void keepPages (Set<Integer> pageIndices)

Keep all the pages referenced and remove the remaining.

Parameters
pageIndices Pages to keep.

public void movePages (Set<Integer> pagesToMove, int moveToIndex, DocumentEditor.IndexPosition indexPosition)

Move the referenced pages to a new location.

Parameters
pagesToMove The pages to move.
moveToIndex The index to move to.
indexPosition Move the pages before or after the given index.

public void removePages (Set<Integer> pageIndices)

Remove the referenced pages.

Parameters
pageIndices All the pages to remove.

public void rotatePages (Set<Integer> pagesToRotate, Rotation rotation)

Rotate the reference pages by the rotation given.

Parameters
pagesToRotate The pages to rotate.
rotation The rotation to apply in 90 degree increments.

public void saveDocument (WritableDataProvider dataProvider)

Apply the staged operations and export to the given data provider.

Parameters
dataProvider The data provider to export the document to.

public void setPageLabel (Set<Integer> pageIndices, String label)

Set a label on the given pages.

Parameters
pageIndices The pages to set the label.
label The label to set.