Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: PDF API2

by vr (Curate)
on May 04, 2017 at 13:54 UTC ( [id://1189500]=note: print w/replies, xml ) Need Help??


in reply to PDF API2

use strict; use warnings; use PDF::API2; sub _p ($) { $_[ 0 ] / 25.4 * 72 } # mm to postscript points my $pdf = PDF::API2-> open( 'docu.pdf' ); my $logo = $pdf-> image_png( 'logo.png' ); for my $i ( 1 .. $pdf-> pages ) { my $p = $pdf-> openpage( $i ); my ( $llx, $lly, $urx, $ury ) = $p-> get_mediabox; my $gfx = $p-> gfx( 1 ); # prepend content $gfx-> save; $gfx-> translate( 0, _p -20 ); # shift 20 mm down $gfx = $p-> gfx; # append content $gfx-> restore; my $scale = 0.25; # scale 0 .. 1, adjust as desired my $x = # let's make it centered! ( $urx - $llx - $scale * $logo-> width ) / 2; my $y = $ury - _p 20; # 20 mm from top $gfx-> image( $logo, $x, $y, $scale ); } $pdf-> update; # you had a backup, right?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1189500]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found