🔒 Ares Defence Labs Locksmith PDF
A Flutter plugin to encrypt, decrypt, and manage PDF security with fine-grained permissions.
Supports user password, owner password, and control over PDF actions like printing, copying, modifying, annotating, and filling forms.
Supports both iOS & Android
Uses PdfBox on Android
Uses Apple PdfKit Apis for iOS
✨ Features
- Password-protect PDFs using AES-256 encryption.
- Decrypt password-protected PDFs.
- Allow or restrict printing, copying, annotating, modifying, and form filling.
- Remove all security restrictions from a PDF & Decrypt
- Check if a PDF is encrypted or not
📦 Installation
Add this to your pubspec.yaml
:
dependencies:
ares_defence_labs_lock_smith_pdf: ^0.0.1
Then run
flutter pub get
To use the Api please import the library
import 'package:ares_defence_labs_lock_smith_pdf/ares_defence_labs_lock_smith_pdf.dart';
To generate a protected PDF with a passcode, please use the following (this enabled all permissions by default: Printing, Annotations Editing, etc):
await AresDefenceLabsLocksmithPdf.protectPdf(
inputPath: '/path/to/input.pdf',
outputPath: '/path/to/encrypted_output.pdf',
password: 'SuperSecretPassword123',
);
You can also adjust the permissions of the document, and adding a owners passcode onto it too (this allows anyone who has decrypted the PDF to be able to adjust the permissions).
await AresDefenceLabsLocksmithPdf.protectPdfWithPermissions(
inputPath: '/path/to/input.pdf',
outputPath: '/path/to/secured_output.pdf',
userPassword: 'EncryptionPasscode123',
ownerPassword: 'PermissionsManagerPasscode456',
permissions: [
PermissionOption.print,
PermissionOption.copy,
PermissionOption.annotate,
],
);
To decrypt an encrypted PDF:
await AresDefenceLabsLocksmithPdf.decryptPdf(
inputPath: '/path/to/encrypted.pdf',
outputPath: '/path/to/decrypted_output.pdf',
password: 'SuperSecret123',
);
To check if a PDF file is encrypted or not
bool isEncrypted = await AresDefenceLabsLocksmithPdf.isPdfEncrypted(
inputPath: '/path/to/file.pdf',
);
if (isEncrypted) {
print('The PDF is encrypted.');
} else {
print('The PDF is not encrypted.');
}
To remove all permissions & security from a PDF file:
await AresDefenceLabsLocksmithPdf.removePdfSecurity(
inputPath: '/path/to/protected.pdf',
outputPath: '/path/to/unlocked_output.pdf',
password: 'OwnerPass456',
);