ownerPassword property

String get ownerPassword

Gets the owner password.

If the PDF document is password protected you can use the owner password to open the document and change its permissions.

//Load an exisiting PDF document.
PdfDocument document = PdfDocument.fromBase64String(pdfData, 'password');
//Get the owner password.
String ownerPassword = document.security.ownerPassword;
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();

Implementation

String get ownerPassword {
  return _helper.encryptAttachments ? '' : _helper.encryptor.ownerPassword;
}
set ownerPassword (String value)

Sets the owner password.

If the PDF document is password protected you can use the owner password to open the document and change its permissions.

//Create a new PDF document.
PdfDocument document = PdfDocument();
//Document security
PdfSecurity security = document.security;
//Set security options
security.algorithm = PdfEncryptionAlgorithm.rc4x128Bit;
security.userPassword = 'password';
security.ownerPassword = 'syncfusion';
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();

Implementation

set ownerPassword(String value) {
  if (_helper.conformance) {
    throw ArgumentError(
        'Document encryption is not allowed with Conformance documents.');
  }
  _helper.encryptor.ownerPassword = value;
  _helper.encryptor.encrypt = true;
  _helper.modifiedSecurity = true;
}