in reply to Help with PDF module
G'day BernieC,
Here's a quick comparison of PDF-related modules.
$ perl -E ' use strict; use warnings; use PDF::API2; my $pdf = PDF::API2->new(); my $font = $pdf->font("Helvetica-Bold"); for my $p (1 .. 10) { my $page = $pdf->page(); my $text = $page->text(); $text->font($font, 20); $text->position(200, 700); $text->text("Page: $p"); } $pdf->save("test.pdf"); ' $ file test.pdf test.pdf: PDF document, version 1.4, 10 pages $ perl -E ' use strict; use warnings; use PDF::API2; my $pdf = PDF::API2->open("test.pdf"); say "Page count: ", $pdf->page_count(); ' Page count: 10
See its README.md for possible hurdles to using this, such as requiring Perl v5.24; having said that, it installed first time for me using the cpan utility (I have Perl v5.36.0).
Given the similarities, I just repeated the test I did previously, replacing API2 with Builder and test.pdf with test2.pdf. At least in this respect, PDF::API2 and PDF::Builder function identically. If anyone has other information re PDF::API2 vs. PDF::Builder, please add comments.
$ perl -E ' use strict; use warnings; use PDF::Builder; my $pdf = PDF::Builder->new(); my $font = $pdf->font("Helvetica-Bold"); for my $p (1 .. 10) { my $page = $pdf->page(); my $text = $page->text(); $text->font($font, 20); $text->position(200, 700); $text->text("Page: $p"); } $pdf->save("test2.pdf"); ' $ file test2.pdf test2.pdf: PDF document, version 1.4, 10 pages perl -E ' use strict; use warnings; use PDF::Builder; my $pdf = PDF::Builder->open("test2.pdf"); say "Page count: ", $pdf->page_count(); ' Page count: 10
Update (additional information): I just noticed that the PDF produced by PDF::Builder is substantially bigger than that produced by PDF::API2. I would have expected them to be almost the same size.
ken@titan ~/tmp/pm_11152014_pdf $ ls -l total 16 -rw-r--r-- 1 ken None 4272 May 7 00:50 test.pdf -rw-r--r-- 1 ken None 7024 May 7 01:05 test2.pdf
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help with PDF module [comparison]
by kcott (Archbishop) on May 07, 2023 at 00:48 UTC | |
|
Re^2: Help with PDF module [comparison]
by Anonymous Monk on May 08, 2023 at 10:35 UTC |