As described on wkhtmltopdf Google group
(http://code.google.com/p/wkhtmltopdf/issues/detail?id=162), I have a
problem generating a PDF while using popen and wkhtmltopdf.
wkhtmltopdf takes HTML code as input and ouputs a PDF file. Here is what
I'm doing:
command = '"C:\Program Files\wkhtmltopdf\wkhtmltopdf.exe" - - -q'
IO.popen(command, 'r+') do |f|
# Writing the html previously rendered in a string
f.write(html_output)
f.close_write
# Reading the ouput and closing
pdf = f.readlines
f.close
# Returning the pdf data
pdf
end
This code results in a corrupted PDF file. I checked the PDF itself
which shows some differences with a valid PDF file, like some missing
closing tags (endstream) - but I'm not an expert of that format.
Well, my question is the following: am I doing it wrong, using a wrong
method, missing something, or wkhtmltopdf is more likely to be the
problem?
I attached the corrupted file.
If you have a look at it, you'll notice that a PDF EOF symbol is there,
which tends to say that the generation was not interrupted in any way.
Any idea?
Thanks for your help!
- Nicolas
Attachments:
http://www.ruby-forum.com/attachment/4453/corrupted.pdf