forEach method
Iterate for each element in permissions and perform action.
//Load encrypted PDF document with password.
PdfDocument document = PdfDocument(inputBytes: pdfData, password: 'password');
//Document security
PdfSecurity security = document.security;
//Gets the PDF permission.
PdfPermissions permissions = security.permissions;
List<PdfPermissionsFlags> permissions = <PdfPermissionsFlags>[
PdfPermissionsFlags.print,
PdfPermissionsFlags.editContent,
PdfPermissionsFlags.copyContent,
PdfPermissionsFlags.editAnnotations,
PdfPermissionsFlags.fillFields,
PdfPermissionsFlags.accessibilityCopyContent,
PdfPermissionsFlags.assembleDocument,
PdfPermissionsFlags.fullQualityPrint];
//Check the PDF document encrypted with all permissions options.
bool hasAllPermissions = true;
permissions.forEach((PdfPermissionsFlags flag) {
if (flag != PdfPermissionsFlags.none) {
hasAllPermissions &= permissions.contains(flag);
}
});
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();
Implementation
void forEach(void Function(PdfPermissionsFlags element) action) {
final int length = count;
for (int i = 0; i < count; i++) {
action(this[i]);
if (length != count) {
throw ConcurrentModificationError(this);
}
}
}