App-PDFUtils
view release on metacpan or search on metacpan
script/add-pdf-password view on Meta::CPAN
#!perl
# Note: This script is a CLI for Riap function /App/PDFUtils/add_pdf_password
# and generated automatically using Perinci::CmdLine::Gen version 0.502
use 5.010001;
use strict;
use warnings;
use Log::ger;
use Perinci::CmdLine::Any;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2026-02-02'; # DATE
our $DIST = 'App-PDFUtils'; # DIST
our $VERSION = '0.017'; # VERSION
my $cmdline = Perinci::CmdLine::Any->new(
url => "/App/PDFUtils/add_pdf_password",
program_name => "add-pdf-password",
log => 1,
);
$cmdline->run;
# ABSTRACT: Password-protect PDF files
# PODNAME: add-pdf-password
__END__
=pod
=encoding UTF-8
=head1 NAME
add-pdf-password - Password-protect PDF files
=head1 VERSION
This document describes version 0.017 of add-pdf-password (from Perl distribution App-PDFUtils), released on 2026-02-02.
=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>
See C<--files>.
Can also be specified as the 1st command-line argument and onwards.
=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
=head2 Configuration options
=over
=item B<--config-path>=I<s>, B<-c>
Set path to configuration file.
Can actually be specified multiple times to instruct application to read from
multiple configuration files (and merge them).
=item B<--config-profile>=I<s>, B<-P>
Set configuration profile to use.
A single configuration file can contain profiles, i.e. alternative sets of
values that can be selected. For example:
[profile=dev]
username=foo
pass=beaver
[profile=production]
username=bar
pass=honey
When you specify C<--config-profile=dev>, C<username> will be set to C<foo> and
C<password> to C<beaver>. When you specify C<--config-profile=production>,
C<username> will be set to C<bar> and C<password> to C<honey>.
=item B<--no-config>, B<-C>
Do not use any configuration file.
If you specify C<--no-config>, the application will not read any configuration
file.
=back
=head2 Environment options
=over
=item B<--no-env>
Do not read environment for default options.
script/add-pdf-password view on Meta::CPAN
To activate bash completion for this script, put:
complete -C add-pdf-password add-pdf-password
in your bash startup (e.g. F<~/.bashrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.
It is recommended, however, that you install modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.
=head2 tcsh
To activate tcsh completion for this script, put:
complete add-pdf-password 'p/*/`add-pdf-password`/'
in your tcsh startup (e.g. F<~/.tcshrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.
It is also recommended to install L<shcompgen> (see above).
=head2 other shells
For fish and zsh, install L<shcompgen> as described above.
=head1 CONFIGURATION FILE
This script can read configuration files. Configuration files are in the format of L<IOD>, which is basically INI with some extra features.
By default, these names are searched for configuration filenames (can be changed using C<--config-path>): F</home/u1/.config/add-pdf-password.conf>, F</home/u1/add-pdf-password.conf>, or F</etc/add-pdf-password.conf>.
All found files will be read and merged.
To disable searching for configuration files, pass C<--no-config>.
You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.
You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...
You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...
To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:
[plugin=DumpArgs]
-event=before_validate_args
-prio=99
[plugin=Foo]
-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
String. Specify additional command-line options.
=head1 FILES
=head2 /home/u1/.config/add-pdf-password.conf
=head2 /home/u1/add-pdf-password.conf
=head2 /etc/add-pdf-password.conf
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/App-PDFUtils>.
=head1 SOURCE
Source repository is at L<https://github.com/perlancar/perl-App-PDFUtils>.
=head1 SEE ALSO
L<remove-pdf-password>.
=head1 AUTHOR
perlancar <perlancar@cpan.org>
=head1 CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull requests on
GitHub.
Most of the time, you don't need to build the distribution yourself. You can
simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your
system), you can install L<Dist::Zilla>,
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
that are considered a bug and can be reported to me.
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
( run in 0.784 second using v1.01-cache-2.11-cpan-39bf76dae61 )