/usr/bin/pdfrevert is in libtext-pdf-perl 0.29a-3.
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 | #!/usr/bin/perl
=head1 NAME
pdfrevert.plx - Removes one layer of edits from a PDF file
=head1 DESCRIPTION
Removes one layer of changes to a PDF file, trying to maximise the
size of the output file (to account for linearised PDF).
=head1 SYNOPSIS
PDFREVERT infile
=cut
use Text::PDF::File;
unless (defined $ARGV[0])
{
die <<'EOT';
PDFREVERT infile
Removes one layer of changes to a PDF file, trying to maximise the size of the
output file (to account for linearised PDF).
EOT
}
$cr = '\s*(?:\r|\n|(?:\r\n))';
$VERSION = "1.000"; # MJPH 6-NOV-1998 Original
$f = Text::PDF::File->open($ARGV[0], 1);
exit unless defined $f->{'Prev'};
# account for linearised pdf, maximise output
for ($t = $f; defined $t->{' prev'}; $t = $t->{' prev'})
{
$loc1 = $t->{'Prev'}->val;
$loc = $loc1 if ($loc1 > $loc);
}
$fd = $f->{' INFILE'};
seek($fd, $loc, 0);
$rest = "";
while ($len = read($fd, $dat, 1024))
{
$len += length($rest);
$_ = $rest . $dat;
if (m/(?:\r|\n|(?:\r\n))%%EOF$cr/oi)
{
$loc += length($` . $&);
last;
}
elsif (m/$cr(.*?)$/oi)
{
$rest = $1;
$loc += $len - length($rest);
}
}
if ($len != 0)
{
truncate($fd, $loc) || die "Can't truncate";
}
|