This leaves the background (the imported PDF contents) intact and prints the text over this background (Though not semi-transparent, which you might want).sub PrintTextAngle { my ($texthandler, $x, $y, $rot, $text, $options) = @_; $texthandler->transform('-translate'=> [6/mm+$x/mm,10/mm+$y/mm], ' +-rotate'=>$rot); $texthandler->text($text, $options); } my $pdf_input = PDF::API2->open("$Filename"); foreach my $pagenr (1..$pdf_input->pages) { my $page = $pdf_input->openpage($pagenr); my $texthandler = $page->text; my $font = $pdf_input->corefont( 'Helvetica-Bold', -encode => ' +latin1' ); $texthandler->fillcolor('grey'); $texthandler->font($font, 256/pt); PrintTextAngle($texthandler, 50, 60, 45, "TEST"); $texthandler->font($font, 56/pt); PrintTextAngle($texthandler, 20, 10, 0, "Do not throw away!"); } $pdf_input->saveas("$Filename-TEST.pdf");
If you still insist on toying with the overprint setting, use this:
Before calling PrintTextAngle, set the Extended Graphics State using:my $EGOverprint = $pdf->egstate(); my $EGNormal = $pdf->egstate(); $EGOverprint->strokeoverprint(1); $EGNormal->strokeoverprint(0);
Then print, and afterwards (if you want to print some more without using overprint) restore the Extended Graphics State with:$text->egstate($EGOverprint);
$text->egstate($EGNormal);
In reply to Re^3: PDF::API2 and opacity
by Neighbour
in thread PDF::API2 and opacity
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |