Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

PDF::API2 page setup

by ksublondie (Friar)
on Aug 17, 2011 at 23:00 UTC ( #920813=perlquestion: print w/replies, xml ) Need Help??
ksublondie has asked for the wisdom of the Perl Monks concerning the following question:

I'm using PDF::API2 to create documents that are non-letter sized. Even though the pages are the correct size, when I go into the print dialog box of the open document, the paper size/type/etc is still set to letter and the printer can't automatically pick the correct printer tray.

Is there a way to programatically set these fields?


Here's my current code:

foreach (@data){ $line=144; $page= $pdf->page(); $page->mediabox('Legal'); $page->trimbox('Legal'); ... }

Replies are listed 'Best First'.
Re: PDF::API2 page setup
by Perlbotics (Chancellor) on Aug 17, 2011 at 23:12 UTC

    The PDF::API2 doc has something to say about setting the mediabox. Does invoking this method improve the situation?

    $pdf->mediabox($name) $pdf->mediabox($w, $h) $pdf->mediabox($llx, $lly, $urx, $ury)

    Sets the global mediabox.


    $pdf = PDF::API2->new(); $pdf->mediabox('A4'); ... $pdf->saveas('our/new.pdf'); $pdf = PDF::API2->new(); $pdf->mediabox(595, 842); ... $pdf->saveas('our/new.pdf'); $pdf = PDF::API2->new; $pdf->mediabox(0, 0, 595, 842); ... $pdf->saveas('our/new.pdf');

      That's exactly how I'm already setting the page size (I'm not aware of any other way to do it), but the print dialog box isn't recognizing the settings. Like I said, the pages are setup with the right size, the problem is in the print dialog box. It keeps trying to print to "Letter" for everything, no matter the size.
        It might also help to set the trimbox as well.

        To quote PDF page boxes:

        "The TrimBox defines the intended dimensions of the finished page. Contrary to the CropBox, the TrimBox is very important because it defines the actual page size."
Re: PDF::API2 page setup
by Neighbour (Friar) on Aug 18, 2011 at 10:24 UTC
    If you're printing from adobe's acrobat reader, try unchecking the option 'Choose paper source by PDF page size'. (Or adjust the page size to match :))
      That worked! However, it would be nice if Adobe would allow that to be a document setting like Word & WordPerfect do and not a workstation setting.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://920813]
Approved by toolic
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2018-07-20 10:50 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (428 votes). Check out past polls.