Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

setting PDF background color

by akwe-xavante (Novice)
on Mar 29, 2013 at 11:34 UTC ( #1026138=perlquestion: print w/replies, xml ) Need Help??
akwe-xavante has asked for the wisdom of the Perl Monks concerning the following question:

Hoping someone can help me with a, what I hope is silly question with a simple answer. I've googled for a couple of hours now and I just don't get it and i'm failing to find an answer

All i'm wanting to do is set the background color of the entire page to a specific hex color. I don't want white I would like to set the page color to #FAF8CC to start with, might turn it down a little further

Here is the first few lines of code

my $pdf = PDF::API2->new(-file => "$SavedAttachment"); $pdf->mediabox(595,842); my $page = $pdf->page; my $fnt = $pdf->corefont('Arial',-encode => 'latin1'); my $txt = $page->text; $txt->textstart; ###### Logo at top center of page # my $image_02 = $page->gfx; my $image_file = $pdf->image_gif("$Logo"); $image_02->image( $image_file, 260,745,72,72 ); ###### Add Customer Name and Address # $txt->font($fnt, 8); $txt->translate(25,630); $txt->fillcolor('black'); $txt->text("$FullCustName");

Replies are listed 'Best First'.
Re: setting PDF background color
by Khen1950fx (Canon) on Mar 30, 2013 at 11:56 UTC
    Run ths first:
    #!/usr/bin/perl use strict; use warnings; use PDF::API2; my $file = 'SavedAttachment.pdf'; my $pdf = PDF::API2->new( -file => $file ); $pdf->mediabox( 595, 842 ); my $page = $pdf->page; my $fnt = $pdf->corefont( 'Arial', -encode => 'latin1' ); my $txt = $page->text; $txt->textstart; $txt->font( $fnt, 8 ); $txt->translate( 25, 630 ); $txt->fillcolor('black'); $txt->text("FullCustName"); $pdf->saveas; exit;
    Then try from the command line: -o SavedAttachment.pdf 1 fcd SavedAttachment.pdf
    I used fcd because I wanted something neutral and down-to-earth.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2018-07-23 15:58 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 (472 votes). Check out past polls.