Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF::FromHTML Help Needed

Status
Not open for further replies.

1DMF

Programmer
Joined
Jan 18, 2005
Messages
8,795
Location
GB
Hello,

I've managed to get my host to install the PDF::FromHTML module, but am having problems using it, I am getting the following error

C:\WINDOWS\TEMP\LOCxj0Xv2T.xml: 'TABLE' (align center height 100% valign middle width 100%) didn't make a node!

I checked the module and it seems this is the line that generates this error
Code:
my $node = PDF::FromHTML::Template::Factory->create_node($name, @_);
                die "'$name' (@_) didn't make a node!\n" unless defined $node;

So why is it having problems creating a table node? what does this error mean and how can I resolve it.

Regards,

1DMF.


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
According to the doc on CPAN, there is a command line utility supplied with PDF::FromHTML
Code:
html2pdf.pl source.html > target.pdf
This might be a way of proving that it's installed properly, in which case you could focus on the way you are calling it. Can you post the code you're using to call it with?

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::PerlDesignPatterns)[/small]
 
I can't use command line, it's hosting by 3rd party.

here is the code
Code:
my $pdf = PDF::FromHTML->new( encoding => 'utf-8' ) or die "New Failed";
    $pdf->load_file(DIR_TO_CGI . '/source.html') or die "Load Failed";
    $pdf->convert(
        Font        => 'arial.ttf',
        LineHeight  => 10,
        Landscape   => 1,
    ) or die "Convert Failed";
    $pdf->write_file(DIR_TO_HTTPS . '/marketing/target.pdf') or die "Create Failed";

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
It looks exactly like the example on CPAN. One thing - is
Code:
DIR_TO_CGI . '/source.html'
actually a file, or is it a CGI script?

Also, is DIR_TO_CGI a constant, or should it have a $ on the front?

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::PerlDesignPatterns)[/small]
 
it's a constant containing the full path details , but you knew that didn't you ;-)

if i remove all content from the source.html and just put "this text should appear" between the body tags , the pdf gets created with the text.

so paths and stuff is all fine, it just don't like the table tag, i haven't tested with other tags, but either way, if it can't handle a simple table tag then the module is of no use to me as i have div's , select lists, textarea etc in the HTML.

I expect it to handle the linked CCS file as well, i'm wondering if this module is up to the job!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I emailed the module writer, they implied that I have failed to close the table tag !!! how rude - lol

but my page validates 100% with w3c , I deleted everything but 1 table and got a illegal operation division by zero error, so I then removed the attributes in the table tag such as width etc... and it worked.

So me thinks this module might be pants!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Looking at the docs, it seems to use a parser called Twig, which is actually an XML parser. As XML is a lot stricter than HTML about tags, if they are using it to parse the HTML, maybe it falls down here?

Here's a few suggestions: make sure the case of the opening and closing tags is the same, and make sure any attributes are XML compliant e.g.
Code:
<tag attr1="stuff">more stuff</tag>
and tags like
Code:
<br>
might have to be
Code:
<br/>



Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::PerlDesignPatterns)[/small]
 
that doesn't seem to be the issue, here is the email response from the author
Code:
? Jan 20, 2007 12:22 AM ??Craig Chant ???

> Thanks for the reply,
>
> Well the page validates via W3C, you can check here...
>
> [URL unfurl="true"]http://validator.w3.org/check?uri=https%3A%2F%2Fcwcs16.cwcs.co.uk%2F%7Ehomeuk%2Fsource.html[/URL]
>
>  , but I cut it down to a minimum
>
> ......
>
> <body>
> <table width="68%" align="center" >
>     <tr>
>         <td >
>             this is a test
>         </td>
>     </tr>
> </table>
> </body>
>
> ......
>
>  and I got an illegal operation division by zero error.

Strangely it works perfectly for me... Are you using PDF::From 0.21 from CPAN?

Cheers,
Audrey
So now I am having to ask the webhost what module exactly they installed as my page is valid X/HTML and it works fine for Audrey.

i'm going down the pub, it's gone 5pm on a friday night and i'm loosing the will to live with my current webhost.

have a great weekend, i'll feedback next week as to how I get on.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Well apparently I have the right module installed, Audrey then suggested also getting HTML::Tidy installed, which has been done, but I am still getting the same error...
C:\WINDOWS\TEMP\HFzphXGIFq.xml: 'TABLE' (align center width 68%) didn't make a node!
yet with the same source HTML file Audrey says it works for her.

The only difference between our systems is she is on Unix and i'm on windows, could this be the reason? or maybe this module doesn't work properly on windows?

Or any one got any other suggestions?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Sorry mate, but I have no suggestions.

- Kevin, perl coder unexceptional!
 
well i've just installed FromHTML & HTML::Tidy on our dedicated server and guess what
C:\WINDOWS\TEMP\e3Fsj4JOVP.xml: 'TABLE' (align center width 68%) didn't make a node!
So now i'm thinking this module doesn't work on windows 2003 , IIS6 & ActiveState Perl 5.8 , as this is 2 boxes both with the same problem, and w3c says my X/HTML is 100% valid!

So who knows of another module that does work on windows, that doesn't use HTMLDoc ?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Well apparently I found a bug, there is now a version 0.22 of PDF::FromHTML module.

But don't get too excited, I still wasn't getting the desired results and emailed Audrey (the module writer) explaining that my CSS wasn't working....here is the response
PDF::FromHTML does not make use of the CSS information, and I'm afraid there is no plan to do so...

Audrey

So basicaly this module is useless as it is not standards compliant and only works with those sites writen in non-standards HTML with hardcoded fonts, colours, images etc...

So back to the drawing board.

Does anyone have a suggestion on a X/HTML to RTF converter that will work with the current standards in web design using CSS?

I'm thinking this PDF hunt is fruitless!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
well if nothing else the module writer has kindly asked me to help write a heads-up to include in the module documentation so people don't expect more than the module is capable of.

would you mind helping me write a short heads-up notice in the PDF::FromHTML's documentation, to warn against people having expectations beyond its capability?

Thanks,
Audrey

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top