Creating password-protected PDFs on Android
A PDF document can be encrypted to protect its contents from unauthorized access.
PdfProcessor
supports creating encrypted password-protected documents by setting a password via DocumentSaveOptions#setPassword
:
val task = PdfProcessorTask.fromDocument(document) // Create default document save options. var documentSaveOptions = document.getDefaultDocumentSaveOptions() // This will create an encrypted password-protected document. documentSaveOptions.password = "password" // Use created save options when processing the document. PdfProcessor.processDocumentAsync(task, outputFile, documentSaveOptions)
final PdfProcessorTask task = PdfProcessorTask.fromDocument(document); // Create default document save options. DocumentSaveOptions documentSaveOptions = document.getDefaultDocumentSaveOptions(); // This will create an encrypted password-protected document. documentSaveOptions.setPassword("password"); // Use created save options when processing the document. PdfProcessor.processDocumentAsync(task, outputFile, documentSaveOptions);