Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello fellow monks,

I'm having some difficulty with the following chunk of code, from a cgi which is intended to take whatever my web page looks like at the moment, convert it to a pdf and serve that pdf to the client:

use Image::Magick; my $html2ps = '/usr/local/bin/html2ps'; print "Content-type: application/pdf\n\n"; open ( FIN, "$html2ps http://mypage.com/index?param=x&foo=y' |" ); my $image = Image::Magick->new; # I don't think binmode is necessary in ps or pdf, but # I'm adding it just in case it makes a difference. binmode FIN; my $status = $image->Read(file=>\*FIN); warn( "Read status = $status" ); $image->set(format=>'pdf'); binmode STDOUT; $image->set(file=>\*STDOUT); $status = $image->Write(); warn( "Write status = $status" ); $image->set(file=>\*STDERR); $status = $image->Write();

From my debugging, I know that Image::Magick does actually read in the postscript file correctly. I also know that the $status value returned by both Read() and Write() is empty (I think that means success). Also I know that the second Write() call which outputs to STDERR does output a valid pdf file.

My problem, is that the first Write() call which should be sending output to STDOUT isn't doing anything at all! In fact, here is all the output that the web server returns from this cgi:

HTTP/1.1 200 OK
Connection: close
Date: Wed, 29 Jan 2003 20:50:01 GMT
Server: Apache/1.3.26 (Unix) mod_perl/1.27 mod_ssl/2.8.9 OpenSSL/0.9.6e
Content-Type: application/pdf
Client-Date: Wed, 29 Jan 2003 20:50:48 GMT
Client-Peer: 1.2.3.4:80

All its returning back are the headers. No output from the Write(). Can anybody tell me what I'm doing wrong?


In reply to Problem converting HTML to PDF by ehdonhon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-23 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found