view release on metacpan or search on metacpan
add_pdf_password(%args) -> [$status_code, $reason, $payload, \%result_meta]
Password-protect PDF files.
This program is a wrapper for qpdf to password-protect PDF files
(in-place). This is the counterpart for remove-pdf-password. Why use
this wrapper instead of qpdf directly? This wrapper offers configuration
file support, where you can put the password(s) you want to use there.
The wrapper also offers multiple file support and additional options,
e.g. whether to create backup.
This function is not exported.
Arguments ('*' denotes required arguments):
* backup => *bool* (default: 1)
Whether to backup the original file to ORIG~.
* files* => *array[filename]*
(No description)
* password* => *str*
(No description)
Returns an enveloped result (an array).
password-protected PDF file. This is annoying when we want to archive
the file or use it in an organization because we have to remember
different passwords for different financial institutions and re-enter
the password everytime we want to use the file. (The banks could've sent
the PDF in a password-protected .zip, or use PGP-encrypted email, but I
digress.)
Compared to using qpdf directly, this wrapper offers some additional
features/options and convenience, for example: multiple file support,
multiple password matching attempt, configuration file, option whether
you want backup, etc.
You can provide the passwords to be tried in a configuration file,
"~/remove-pdf-password.conf", e.g.:
passwords = pass1
passwords = pass2
passwords = pass3
or:
passwords = ["pass1", "pass2", "pass3"]
This function is not exported.
Arguments ('*' denotes required arguments):
* backup => *bool* (default: 1)
Whether to backup the original file to ORIG~.
* files* => *array[filename]*
(No description)
* passwords => *array[str]*
(No description)
Returns an enveloped result (an array).
lib/App/PDFUtils.pm view on Meta::CPAN
$SPEC{add_pdf_password} = {
v => 1.1,
summary => 'Password-protect PDF files',
description => <<'MARKDOWN',
This program is a wrapper for <prog:qpdf> to password-protect PDF files
(in-place). This is the counterpart for <prog:remove-pdf-password>. Why use this
wrapper instead of **qpdf** directly? This wrapper offers configuration file
support, where you can put the password(s) you want to use there. The wrapper
also offers multiple file support and additional options, e.g. whether to create
backup.
MARKDOWN
args => {
%argspec0_files,
password => {
schema => ['str*', min_len=>1],
req => 1,
},
backup => {
summary => 'Whether to backup the original file to ORIG~',
schema => 'bool*',
default => 1,
},
# XXX key_length (see qpdf, but when 256 can't be opened by evince)
# XXX other options (see qpdf)
},
deps => {
prog => 'qpdf',
},
links => [
lib/App/PDFUtils.pm view on Meta::CPAN
$envres->add_result(412, "File already encrypted", {item_id=>$f});
next FILE;
} elsif ($err) {
$stderr =~ s/\R//g;
$envres->add_result(500, $stderr, {item_id=>$f});
next FILE;
}
BACKUP:
{
last unless $args{backup};
unless (rename $f, "$f~") {
warn "Can't backup original '$f' to '$f~': $!, skipped backup\n";
last;
};
}
unless (rename $tempf, $f) {
$envres->add_result(500, "Can't rename $tempf to $f: $!", {item_id=>$f});
next FILE;
}
$envres->add_result(200, "OK", {item_id=>$f});
}
lib/App/PDFUtils.pm view on Meta::CPAN
The motivation for this wrapper is the increasing occurence of financial
institutions sending financial statements or documents in the format of
password-protected PDF file. This is annoying when we want to archive the file
or use it in an organization because we have to remember different passwords for
different financial institutions and re-enter the password everytime we want to
use the file. (The banks could've sent the PDF in a password-protected .zip, or
use PGP-encrypted email, but I digress.)
Compared to using **qpdf** directly, this wrapper offers some additional
features/options and convenience, for example: multiple file support, multiple
password matching attempt, configuration file, option whether you want backup,
etc.
You can provide the passwords to be tried in a configuration file,
`~/remove-pdf-password.conf`, e.g.:
passwords = pass1
passwords = pass2
passwords = pass3
or:
passwords = ["pass1", "pass2", "pass3"]
MARKDOWN
args => {
%argspec0_files,
passwords => {
schema => ['array*', of=>['str*', min_len=>1], min_len=>1],
},
backup => {
summary => 'Whether to backup the original file to ORIG~',
schema => 'bool*',
default => 1,
},
},
deps => {
prog => 'qpdf',
},
links => [
{url => 'prog:add-pdf-password'},
],
lib/App/PDFUtils.pm view on Meta::CPAN
}
last;
}
unless (-f $tempf) {
$envres->add_result(412, "No passwords can be successfully used on $f", {item_id=>$f});
next FILE;
}
BACKUP:
{
last unless $args{backup};
unless (rename $f, "$f~") {
warn "Can't backup original '$f' to '$f~': $!, skipped backup\n";
last;
};
}
unless (rename $tempf, $f) {
$envres->add_result(500, "Can't rename $tempf to $f: $!", {item_id=>$f});
next FILE;
}
$envres->add_result(200, "OK", {item_id=>$f});
}
lib/App/PDFUtils.pm view on Meta::CPAN
add_pdf_password(%args) -> [$status_code, $reason, $payload, \%result_meta]
Password-protect PDF files.
This program is a wrapper for L<qpdf> to password-protect PDF files
(in-place). This is the counterpart for L<remove-pdf-password>. Why use this
wrapper instead of B<qpdf> directly? This wrapper offers configuration file
support, where you can put the password(s) you want to use there. The wrapper
also offers multiple file support and additional options, e.g. whether to create
backup.
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<backup> => I<bool> (default: 1)
Whether to backup the original file to ORIG~.
=item * B<files>* => I<array[filename]>
(No description)
=item * B<password>* => I<str>
(No description)
lib/App/PDFUtils.pm view on Meta::CPAN
The motivation for this wrapper is the increasing occurence of financial
institutions sending financial statements or documents in the format of
password-protected PDF file. This is annoying when we want to archive the file
or use it in an organization because we have to remember different passwords for
different financial institutions and re-enter the password everytime we want to
use the file. (The banks could've sent the PDF in a password-protected .zip, or
use PGP-encrypted email, but I digress.)
Compared to using B<qpdf> directly, this wrapper offers some additional
features/options and convenience, for example: multiple file support, multiple
password matching attempt, configuration file, option whether you want backup,
etc.
You can provide the passwords to be tried in a configuration file,
C<~/remove-pdf-password.conf>, e.g.:
passwords = pass1
passwords = pass2
passwords = pass3
or:
passwords = ["pass1", "pass2", "pass3"]
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<backup> => I<bool> (default: 1)
Whether to backup the original file to ORIG~.
=item * B<files>* => I<array[filename]>
(No description)
=item * B<passwords> => I<array[str]>
(No description)
script/add-pdf-password view on Meta::CPAN
=head1 VERSION
This document describes version 0.016 of add-pdf-password (from Perl distribution App-PDFUtils), released on 2024-09-28.
=head1 SYNOPSIS
B<add-pdf-password> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)
B<add-pdf-password> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)
B<add-pdf-password> [B<L<--backup|/"--no-backup">>|B<L<--no-backup|/"--no-backup">>|B<L<--nobackup|/"--no-backup">>] [B<L<--config-path|/"--config-path=s, -c">>=I<path>|B<L<-c|/"--config-path=s, -c">>|B<L<--no-config|/"--no-config, -C">>|B<L<-C|/"--n...
=head1 DESCRIPTION
This program is a wrapper for L<qpdf> to password-protect PDF files
(in-place). This is the counterpart for L<remove-pdf-password>. Why use this
wrapper instead of B<qpdf> directly? This wrapper offers configuration file
support, where you can put the password(s) you want to use there. The wrapper
also offers multiple file support and additional options, e.g. whether to create
backup.
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
=item B<--files-json>=I<s>
script/add-pdf-password view on Meta::CPAN
=item B<--files>=I<s@>*
(No description)
Can also be specified as the 1st command-line argument and onwards.
Can be specified multiple times.
=item B<--no-backup>
(No description)
=item B<--password>=I<s>*
(No description)
=back
script/add-pdf-password view on Meta::CPAN
-event=after_validate_args
arg1=val1
arg2=val2
which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.
List of available configuration parameters:
backup (see --no-backup)
files (see --files)
format (see --format)
log_level (see --log-level)
naked_res (see --naked-res)
password (see --password)
=head1 ENVIRONMENT
=head2 ADD_PDF_PASSWORD_OPT
script/pdfnopass view on Meta::CPAN
=head1 VERSION
This document describes version 0.016 of pdfnopass (from Perl distribution App-PDFUtils), released on 2024-09-28.
=head1 SYNOPSIS
B<pdfnopass> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)
B<pdfnopass> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)
B<pdfnopass> [B<L<--backup|/"--no-backup">>|B<L<--no-backup|/"--no-backup">>|B<L<--nobackup|/"--no-backup">>] [B<L<--config-path|/"--config-path=s, -c">>=I<path>|B<L<-c|/"--config-path=s, -c">>|B<L<--no-config|/"--no-config, -C">>|B<L<-C|/"--no-confi...
=head1 DESCRIPTION
This program is a wrapper for L<qpdf> to remove passwords from PDF files
(in-place).
The motivation for this wrapper is the increasing occurence of financial
institutions sending financial statements or documents in the format of
password-protected PDF file. This is annoying when we want to archive the file
or use it in an organization because we have to remember different passwords for
different financial institutions and re-enter the password everytime we want to
use the file. (The banks could've sent the PDF in a password-protected .zip, or
use PGP-encrypted email, but I digress.)
Compared to using B<qpdf> directly, this wrapper offers some additional
features/options and convenience, for example: multiple file support, multiple
password matching attempt, configuration file, option whether you want backup,
etc.
You can provide the passwords to be tried in a configuration file,
C<~/remove-pdf-password.conf>, e.g.:
passwords = pass1
passwords = pass2
passwords = pass3
or:
script/pdfnopass view on Meta::CPAN
=item B<--files>=I<s@>*
(No description)
Can also be specified as the 1st command-line argument and onwards.
Can be specified multiple times.
=item B<--no-backup>
(No description)
=item B<--passwords-json>=I<s>
See C<--passwords>.
=item B<--passwords>=I<s@>
script/pdfnopass view on Meta::CPAN
-event=after_validate_args
arg1=val1
arg2=val2
which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.
List of available configuration parameters:
backup (see --no-backup)
files (see --files)
format (see --format)
log_level (see --log-level)
naked_res (see --naked-res)
passwords (see --passwords)
=head1 ENVIRONMENT
=head2 PDFNOPASS_OPT
script/remove-pdf-password view on Meta::CPAN
=head1 VERSION
This document describes version 0.016 of remove-pdf-password (from Perl distribution App-PDFUtils), released on 2024-09-28.
=head1 SYNOPSIS
B<remove-pdf-password> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)
B<remove-pdf-password> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)
B<remove-pdf-password> [B<L<--backup|/"--no-backup">>|B<L<--no-backup|/"--no-backup">>|B<L<--nobackup|/"--no-backup">>] [B<L<--config-path|/"--config-path=s, -c">>=I<path>|B<L<-c|/"--config-path=s, -c">>|B<L<--no-config|/"--no-config, -C">>|B<L<-C|/"...
=head1 DESCRIPTION
This program is a wrapper for L<qpdf> to remove passwords from PDF files
(in-place).
The motivation for this wrapper is the increasing occurence of financial
institutions sending financial statements or documents in the format of
password-protected PDF file. This is annoying when we want to archive the file
or use it in an organization because we have to remember different passwords for
different financial institutions and re-enter the password everytime we want to
use the file. (The banks could've sent the PDF in a password-protected .zip, or
use PGP-encrypted email, but I digress.)
Compared to using B<qpdf> directly, this wrapper offers some additional
features/options and convenience, for example: multiple file support, multiple
password matching attempt, configuration file, option whether you want backup,
etc.
You can provide the passwords to be tried in a configuration file,
C<~/remove-pdf-password.conf>, e.g.:
passwords = pass1
passwords = pass2
passwords = pass3
or:
script/remove-pdf-password view on Meta::CPAN
=item B<--files>=I<s@>*
(No description)
Can also be specified as the 1st command-line argument and onwards.
Can be specified multiple times.
=item B<--no-backup>
(No description)
=item B<--passwords-json>=I<s>
See C<--passwords>.
=item B<--passwords>=I<s@>
script/remove-pdf-password view on Meta::CPAN
-event=after_validate_args
arg1=val1
arg2=val2
which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.
List of available configuration parameters:
backup (see --no-backup)
files (see --files)
format (see --format)
log_level (see --log-level)
naked_res (see --naked-res)
passwords (see --passwords)
=head1 ENVIRONMENT
=head2 REMOVE_PDF_PASSWORD_OPT