setPassword method
Future<bool>
setPassword({
- String? userPassword,
- String? ownerPassword,
- bool allowsPrinting = true,
- bool allowsCopying = true,
- CPDFDocumentEncryptAlgo encryptAlgo = CPDFDocumentEncryptAlgo.rc4,
This method sets the document password, including the user password for access restrictions and the owner password for granting permissions.
- To enable permissions like printing or copying, the owner password must be set; otherwise, the settings will not take effect.
example:
bool result = controller.document.setPassword(
userPassword : '1234',
ownerPassword : '4321',
allowsPrinting : false,
allowsCopying : false,
encryptAlgo = CPDFDocumentEncryptAlgo.rc4
);
Implementation
Future<bool> setPassword(
{String? userPassword,
String? ownerPassword,
bool allowsPrinting = true,
bool allowsCopying = true,
CPDFDocumentEncryptAlgo encryptAlgo =
CPDFDocumentEncryptAlgo.rc4}) async {
try {
return await _channel.invokeMethod('set_password', {
'user_password': userPassword,
'owner_password': ownerPassword,
'allows_printing': allowsPrinting,
'allows_copying': allowsCopying,
'encrypt_algo': encryptAlgo.name
});
} on PlatformException catch (e) {
debugPrint(e.message);
return false;
}
}