问题
Similar to this post PDF::FromHTML creates empty PDF
I have the following code
$textblob='<html><head></head><body><p>HelloWorld</p></body></html>';
my $output;
if(defined($query->param('PDF'))){
my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
$pdf->load_file(\$textblob);
$pdf->convert(
# With PDF::API2, font names such as 'traditional' also works
Font => 'Arial',
LineHeight => 10,
Landscape => 1,
);
$pdf->write_file(\$output);
print $output;
}
In Firefox this simply gives me an empty PDF page, when I save the page and view it in Acrobat it reports the file is corrupt/damaged and cannot be repaired. TIA.
回答1:
My error was elsewhere in the script thanks for looking/commenting (note do not :
binmode STDOUT, ':encoding(UTF-8)';
if you want to use this module obvs).
Of course the Anchors don't work/appear now for some unknown reason :-(
来源:https://stackoverflow.com/questions/57967465/pdffromhtml-corrupt-file-and-no-output