This file is indexed.

/usr/bin/pdfstamp is in libtext-pdf-perl 0.31-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
#!/usr/bin/perl

use 5.006;    
use strict;   

=head1 NAME

pdfstamp.plx - Adds the given text in a given fonts, size to all pages
    at given location

=head1 DESCRIPTION

Adds the given string to the infile .pdf file at the given location,
    font and size.

=head1 SYNOPSIS

    pdfstamp [-f font] [-l locx,locy] [-s size] infile string

    -f font     Font name from the standard fonts [Helvetica]
    -l locx,locy    Location in points from bottom left of page [0,0]
    -s size     Font size to print at             [11]
    -t ttfile   TrueType font file to use (instead of -f)

=cut

use Text::PDF::File;
use Text::PDF::SFont;
use Text::PDF::Utils;

use Getopt::Std;
our ($opt_t,$opt_f,$opt_p,$opt_s,$opt_l);
getopts('f:l:ps:t:');

our $VERSION = 0.02;    #   MJPH    23-JUL-2001     Re-order to stamp on the top

unless ((defined $ARGV[1] || $opt_p) && -f $ARGV[0])
{
    die <<'EOT';
    pdfstamp [-f font] [-l locx,locy] [-s size] infile string
Adds the given string to the infile .pdf file at the given location, font and
size.

    -f font     Font name from the standard fonts [Helvetica]
    -l locx,locy    Location in points from bottom left of page [0,0]
    -p          Use the page number as the string
    -s size     Font size to print at             [11]
    -t ttfile   TrueType font file to use (instead of -f)
EOT
}

require Text::PDF::TTFont if ($opt_t);

$opt_f = 'Helvetica' unless $opt_f;
$opt_s = 11 unless $opt_s;
$opt_l =~ s/,\s*/ /o;
$opt_l = "0 0" unless $opt_l;

my ($pdf, $root, $pgs, $fpgins, $spgins, @pglist);

$pdf = Text::PDF::File->open($ARGV[0], 1);
$root = $pdf->{'Root'}->realise;
$pgs = $root->{'Pages'}->realise;

$fpgins = PDFDict(); $pdf->new_obj($fpgins);
$spgins = PDFDict(); $pdf->new_obj($spgins);
$fpgins->{' stream'} = "q";
$spgins->{' stream'} = "Q";

@pglist = proc_pages($pdf, $pgs);

my $max = 0;
foreach my $p (@pglist)
{
    my $dict = $p->find_prop('Resources');
    if (defined $dict && defined $dict->{'Font'})
    {
        foreach my $k (keys %{$dict->{'Font'}})
        {
            next unless $k =~ m/^ap([0-9]+)/o;
            my $val = $1;
            $max = $val if $val > $max;
        }
    }
}

$max++;
my $font;
if ($opt_t)
{ $font = Text::PDF::TTFont->new($pdf, $opt_t, "ap$max", -subset => 1) || die "Can't work with font $opt_t"; }
else
{ $font = Text::PDF::SFont->new($pdf, $opt_f, "ap$max") || die "Can't create font $opt_f"; }
my $stream = PDFDict();
$stream->{' stream'} = "BT 1 0 0 1 $opt_l Tm /ap$max $opt_s Tf " . $font->out_text($ARGV[1]) . " Tj ET";
$pdf->new_obj($stream);
my $count = 1;
foreach my $p (@pglist)
{
    my ($s) = $stream;
    if ($opt_p)
    {
        $s = PDFDict();
        $s->{' stream'} = "BT 1 0 0 1 $opt_l Tm /ap$max $opt_s Tf " . $font->out_text($count++) . " Tj ET";
        $pdf->new_obj($s);
    }
    $p->add_font($font, $pdf);
    $p->{Contents} = PDFArray($fpgins, $p->{Contents}->elementsof, $spgins, $s);
    $pdf->out_obj($p);
}

$pdf->close_file;

sub proc_pages
{
    my ($pdf, $pgs) = @_;
    my ($pg, $pgref, @pglist, $pcount);

    foreach $pgref ($pgs->{'Kids'}->elementsof)
    {
        $pg = $pdf->read_obj($pgref);
        if ($pg->{'Type'}->val =~ m/^Pages$/oi)
        { push(@pglist, proc_pages($pdf, $pg)); }
        else
        {
            $pgref->{' pnum'} = $pcount++;
            push (@pglist, $pgref);
        }
    }
    (@pglist);
}