NAME
PDF::Make::Crypt - PDF encryption support for PDF::Make
SYNOPSIS
use PDF::Make;
my $pdf = PDF::Make->new();
$pdf->add_page(width => 612, height => 792);
$pdf->text('Secret document', x => 100, y => 700);
# Render with encryption
my $bytes = $pdf->render(
encrypt => {
algorithm => 'AES-256',
user_password => 'secret',
owner_password => 'admin',
permissions => ['print', 'copy'],
}
);
DESCRIPTION
This module provides PDF encryption support for PDF::Make. It implements the Standard security handler per ISO 32000-2:2020 §7.6, supporting:
RC4-40 (R2, V=1) - 40-bit RC4, legacy
RC4-128 (R3, V=2) - 128-bit RC4
AES-128 (R4, V=4) - 128-bit AES-CBC
AES-256 (R6, V=5) - 256-bit AES-CBC (recommended)
METHODS
parse_permissions
my $flags = PDF::Make::Crypt->parse_permissions(\@perms);
Convert a list of permission names to a permission flags integer.
Valid permission names:
print - Allow printing
modify - Allow document modification
copy - Allow text/graphic extraction
annotate / annot - Allow annotations
fill_forms / fillforms - Allow form filling
extract - Allow accessibility extraction
assemble - Allow document assembly
print_high / printhigh - Allow high-quality printing
format_permissions
my @perms = PDF::Make::Crypt->format_permissions($flags);
Convert permission flags integer back to a list of permission names.
new
my $crypt = PDF::Make::Crypt->new();
Create a new encryption context.
setup
$crypt->setup($algorithm, $user_passwd, $owner_passwd, $permissions, $doc_id);
Set up encryption for a new document.
authenticate
my $result = $crypt->authenticate($password);
Authenticate with the given password.
Returns:
1 - Owner password authenticated
0 - User password authenticated
-1 - Authentication failed
encrypt_string
my $encrypted = $crypt->encrypt_string($obj_num, $gen_num, $data);
Encrypt a string for the given object.
decrypt_string
my $decrypted = $crypt->decrypt_string($obj_num, $gen_num, $data);
Decrypt a string from the given object.
SEE ALSO
PDF::Make, ISO 32000-2:2020 §7.6
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 60:
Non-ASCII character seen before =encoding in '§7.6,'. Assuming UTF-8