Features: Document Processing | PSPDFKit for Android

Loading...
PdfProcessor

PdfProcessor

1 2 3 4 5 6 7 8

// Pages numbers start at 0. This range therefore contains the 5th page of the document. val task = PdfProcessorTask(document).keepPages(setOf(4)) // Keep pages 5, 6 and 7. val task = PdfProcessorTask(document).keepPages(setOf(4, 5, 6)) // Remove first page val task = PdfProcessorTask(document).removePages(setOf(0))

PdfProcessorTask PdfProcessor#processDocumentAsync

PdfProcessor#processDocument

PdfProcessorTask

val outputFile = File(getFilesDir(), "extracted-pages.pdf") val task = PdfProcessorTask(document).keepPages(setOf(4, 5, 6)) 1 2 3 4 5 6 7 8 9

PdfProcessor.processDocumentAsync(task, outputFile) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ progress: PdfProcessor.ProcessorProgress -> Toast.makeText(context, "Processing page " + progress.pagesProcessed + "/" + progress.totalPages, Toast.LENGTH_SHORT) }, { error: Throwable -> Toast.makeText(context, "Processing has failed:" + error.message, Toast.LENGTH_SHORT) }, { Toast.makeText(context, "Processing has been completed successfully.", Toast.LENGTH_SHORT); });

PdfDocument PSPDFKit#openDocuments

PdfActivity#showDocuments

DocumentProcessingExample

PdfProcessorTask#changeAllAnnotations PdfProcessorTask#changeAnnotationsOfType

PdfProcessorTask#changeAnnotations

// Process all pages of the document, flattening all of its annotations. val task = 1

PdfProcessorTask(document).changeAllAnnotations(PdfProcessorTask.AnnotationProcessingMode.FLATTEN)

2

PdfProcessor.processDocumentAsync(...) ...

3 4

// Flatten only free text annotations, copy everything else.

5

val task =

6

PdfProcessorTask(document).changeAllAnnotations(PdfProcessorTask.AnnotationProcessingMode.KEEP)

7

.changeAnnotationsOfType(AnnotationType.FREETEXT,

8

PdfProcessorTask.AnnotationProcessingMode.FLATTEN) PdfProcessor.processDocumentAsync(...) ...

AnnotationType::WIDGET

FormType PdfProcessorTask#changeFormsOfType

1

// Rotate all pages of the document by 90°.

2

val task = PdfProcessorTask(document)

3

for(pageIndex in 0..document.pageCount-1) {

4

task.rotatePage(pageIndex, 90)

5

}

6 7

PdfProcessor.processDocumentAsync(...) ...

PdfProcessor DocumentSaveOptions#setPassword

1

val task = PdfProcessorTask(document)

2 3

// Create default document save options.

4

var documentSaveOptions = document.getDefaultDocumentSaveOptions()

5

// This will create encrypted password protected document.

6

documentSaveOptions.password = "password"

7 8

// Use created save options when processing the document.

9

PdfProcessor.processDocumentAsync(task, outputFile, documentSaveOptions) ...

Loading...

Features: Document Processing | PSPDFKit for Android

PdfProcessor PdfProcessor 1 2 3 4 5 6 7 8 // Pages numbers start at 0. This range therefore contains the 5th page of the document. val task = PdfPr...

448KB Sizes 5 Downloads 8 Views

Recommend Documents

No documents