Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
thank you for that "form"-hint. that was what i needed. i finally assembled a script which does perfectly what i wanted to achieve:

i know that the string concatenation ($string) is a bit clumsy, but i wanted to add the comments. you cannot have comments in quotes, can you?

use strict; use PDF::API2; use PDF::Reuse; # specify files my $ifile = "c:/kopie/anlage-h-beg.pdf"; my $ofile = "c:/kopie/new.pdf"; #find out number of pages my $ipdf = PDF::API2->open($ifile); my $nop = $ipdf->pages; $ipdf->end(); #set outfile for PDF::Reuse prFile($ofile); #get font my $intName = prFont("Helvetica"); # assemble watermark text my $string = # save graphic state "q\n" . # Begin Text "BT\n" . # set font and "size" "/$intName 1 Tf\n" . # set a text matrix # 1. width of text # 2. rotation angle (counterclockwise) # 3. inclination (clockwise) # 4. height of text # 5. position x (0=left) # 6. position y (0=bottom) "180 60 -60 180 100 185 Tm\n" . #set rgb-color (values between 0 and 1) #"1 0 0 rg" . #set grayscale (white=1 black=0) "0.9 g\n" . # show text "(Kopie) Tj\n" . # End Text "ET\n" . "Q\n"; #loop over pages for (my $i=1;$i<=$nop;$i++) { #add watermark prAdd ($string); #add original content my $internalName = prForm ( { file => $ifile, page => $i, effect => 'print', tolerant => 'no' } ); #add pagebreak prPage; } #save and close prEnd();

In reply to Re^2: Add watermark to a pdf by holli
in thread Add watermark to a pdf by holli

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (5)
    As of 2018-02-21 07:57 GMT
    Find Nodes?
      Voting Booth?
      When it is dark outside I am happiest to see ...

      Results (276 votes). Check out past polls.