Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: Add Border to a PDF file

by snoopy (Deacon)
on Jul 24, 2007 at 07:41 UTC ( #628403=note: print w/replies, xml ) Need Help??

in reply to Re^2: Add Border to a PDF file
in thread Add Border to a PDF file

Here's a second cut. This preserves the page size and shrinks the graphics by 10%:
#!/usr/bin/perl use warnings; use strict; use PDF::API2; my $pdf_in = PDF::API2->open('/tmp/test.pdf'); my $pdf_out = PDF::API2->new; foreach my $pagenum (1 .. $pdf_in->pages) { my $page_in = $pdf_in->openpage($pagenum); # # create new page # my $page_out = $pdf_out->page(0); # # Get the page size # my @mbox = $page_in->get_mediabox; # # Inherit mediabox $page_out->mediabox(@mbox); # # # copy page as a form. reduce slightly. # my $xo = $pdf_out->importPageIntoForm($pdf_in, $pagenum); my $gfx = $page_out->gfx; $gfx->formimage($xo, my $_x = 20, my $_y = 20, my $_scale = .9); # # Draw a box 10pt in from the edges of the page # $gfx->linewidth(1); $gfx->strokecolor('#000000'); $gfx->rect($mbox[0]+10, $mbox[1]+10, $mbox[2]-20, $mbox[3]-20); $gfx->stroke; } $pdf_out->saveas('/tmp/test2.pdf');

Replies are listed 'Best First'.
Re^4: Add Border to a PDF file
by Anonymous Monk on Jul 24, 2007 at 15:24 UTC
    Thank you very much. This works perfect.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://628403]
[shmem]: go figure. Might help to open views to other ways of perceiving reality. No, no supernatural stuff.
[shmem]: the "Vineyard" is a biblic term, also. But that's not the point.
[erix]: sorry, my attention is a rar commodity. I will not squander it on such pro-russia sites :)
[erix]: *rare commodity
[shmem]: erix: you are utterly mistaken in marking that site as "pro-russian".
[erix]: how do you mean? the bear, explanations of Putin's "election", the fearsome new russian weaponry. I came across them immediately. Just coincidence?

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2018-03-19 21:03 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.