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 Module problems

Status
Not open for further replies.

1DMF

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

I've been hunting for a simple module to take a HTML page and convert it to PDF, which I then want to attach to an email and send.

I've found PDF::FromHTML , but am having problems striping it apart to use on my hosting as I cannot install modules.

I got the CPAN tar and extracted the FromHTML.pm and placed that up on my site, but when i try to use it I get the following error...

Can't locate PDF/Writer.pm

I've tried use PDF; and it errors so I assume the PDF module isn't installed, I checked every folder in the tar file from CPAN and cannot find Writer.pm to put up myself, so I am assuming this module has dependencies on other modules not installed or supplied with FromHTML.

so is there a way for me to use this module in the manner i want or is there another module out there that can be used the way i would like, or is my only option to get m y host to install the PDF module and the FromHTML modules?

I really hope I can do this without getting my host to install any modules, they have enough trouble just keeping the damn server up.

all help appreciated.

1DMF.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
i've extracted the other modules to the correct location however, i've hit this error, what does it mean?

Base class package "XML::Twig" is empty.
(Perhaps you need to 'use' the module which defines that package first.)
at /cgi-bin/XML/Twig.pm line 6
BEGIN failed--compilation aborted at /cgi-bin/XML/Twig.pm line 6.
Compilation failed in require at /cgi-bin/PDF/FromHTML/Twig.pm line 5.
BEGIN failed--compilation aborted at /cgi-bin/PDF/FromHTML/Twig.pm line 5.
Compilation failed in require at /cgi-bin/FromHTML.pm line 20.
BEGIN failed--compilation aborted at /cgi-bin/FromHTML.pm line 20.
Compilation failed in require at \cgi-bin\subcompforms2.cgi line 33.
BEGIN failed--compilation aborted at \cgi-bin\subcompforms2.cgi line 33.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
right i've found an alternative but am having trouble using the module..
the synopsis shows the usage of a method 'to_string()' , yet it is not mentioned anywhere or shown in the method listing, so what does it do? , using it doesn't error so one assumes the method exists.

Also when I run the to_file method the PDF that is created is empty and has a file size of ZERO ?

what am I doing wrong? here is my usage...

Code:
  my $htmldoc = new HTML::HTMLDoc();
   $htmldoc->set_input_file(DIR_TO_CGI . '/source.html') or die "can't open HTML";
  my $pdf = $htmldoc->generate_pdf() or die "PDF generation error";
  print $pdf->to_string() or die "to_string error";
  $pdf->to_file(DIR_TO_HTTPS . '/marketing/target.pdf') or die "can't create PDF";


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I have even tried my $htmldoc = new HTMLDoc('mode'=>'file', 'tmpdir'=>'/tmp'); as this is meant to solve some PDF creation problems but it hasn't worked.

I still just keep getting a zero byte PDF created? anyone know why?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I don't think you're going to have a happy coding experience until you sort the Twig installation issue.

Have a careful look at the installation instructions for the PDF module and go through each module it says it needs, installing and testing as neccessary.

Hmmm, and your chances of getting it running without having new modules installed on your host server don't look good to me.

Mike

The options are: fast, cheap and right - pick any two... [orientalbow] & [anakin]

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
I've seen similar postings on other forums, this seems to be a hard module to get working, and then to get decent results if you do get it working.

- Kevin, perl coder unexceptional!
 
I emailed the module writer, and the nice chap replied :-)

apparently HTML::HTMLDoc is just a wrapper for HTMLDoc.exe , he suggested placing the exe binary in the location of the executing script and supplied me a download link, but it didn't work :-(

So I emailed my host and asked them to install PDF::FromHTML for me, i'll have to see if they can do this.

I'm close to having our new dedicated server up and running and will be able to have full control of the server and install what I like, oh happy days, so I'm sure i'm gonna need some hand holding through the install process from you nice chappies once that's up and running ;-)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Power corrupts. Absolute power, well you know the story. You become a Unix sysadmin...

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]
 
Power corrupts. Absolute power, well you know the story. You become a Unix sysadmin...
Not if you're running Windows ;-)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
You'll be needing one of these, then...



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]
 
Well now I know what you think of me :-P

"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.

Part and Inventory Search

Sponsor

Back
Top