App-PDFUtils

 view release on metacpan or  search on metacpan

script/pdfnopass  view on Meta::CPAN

#!perl

# Note: This script is a CLI for Riap function /App/PDFUtils/remove_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/remove_pdf_password",
    program_name => "pdfnopass",
    log => 1,
    config_filename => "remove-pdf-password.conf",
);

$cmdline->run;

# ABSTRACT: Short alias for remove-pdf-password
# PODNAME: pdfnopass

__END__

=pod

=encoding UTF-8

=head1 NAME

pdfnopass - Short alias for remove-pdf-password

=head1 VERSION

This document describes version 0.017 of pdfnopass (from Perl distribution App-PDFUtils), released on 2026-02-02.

=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:

 passwords = ["pass1", "pass2", "pass3"]

=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<--passwords-json>=I<s>

See C<--passwords>.

=item B<--passwords>=I<s@>

(No description)


Can be specified multiple times.

=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

script/pdfnopass  view on Meta::CPAN

To activate bash completion for this script, put:

 complete -C pdfnopass pdfnopass

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 pdfnopass 'p/*/`pdfnopass`/'

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/remove-pdf-password.conf>, F</home/u1/remove-pdf-password.conf>, or F</etc/remove-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)
 passwords (see --passwords)

=head1 ENVIRONMENT

=head2 PDFNOPASS_OPT

String. Specify additional command-line options.

=head1 FILES

=head2 /home/u1/.config/remove-pdf-password.conf

=head2 /home/u1/remove-pdf-password.conf

=head2 /etc/remove-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<add-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 1.102 second using v1.01-cache-2.11-cpan-39bf76dae61 )