in reply to Re^3: How to make work HTML::HTMLDoc on browser?
in thread How to make work HTML::HTMLDoc on browser?

Hi rnewsham , I have the same issue with elavarasan. Please help me solve it. I've been working on this for more than a week now. Please see my codes below

#!/usr/bin/perl5 use HTML::HTMLDoc; use strict; use warnings; use CGI; my $cgi=new CGI; print $cgi->header( -type => 'application/pdf' ); my $htmldoc = new HTML::HTMLDoc('mode'=>'file', 'tmpdir'=>'/tmp'); $htmldoc->set_permissions('all'); $htmldoc->set_html_content(qq~<html><body><table border=1><tr><td cols +pan=2>A PDF file</td></tr><tr><td>Column 1</td><td><img src='freight- +charge.jpg'></td></tr></table></body></html>~); # $htmldoc->set_input_file($filename); # alternative to use a present +file from your fs my $pdf = $htmldoc->generate_pdf(); print $pdf->to_string(); $pdf->to_file('foo.pdf');

Replies are listed 'Best First'.
Re^5: How to make work HTML::HTMLDoc on browser?
by rnewsham (Curate) on Aug 02, 2013 at 22:59 UTC

    I have tested your code and it works for me.

    Assuming you have already followed my earlier suggestions, for tracing the problem, I think the best think to do is try to contact the creators of the module.

      Did it work when you run it from the browser? what browser did you use? I already contacted the author and he gave a suggestion, then i followed it but still it didn't work perfectfully. Well, it can generate the pdf file with no contents, always 0 bytes. Is this something to do with our server configuration?

        The script works, running it from the command line or browser does not make any difference. Your problem is not with the script or how it is being executed. The problem is with your system, htmldoc or HTML::HTMLDoc.

        You could try reinstalling htmldoc and HTML::HTMLDoc or try the same code on a different system. Perhaps try setting up a virtual machine and test the code there. If it works on another system you may be able to compare the two to find the problem.