/usr/bin/pdfinfo.cam-pdf is in libcam-pdf-perl 1.60-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | #!/usr/bin/perl -w
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
package main;
use warnings;
use strict;
use CAM::PDF;
use Getopt::Long;
use Pod::Usage;
use English qw(-no_match_vars);
our $VERSION = '1.60';
my %opts = (
verbose => 0,
help => 0,
version => 0,
);
Getopt::Long::Configure('bundling');
GetOptions('v|verbose' => \$opts{verbose},
'h|help' => \$opts{help},
'V|version' => \$opts{version},
) or pod2usage(1);
if ($opts{help})
{
pod2usage(-exitstatus => 0, -verbose => 2);
}
if ($opts{version})
{
print "CAM::PDF v$CAM::PDF::VERSION\n";
exit 0;
}
if (@ARGV < 1)
{
pod2usage(1);
}
while (@ARGV > 0)
{
my $file = shift;
# prompt for password
my $doc = CAM::PDF->new($file, q{}, q{}, 1) || die "$CAM::PDF::errstr\n";
if ($file eq q{-})
{
$file = 'STDIN';
}
my $size = length $doc->{content};
my $pages = $doc->numPages();
my @prefs = $doc->getPrefs();
my $pdfversion = $doc->{pdfversion};
my $pdfinfo = $doc->{trailer}->{Info};
$pdfinfo &&= $doc->getValue($pdfinfo);
my @pagesize = (0,0);
my $p = $doc->{Pages};
my $box = $p->{MediaBox};
if ($box)
{
$box = $box->{value};
@pagesize = ($box->[2]->{value} - $box->[0]->{value},
$box->[3]->{value} - $box->[1]->{value});
}
print "File: $file\n";
print "File Size: $size bytes\n";
print "Pages: $pages\n";
if ($pdfinfo)
{
my $date = qr/(\d{4})(\d{2})(\d{2})/xms;
my $time = qr/(\d{2})(\d{2})(\d{2})/xms;
my $tz = qr/([+-Z])(\d{2})\'(\d{2})\'/xms;
foreach my $key (sort keys %{$pdfinfo})
{
my $val = $pdfinfo->{$key}->{value};
if ($pdfinfo->{$key}->{type} eq 'string' && $val &&
$val =~ m{ \A
D: $date $time $tz
\z
}xms)
{
my ($Y,$M,$D,$h,$m,$s,$sign,$tzh,$tzm) = ($1,$2,$3,$4,$5,$6,$7,$8,$9);
if ($sign eq 'Z')
{
$sign = q{+};
}
require Time::Local;
my $timegm = Time::Local::timegm($s,$m,$h,$D,$M-1,$Y-1900);
my $tzshift = $sign . ($tzh*3600 + $tzm*60);
$timegm += $tzshift;
$val = localtime $timegm;
}
printf "%-13s %s\n", $key.q{:}, $val;
}
}
print 'Page Size: '.($pagesize[0] ? "$pagesize[0] x $pagesize[1] pts" : 'variable')."\n";
print 'Optimized: '.($doc->isLinearized()?'yes':'no')."\n";
print "PDF version: $pdfversion\n";
print "Security\n";
if ($prefs[0] || $prefs[1])
{
print " Passwd: '$prefs[0]', '$prefs[1]'\n";
}
else
{
print " Passwd: none\n";
}
print ' Print: '.($prefs[2]?'yes':'no')."\n";
print ' Modify: '.($prefs[3]?'yes':'no')."\n";
print ' Copy: '.($prefs[4]?'yes':'no')."\n";
print ' Add: '.($prefs[5]?'yes':'no')."\n";
if (@ARGV > 0)
{
print "---------------------------------\n";
}
}
__END__
=for stopwords pdfinfo.pl
=head1 NAME
pdfinfo.pl - Print information about PDF file(s)
=head1 SYNOPSIS
pdfinfo.pl [options] file.pdf [file.pdf ...]
Options:
-v --verbose print diagnostic messages
-h --help verbose help message
-V --version print CAM::PDF version
=head1 DESCRIPTION
Prints to STDOUT various basic details about the specified PDF
file(s).
=head1 SEE ALSO
CAM::PDF
=head1 AUTHOR
See L<CAM::PDF>
=cut
|