attachmentOpenPassword property

String? attachmentOpenPassword
getter/setter pair

A value of PDF password.

//Load an existing PDF document
PdfDocument document =
    PdfDocument(inputBytes: File('input.pdf').readAsBytesSync())
      //Subsribe the onPdfPassword event
      ..onPdfPassword = loadOnPdfPassword;
//Access the attachments
PdfAttachmentCollection attachmentCollection = document.attachments;
//Iterates the attachments
for (int i = 0; i < attachmentCollection.count; i++) {
  //Extracts the attachment and saves it to the disk
  File(attachmentCollection[i].fileName)
      .writeAsBytesSync(attachmentCollection[i].data);
}
//Disposes the document
document.dispose();

void loadOnPdfPassword(PdfDocument sender, PdfPasswordArgs args) {
  //Sets the value of PDF password.
  args.attachmentOpenPassword = 'syncfusion';
}

Implementation

String? attachmentOpenPassword;