This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/android/document-security/add-a-password.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Create password-protected PDF on Android | Nutrient SDK

A PDF document can be encrypted to protect its contents from unauthorized access.

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);