Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Comment on

( #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

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 snow settles gently...

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

      Results (264 votes). Check out past polls.