Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF::API2 Z Order problem 2

Status
Not open for further replies.

menkes

Programmer
Nov 18, 2002
47
US
I am just playing around with this, and have run into a problem I cannot fix. Here is the code:
Code:
use PDF::API2;
my @cols = @ARGV;
my $yLoc = 720;

my $pdf  = PDF::API2->new(-file => "$0.pdf");
$pdf->mediabox(595,842);
my $page = $pdf->page;

my $box = $page->gfx();
$box->fillcolor( 'lightgrey' );
$box->rect(40, 718, 532, 13);
$box->fill;

my $fnt = $pdf->corefont('Arial',-encoding => 'latin1'); 
my $txt = $page->text;

$txt->font($fnt, 9);
$txt->textstart;
$txt->translate($cols[0],$yLoc);
$txt->text("1234");
$txt->translate($cols[1],$yLoc);
$txt->text("DP");
# More of the same follows....

$yLoc -= 12;
$txt->translate($cols[0],$yLoc);
$txt->text("5678");
$txt->translate($cols[1],$yLoc);
$txt->text("RQ");
# More of the same follows....

$txt->textend;
$pdf->save;
$pdf->end();

Basically the effect I want is rows of columnar data, with every other row having a light gray background (I'll make it more dynamic, etc. after I prove I can do it).

The problem is that the rectangle covers the text. I tried this:
Code:
my $box = $page->gfx(1);

...but what I get with that is the same problem, AND the text below the rectangle is changed to the rectangle's fill color.

Any ideas??
 
Well, guess this is not used enough to get a response in these forums (first time that has happened).

So, for those who stumble across this post - I found the answer.

Text is treated as a graphic in creating PDFs with this module. The only time I set the fill color was for the rectangle:
Code:
$box-> fillcolor( 'lightgrey' );
The text in the same area just took that as it's fillcolor. By explicitly designating the fillcolor for the text object, I get the desired result of black text on a grey background:
Code:
$txt -> fillcolor( '#000000' );

For anyone interested in the module, documentation is non-existent. However, there is a group at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top