Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

That worked beautifully! Thank you so much! Here is the final code in case anyone is interested:

#!perl # Command Line Arguments:: # 0 = path to original pdf # 1 = job identifier # 2 = folio start - must pass 1 # include modules use PDF::API2; # declarations use constant mm => 25.4 / 72; use constant in => 1 / 72; use constant pt => 1; # load pdf from passed argument my $pdf = PDF::API2->open($ARGV[0]) || die("Unable to open PDF"); # new pdf to hold legal size my $pdf_out = PDF::API2->new; # font definition my %font = ( Verdana => { Bold => $pdf_out->corefont('Verdana-Bold',-encoding => 'lati +n1' ), Roman => $pdf_out->corefont('Verdana',-encoding => 'latin1' ) +, Italic => $pdf_out->corefont('Verdana-Italic',-encoding => 'la +tin1' ) } ); # get total number of pages my $pagenumber = $pdf->pages; # folio offset my $offset = int($ARGV[2]-1); for ($count=1; $count<=$pagenumber; $count++) { # get the current page/new page my $page = $pdf->openpage($count); my $page_out = $pdf_out->page(0); # resize new pdf page to legal $page_out->mediabox('Legal'); $page_out->cropbox('Legal'); $page_out->bleedbox('Legal'); $page_out->trimbox('Legal'); $page_out->artbox('Legal'); # turn old pdf into graphic # import into new pdf at offset my $gfx = $page_out->gfx; my $xo = $pdf_out->importPageIntoForm($pdf, $count); # 612x1008 = legal # 612x792 = letter # y diff is 216 $gfx->formimage($xo, 0, 216, # x y 1); # scale # add our folio identifier # construct a text box my $text = $page_out->text; # define font, face, pointsize $text->font( $font{"Verdana"}{"Roman"}, 12/pt ); # font color (not background) $text->fillcolor("#000000"); # x/y coords, remember cartesian coordinates, left,bottom = 0,0 # for a 8.5x11 doc, the bottom left viewable (not in bleed/crop ar +ea) is approx 68,0 ? $text->translate( 74/pt, 3/pt ); # actual text to place, text_right is single line look at text_blo +ck for para's $text->text_right($ARGV[1] . "_" . ($count+$offset)); } # save and close $pdf_out->saveas("C:\\dp\\perlTest.pdf"); $pdf_out->end(); exit

In reply to Re^2: PDF::API2 Page Dimensions Layout by dimv
in thread PDF::API2 Page Dimensions Layout by dimv

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found