public final class

PdfProcessorTask

extends Object
java.lang.Object
   ↳ com.pspdfkit.document.processor.PdfProcessorTask

Class Overview

Represents a processing task for PdfProcessor.

Summary

Nested Classes
enum PdfProcessorTask.AnnotationProcessingMode Describes how an annotation will be processed by a processor. 
Public Methods
PdfProcessorTask addCanvasDrawingToPage(PageCanvas pageCanvas, int destinationPageIndex)
Merges content of canvas drawing on top (or below) the destination page content.
PdfProcessorTask addImageToPage(PageImage image, int destinationPageIndex)
Adds an image on top (or below) the destination page content.
PdfProcessorTask addNewPage(NewPage newPage, int destinationPageIndex)
Adds a new page to the document at passed index.
PdfProcessorTask addPdfToPage(PagePdf pagePdf, int destinationPageIndex)
This method is deprecated. Use mergePage(PagePdf, int) instead.
PdfProcessorTask applyRedactions()
Applies the redact annotations for the given page index.
PdfProcessorTask changeAllAnnotations(PdfProcessorTask.AnnotationProcessingMode processingMode)
Changes ALL annotations in document according to PdfProcessorTask.AnnotationProcessingMode.
PdfProcessorTask changeAnnotations(List<Annotation> annotations, PdfProcessorTask.AnnotationProcessingMode processingMode)
Changes passed annotations according to passed PdfProcessorTask.AnnotationProcessingMode.
PdfProcessorTask changeAnnotationsOfType(AnnotationType annotationType, PdfProcessorTask.AnnotationProcessingMode processingMode)
Changes all annotation of a certain type according to the passed in processing mode.
PdfProcessorTask changeFormsOfType(FormType formType, PdfProcessorTask.AnnotationProcessingMode processingMode)
Changes all form annotations of a certain type according to the passed in processing mode.
PdfProcessorTask changeStrokeColorOnPage(int pageIndex, int color)

Adjusts color of all strokes on the given page.

PdfProcessorTask clearPageLabels()
Removes all page labels in the document.
static PdfProcessorTask empty()
Creates a new empty processing task for the PdfProcessor.
static PdfProcessorTask fromDocument(PdfDocument sourceDocument)
Creates a new processing task for the PdfProcessor.
PdfProcessorTask keepPages(Set<Integer> pagesToKeep)
Keeps only passed pages from document.
PdfProcessorTask mergePage(PagePdf pagePdf, int destinationPageIndex)
Merges a page with a page of the task's document.
PdfProcessorTask mergePage(PagePdf pagePdf, int destinationPageIndex, BlendMode blendMode)

Merges a page with a page of the task's document by using specified BlendMode.

PdfProcessorTask movePages(Set<Integer> pagesToMove, int destinationIndex)
Moves passed pages to a new index in the document.
static PdfProcessorTask newPage(NewPage newPage)
Creates a new processing task for creating a new single-page document from scratch.
PdfProcessorTask removePages(Set<Integer> pagesToRemove)
Removes passed pages from document.
PdfProcessorTask resizePage(int pageIndex, Size pageSize)
Re-sizes the selected page to pageSize.
PdfProcessorTask rotatePage(int pageIndex, int rotation)
Rotates the selected page for passed degrees.
PdfProcessorTask setFormFieldNameMappings(Map<StringString> formFieldNameMappings)
Renames form fields as described in a mapping.
PdfProcessorTask setFormMappingNameMappings(Map<StringString> formMappingNameMappings)
Renames form mapping names as described in this mapping.
PdfProcessorTask setPageBox(int pageIndex, PdfBox boxToChange, RectF rectF)
Changes one of the page boxes for the passed page.
PdfProcessorTask setPageLabel(int pageIndex, String label)
Sets a label on the page.
PdfProcessorTask stripEmptyPages(boolean stripEmptyPages)
Strip empty pages at the end of processing.
PdfProcessorTask withMetadata(HashMap<StringString> metadata)
Sets metadata for the output document.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public PdfProcessorTask addCanvasDrawingToPage (PageCanvas pageCanvas, int destinationPageIndex)

Merges content of canvas drawing on top (or below) the destination page content.

Parameters
pageCanvas Canvas drawing to be merged.
destinationPageIndex Page index of page to add PDF to.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask addImageToPage (PageImage image, int destinationPageIndex)

Adds an image on top (or below) the destination page content.

Parameters
image Image to be added to the page.
destinationPageIndex Page index of page to add image to.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask addNewPage (NewPage newPage, int destinationPageIndex)

Adds a new page to the document at passed index.

Note: This call requires document editing feature in your license.

Parameters
newPage Configuration setting size and rotation of the new page.
destinationPageIndex Page index position of the destination where page should be added.
Returns
  • Processor task describing the page processing progress.
Throws
PdfProcessorException If new page contains a bitmap that cannot be opened

public PdfProcessorTask addPdfToPage (PagePdf pagePdf, int destinationPageIndex)

This method is deprecated.
Use mergePage(PagePdf, int) instead.

Merges content of first page of passed PDF on top (or below) the destination page content.

Parameters
pagePdf PDF to be merged
destinationPageIndex Page index of a page to add PDF to.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask applyRedactions ()

Applies the redact annotations for the given page index. Applying a redact annotation means removing the text that is underneath them, and removing the redact annotations themselves.

NOTE: This requires the Redaction component license to use.

Returns
  • Processor task describing processing progress.

public PdfProcessorTask changeAllAnnotations (PdfProcessorTask.AnnotationProcessingMode processingMode)

Changes ALL annotations in document according to PdfProcessorTask.AnnotationProcessingMode. By default all annotations are kept (KEEP).

Parameters
processingMode Processing mode for annotations in the document.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask changeAnnotations (List<Annotation> annotations, PdfProcessorTask.AnnotationProcessingMode processingMode)

Changes passed annotations according to passed PdfProcessorTask.AnnotationProcessingMode. By default all annotations are kept (KEEP).

Parameters
annotations List of annotations to specify processing mode for. The annotations must be part of a source document.
processingMode Processing mode for annotations in the list.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask changeAnnotationsOfType (AnnotationType annotationType, PdfProcessorTask.AnnotationProcessingMode processingMode)

Changes all annotation of a certain type according to the passed in processing mode.

Parameters
annotationType Annotation type to change.
processingMode PdfProcessorTask.AnnotationProcessingMode describing how to change annotations.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask changeFormsOfType (FormType formType, PdfProcessorTask.AnnotationProcessingMode processingMode)

Changes all form annotations of a certain type according to the passed in processing mode.

Parameters
formType Form type to change.
processingMode PdfProcessorTask.AnnotationProcessingMode describing how to change annotations.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask changeStrokeColorOnPage (int pageIndex, int color)

Adjusts color of all strokes on the given page.


Note: This call requires document comparison features in your license.

Parameters
pageIndex Index of the page, whose stroke color should be changed.
color The new color used to change the strokes.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask clearPageLabels ()

Removes all page labels in the document.

Returns
  • Processor task describing the page processing progress.

public static PdfProcessorTask empty ()

Creates a new empty processing task for the PdfProcessor.

Note: This call requires document editing feature in your license.

public static PdfProcessorTask fromDocument (PdfDocument sourceDocument)

Creates a new processing task for the PdfProcessor. By default the processing task copies all pages and all annotations to the destination document.

Note: This call requires document editing feature in your license.

Parameters
sourceDocument The processed PdfDocument.

public PdfProcessorTask keepPages (Set<Integer> pagesToKeep)

Keeps only passed pages from document.

Note: This will shift page indices for any other operation accepting page index as a parameter after this!

Parameters
pagesToKeep Pages to keep in the document.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask mergePage (PagePdf pagePdf, int destinationPageIndex)

Merges a page with a page of the task's document.

Parameters
pagePdf PDF page to be merged.
destinationPageIndex Index of the destination document's page the source page should be merged into.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask mergePage (PagePdf pagePdf, int destinationPageIndex, BlendMode blendMode)

Merges a page with a page of the task's document by using specified BlendMode.


Note: This call requires document comparison feature in your license.

Parameters
pagePdf PDF page to be merged. This call does not support PagePosition property of the PagePdf.
destinationPageIndex Index of the destination document's page the source page should be merged into.
blendMode Defines how the two pages should be blended into each other.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask movePages (Set<Integer> pagesToMove, int destinationIndex)

Moves passed pages to a new index in the document. The order of pages in new location is retained.

Note: This will shift page indices for any other operation accepting page index as a parameter after this!

Parameters
pagesToMove 0-indexed set of page indexes of pages to remove.
destinationIndex Index of position where pages should be moved to in source document.
Returns
  • Processor task describing the page processing progress.

public static PdfProcessorTask newPage (NewPage newPage)

Creates a new processing task for creating a new single-page document from scratch.

Note: This call requires document editing feature in your license.

Parameters
newPage NewPage options for the first page of the new document.

public PdfProcessorTask removePages (Set<Integer> pagesToRemove)

Removes passed pages from document.

Note: This will shift page indices for any other operation accepting page index as a parameter after this!

Parameters
pagesToRemove 0-indexed set of page indexes of pages to remove.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask resizePage (int pageIndex, Size pageSize)

Re-sizes the selected page to pageSize. The content of the page will be resized with kept aspect ratio. NOTE: This call requires document editing feature in your license.

Parameters
pageIndex 0-indexed page index of the page to be rotated.
pageSize Size of the scaled page.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask rotatePage (int pageIndex, int rotation)

Rotates the selected page for passed degrees. The pages can only be rotated for 0, 90, 180 or 270.

Note: This call requires document editing feature in your license.

Parameters
pageIndex 0-indexed page index of the page to be rotated.
rotation Rotation in degrees. Positive number is clockwise rotation, negative is counter-clockwise. The value may only be 0, 90, 180 or 270.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask setFormFieldNameMappings (Map<StringString> formFieldNameMappings)

Renames form fields as described in a mapping.

NOTE: This requires the Document Editor component license to use.

Parameters
formFieldNameMappings Map of old name - new name pairs for this document.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask setFormMappingNameMappings (Map<StringString> formMappingNameMappings)

Renames form mapping names as described in this mapping.

NOTE: This requires the Document Editor component license to use.

Parameters
formMappingNameMappings Map of old name - new name pairs for this document.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask setPageBox (int pageIndex, PdfBox boxToChange, RectF rectF)

Changes one of the page boxes for the passed page.

Note: This call requires document editing feature in your license.

Parameters
pageIndex 0-indexed page index of the page to be rotated.
boxToChange Current PDF box to be changed.
rectF New box position in PDF coordinates.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask setPageLabel (int pageIndex, String label)

Sets a label on the page. Most viewers will show the page label instead of its page number in both the document view and table of contents.

Parameters
pageIndex 0-indexed page index of the page to set the label to.
label Label to be set for the page. If null, the label of the page will be removed.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask stripEmptyPages (boolean stripEmptyPages)

Strip empty pages at the end of processing.

Parameters
stripEmptyPages true if empty pages should be stripped when writing processed document.
Returns
  • Processor task describing the page processing progress.

public PdfProcessorTask withMetadata (HashMap<StringString> metadata)

Sets metadata for the output document. The set metadata will fully replace any existing metadata.

Returns
  • Processor task describing the page processing progress.