Change font size on PDF::TextBlock Perl

Viewed 88

Struggling to set the font size on a block of text using PDF::TextBlock.

use PDF::TextBlock;
my $tb  = PDF::TextBlock->new({
    pdf       => $pdf,
    page      => $page,
    x            => 20,
    y            => 200,
    w            => 550,
    fonts     => {
       b => PDF::TextBlock::Font->new({
       pdf  => $pdf,
       font => $pdf->corefont( 'Helvetica-Bold', -encoding => 'latin1' ),
     }),
   },
 });

Where to put the size? Have tried size=>4, size=>'4/pt', fontsize=>4. Nothing in the documentation on this. Any ideas?

1 Answers

This works for me (change b to default and add size parameter):

my $tb  = PDF::TextBlock->new({
    pdf       => $pdf,
    page      => $page,
    x         => 20,
    y         => 200,
    w         => 550,
    fonts     => {
      default => PDF::TextBlock::Font->new({
        pdf  => $pdf,
        font => $pdf->corefont( 'Helvetica-Bold', -encoding => 'latin1' ),
        size => 24,
      }),
    },
 });

$tb->text('Hello');
Related