Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Html to PDF convertor

by arnab2k4 (Initiate)
on Sep 20, 2006 at 12:19 UTC ( [id://573876]=perlquestion: print w/replies, xml ) Need Help??

arnab2k4 has asked for the wisdom of the Perl Monks concerning the following question:

Hi everybody,

I am a perl programmer, and I need to convert a html text to PDF format on the fly.I am using perl 5 and linux 9.

To do this I have installed module HTML-HTMLDoc-0.10 but it didn't work . Whenever I tried to install this module:
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" test_htmldoc.PL test_htmldoc htmldoc not found. please install first make: *** [test_htmldoc] Error 1
I have got this error msg and I was unable to install it .

Anybody could please help me how to generate a PDF file from the html file.

edit: holli added formatting as intended by the author

Replies are listed 'Best First'.
Re: Html to PDF convertor
by Joost (Canon) on Sep 20, 2006 at 12:30 UTC
      Another bad point for CPAN: nowhere in the installation is the presence or absence of the htmldoc program tested for, or even mentioned. There's even no standardized way in the MakeMaker utils to list it. It is a dependency, isn't it? It's the same with external libraries, those dependencies aren't checked either. ("probably harmless", yeah, right.)

      This dependency is the reason for the huge amount of test failures on CPAN Testers. But if you don't look at the report very closely, you won't even see what is wrong. This is very user-unfriendly, for anybody who isn't at least a sysadmin by profession.

Re: Html to PDF convertor
by hgolden (Pilgrim) on Sep 20, 2006 at 12:32 UTC
Re: Html to PDF convertor
by leocharre (Priest) on Sep 20, 2006 at 14:44 UTC

    Just in case one should 'empower' the rest of the people in the office: pdfizer. I just remember doing this myself before when something else was perhaps what was needed. Please keep in mind I don't know your situation.

    What's linux 9? Perl 5?

    You can do # perl -v on your terminal to get the version of your perl. there *are* differences between 5.x.x and 5.y.y

    For the os, you can do # echo `uname -r`

    update (sorry you don't need echo.. i'm running a fever.)

    uname gives system info, interesting is like uname -a for all , uname -r is kernel ver, often distro info can be there.

    uname -r
Re: Html to PDF convertor
by rbi (Monk) on Sep 20, 2006 at 15:59 UTC
    I've installed html2ps, written in Perl, and Ghostscript that has the ps2pdf utility.
    then you could do something like:
    my $HTML2PS = '/usr/local/bin/html2ps -L'; my $PS2PDF = '/usr/bin/ps2pdf'; my $plot_file_base = 'whatever'; # First create an HTML file (or slurp it from file) my $h2p = "<html><head></head><body> <img src=$pngfile> </body></html>"; my $file_to_ps = $plot_file_base.'_to_ps.htm'; open (FH,">$file_to_ps") or die "cannot open $file_to_ps: $!\n"; print FH $h2p; close(FH); # Then create a ps file my $file_ps = $plot_file_base.'.ps'; system "$HTML2PS $file_to_ps > $file_ps"; #And finally convert it to PDF my $file_pdf = $plot_file_base.'.pdf'; system "$PS2PDF $file_ps $file_pdf"; unlink $file_to_ps; unlink $file_ps;
    Hope this can help.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2025-06-17 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.