Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: PDF::Table last page

by vr (Curate)
on Apr 16, 2018 at 16:48 UTC ( [id://1213009]=note: print w/replies, xml ) Need Help??


in reply to PDF::Table last page

It's good you have solution that finally works, but we don't know what 'main_table', 'main_table2' (and 'newpage2', 'footer2'), that you keep mentioning, are about, and how they would react to empty array refs or undefined scalars ('empty variable' - what's that?).

But, looking at source of PDF::Table, passing an empty array ref, as data, to its table method is, indeed, fatal error in 0.10.0, though it wasn't so in 0.9.7. Not sure what you expect to be placed, as a table, on that 'last page', if you pass no data. I haven't used this module before, but from documentation,

my ($final_page, $number_of_pages, $final_y) = table($pdf, $page, $dat +a, %settings)

perhaps means that table fills as many pages as required, automatically.

-------

A side-note: PDF::Table's POD, and then your code, pass an '-encoding' parameter to corefont method of PDF::API2. It's not a meaningful parameter and is just ignored. Perhaps '-encode' was supposed instead, but you shouldn't use it.

Looking at source, it only makes sense if it is some single-byte encoding for a single-byte encoded font. Passing 'utf8' results in indices 129..255 in Encoding dictionary to stand for the same 'uniFFFD' name. Consider:

use strict;
use warnings;
use utf8;
use PDF::API2;

my $pdf  = PDF::API2-> new;
my $page = $pdf-> page;
my $font = $pdf-> corefont( 'Helvetica', '-encode' => 'utf8' );
my $text = $page-> text;

$text-> font( $font, 20 );
$text-> translate( 200, 700 );
$text-> text( 'рсту' );

$pdf-> saveas( 'test.pdf' );

Oops, broken PDF file with '.notdef' glyphs rendered. Just remove the '-encode' parameter, and file becomes OK.

For 'core' fonts, single-byte encoding other than 'latin1' would be useless. For arbitrary unicode texts and TTFs which support required codepoints (i.e. ttfont method is called to create a double-byte encoded font), it looks like '-encode' parameter is ignored anyway. The PDF::API2's psfont method, and PostScript Type1 custom-encoded fonts are very retro, and of historical interest only.

TL;DR -- don't use '-encode' (nor '-encoding'), its obsolete.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1213009]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-26 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found