Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
use Text::PDF::File; |
| 4 |
|
| 5 |
unless (defined $ARGV[0]) |
| 6 |
{ |
| 7 |
die <<'EOT'; |
| 8 |
PDFREVERT infile |
| 9 |
|
| 10 |
Removes one layer of changes to a PDF file, trying to maximise the size of the |
| 11 |
output file (to account for linearised PDF). |
| 12 |
EOT |
| 13 |
} |
| 14 |
|
| 15 |
$cr = '\s*(?:\r|\n|(?:\r\n))'; |
| 16 |
$VERSION = "1.000"; # MJPH 6-NOV-1998 Original |
| 17 |
|
| 18 |
$f = Text::PDF::File->open($ARGV[0], 1); |
| 19 |
exit unless defined $f->{'Prev'}; |
| 20 |
|
| 21 |
# account for linearised pdf, maximise output |
| 22 |
for ($t = $f; defined $t->{' prev'}; $t = $t->{' prev'}) |
| 23 |
{ |
| 24 |
$loc1 = $t->{'Prev'}->val; |
| 25 |
$loc = $loc1 if ($loc1 > $loc); |
| 26 |
} |
| 27 |
|
| 28 |
$fd = $f->{' INFILE'}; |
| 29 |
seek($fd, $loc, 0); |
| 30 |
$rest = ""; |
| 31 |
while ($len = read($fd, $dat, 1024)) |
| 32 |
{ |
| 33 |
$len += length($rest); |
| 34 |
$_ = $rest . $dat; |
| 35 |
if (m/(?:\r|\n|(?:\r\n))%%EOF$cr/oi) |
| 36 |
{ |
| 37 |
$loc += length($` . $&); |
| 38 |
last; |
| 39 |
} |
| 40 |
elsif (m/$cr(.*?)$/oi) |
| 41 |
{ |
| 42 |
$rest = $1; |
| 43 |
$loc += $len - length($rest); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
if ($len != 0) |
| 48 |
{ |
| 49 |
truncate($fd, $loc) || die "Can't truncate"; |
| 50 |
} |
| 51 |
|