Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

PDF::FromHTML istallation problem or script?

by jonnyfolk (Vicar)
on Aug 10, 2006 at 13:30 UTC ( #566616=perlquestion: print w/replies, xml ) Need Help??
jonnyfolk has asked for the wisdom of the Perl Monks concerning the following question:

I'm having a problem with a script which uses PDF::FromHTML. My provider says it is a problem on the script - I don't think so!

I wondered if some kind person would take a look and either let me know ther error of my ways, or give me the courage to face up to my provider...


#!/usr/bin/perl -w use PDF::FromHTML; my $pdf = PDF::FromHTML->new( encoding => 'utf-8' ); $pdf->load_file('source.html'); $pdf->convert; $pdf->write_file('target.pdf'); print "Content-type: text/html\n\n"; print "done";

Gives the error:

Can't locate in @INC (@INC contains:/usr/local/lib/perl5/5.8.2/i386-freebsd /usr/local/lib/perl5/5.8.2 /usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd
/usr/local/lib/perl5/site_perl/5.8.2 /usr/local/lib/perl5/site_perl .) at /usr/local/lib/perl5/site_perl/5.8.2/PDF/ line 13.
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.8.2/PDF/ line 13.
Compilation failed in require at /usr/local/lib/perl5/site_perl/5.8.2/PDF/ line 20.
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.8.2/PDF/ line 20.
Compilation failed in require at line 5.
BEGIN failed--compilation aborted at line 5.

Update: I just wanted to give a heads up on the outcome of this. I have discovered that PDF::Template is the 'culprit' in all this, requiring pdflib_pl, though the next version is promised to include PDF::API2. My provider has kindly installed pdflib_pl Lite and I shall have to test to see how restrictive that is...

Replies are listed 'Best First'.
Re: PDF::FromHTML installation problem or script?
by davorg (Chancellor) on Aug 10, 2006 at 13:37 UTC

    The Makefile provides some potential clues. It looks like PDF::FromHTML can either use PDF::API2 or pdflib_pl to do the actual heavy lifting. From the error message, I'd guess that it's trying to use pdflib_pl and that this module isn't installed.

    Makes you wonder exactly how your provider installed the modules - I'd expect something like this to be picked up in the tests even if it somehow gets past the dependency checks in the Makefile.


    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Thanks for your reply, davorg.

      I have checked the installed modules and PDF::API2 has been installed - might there have been a faulty installation do you think, or is there anyway I can meaningfully call it up in my script to overcome this?

        There's a chain here. PDF::FromHTML uses PDF::Writer which uses either PDF::API2 or pdflib. If PDF::API is installed correctly then PDF::Writer should use that in preference to pdflib. The fact that it's looking for pdflib (as shown in the error message in your original post) means that there's almost certainly something wrong with the installation of either PDF::API2 or PDF::Writer.

        I'd test those assumptions by writing small test programs that use those modules. Work up from the bottom level (PDF::API2) and see at what level things start to go wrong. Then go to your provider and ask them how they installed (and tested) the modules.


        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg

Re: PDF::FromHTML istallation problem or script?
by planetscape (Chancellor) on Aug 10, 2006 at 19:56 UTC

    I am hoping that what you have shown us is a much shorter example of your actual script and that you do in fact

    use strict; use warnings;

    for they will help you insure that there are no problems in your script...

    Please see

    Why you should use strict

    Use strict and warnings

    for more information.


Re: PDF::FromHTML istallation problem or script?
by fmerges (Chaplain) on Aug 10, 2006 at 22:17 UTC


    By the way, you can also do this kind of stuff, using something like htmldoc, personally I'd very good results using it.


    fmerges at
Re: PDF::FromHTML istallation problem or script?
by Khen1950fx (Canon) on Aug 11, 2006 at 00:36 UTC
    Hi. I've been looking at your script. You might want to test it again at  $pdf -> convert; Convert what? I would add something here for it to chew on like font, width, height, landscape, path to font, etc. Maybe that will kick it into gear.
      Hi, $pdf->convert needs no parameters. When no one ist given, it use standards. But has anyone use thid Module with unicode-characters? My HTML contains german chars like '' and it would contain russian text soon. It doesn't matter if I write it in utf-8 or as ö, all non-ACSCII-chars are deleted. I tried to set an unicode-font, but it uses PDF::API2::Resource::Font::CoreFont::* fonts, which are allways without any unicode definition. Any idea? Tobi PS: htmldoc is very poor. Only HTML 3.2, no CSS, bugs when your source contain <form>-Tags, ony ISO-8859-1 (died with no message). That's the reason, why I want to use PDF::FromHTML.
        Ive also been looking at this script and have a weird problem. I too want only html converted to pdf and I input the file names and when I run the script I get the error not well-formed (invalid token) at line 2, column 0, byte 39 at /usr/lib/perl5/site_perl/5.8.7/i686-linux/XML/ line 187 Now WHY is it trying to use the XML parser? The script is identical to the one posted in this thread. It sais nothing about parsing XML. Im at a stand still. I have no idea what file to edit in order to possibly comment out the instructions to parse the xml version of the html file I want to make into a pdf. Any help on this would be greatly appreciated... Regards and thanks in advance Dan

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://566616]
Approved by Corion
[Discipulus]: yes erix when you specify a Tk geometry 10x10 it goes from 0,0 to 10,10 aka 11x11

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2018-04-24 09:06 GMT
Find Nodes?
    Voting Booth?