PDF::FromHTML - Corrupt file and no output

不问归期 提交于 2020-01-04 09:06:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!