Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Problem converting HTML to PDF

by stephen (Priest)
on Jan 29, 2003 at 21:56 UTC ( #231107=note: print w/replies, xml ) Need Help??

in reply to Problem converting HTML to PDF

A couple of points:

First, what's happening is that your program is dying before it gets the chance to produce any output. In order to see the error message, you need to put

use CGI::Carp qw(fatalsToBrowser);
at the top of your script. That way you'll see the error messages. When I try to run your script on my site, I get various errors from html2ps and Image::Magick. Can you run your script from the command line? If so, and it runs correctly, you've probably got a permissions issue.

Secondly, the 'binmode' line is unnecessary if you're on UNIX. Both the file structure you're using and the HTTP header tell me you're on UNIX, so I'd remove that.


Replies are listed 'Best First'.
Re: Re: Problem converting HTML to PDF
by ehdonhon (Curate) on Jan 29, 2003 at 22:43 UTC

    If it's dying, then why is the second call to Write() producing correct output? I would think if it died before that, the second call to Write() would never happen.

    I have tested both with binmode and without binmode. I was pretty certain that binmode didn't do anything in UNIX.

      >I also know that the $status value returned by both
      >Read() and Write() is empty (I think that means success).

      If you only think that, I really think you should check the documentation before you go any further.

      Everything that you call, check its return. Everything you do, print a line to see if it worked or died there.

      There's stuff you say you "know from debugging" -- why don't you post that stuff here?

      “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
      M-J D

        I also said that " I know that the second Write() call which outputs to STDERR does output a valid pdf file.". I didn't think anybody would find it useful for me to post the contents of the entire pdf file. Here's the first few lines of output produced from the second Write():

        %%Creator: (ImageMagick)
        %%Title: (GLOB(0x92ed52c))
        %%CreationDate: (Wed Jan 29 18:07:37 2003)

        And here are the last few lines:

        %%BoundingBox: 0 0 611 791

        UPDATE: I now realize this isn't what a pdf file looks like. This is what a postscript file looks like. Either I have totally missed the boat on how to use Image::Magick, or it doesn't quite work right for all combinations of conversions yet. In any event, thanks to everybody for their help, I've found a better solution to my problem.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://231107]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2020-06-02 18:19 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (19 votes). Check out past polls.