PhilterPaper / Perl-PDF-Builder

Extended version of the popular PDF::API2 Perl-based PDF library for creating, reading, and modifying PDF documents
https://www.catskilltech.com/FreeSW/product/PDF%2DBuilder/title/PDF%3A%3ABuilder/freeSW_full
Other
6 stars 7 forks source link

Adding truetype text to existing PDF fails to create output PDF with v3.026 #221

Open muehlenp opened 1 month ago

muehlenp commented 1 month ago

Using PDF::Builder v3.026 with the following test script gives an error when trying to save the output PDF.

use PDF::Builder;
print "PDF::Builder v$PDF::Builder::VERSION\n";
my $pdf=PDF::Builder->open('test_input.pdf');
my $page=$pdf->openpage(1);
my $text=$page->text();
my $font=$pdf->font('/usr/share/fonts/truetype/msttcorefonts/Arial.ttf');
$text->font($font, 20);
$text->position(200, 700);
$text->text('Hello World!');
$pdf->saveas('test_output.pdf');

PDF::Builder v3.026 Can't call method "outobj" on unblessed reference at .../lib/perl5/PDF/Builder/Basic/PDF/Dict.pm line 178.

Sample PDF: test_input.pdf

Creating a new PDF and a blank page instead of opening an existing PDF/page works without any error. Running PDF::Builder v3.025 it works, too. Tested under openSuse, Ubuntu and Windows 10 with several input PDFs and fonts.

PhilterPaper commented 1 month ago

I wonder if this is related to your other ticket about adding content to an existing PDF. I have noticed some TTF issues on new PDFs that sound like this, but I thought they were introduced in 3.027 (yet to be released). Another thing to fix...

When you say '3.026', is that the CPAN official release, or are you grabbing from GitHub (near 3.027)? It would be good to know which one you're using.

muehlenp commented 1 month ago

Because of the readonly files issue I tried to use PDF::Builder instead of PDF::API2 in my application and stumbled upon this problem. All versions I tested were installed by cpanm.

PhilterPaper commented 1 month ago

OK, so this was the official (December 2023) 3.026 release, and not the almost-3.027 release on GitHub. Good to know. It gives me another avenue of finding out this TTF problem.