Closed wallslide closed 12 years ago
Doh, youre right.. the buffer size does need to be configurable. Feel free to fork and create a pull request and illl merge those changes in.
I think the ideal solution is to create js bindings to wkhtml, but this will work for now.
I pushed a major refactor that uses spawn. You can listen to the data event directly on the stream or just pipe it to the response or filesystem. Check out the examples and let me know if you have any questions. Thanks!
As seen at this URL:
http://nodejs.org/docs/v0.4.9/api/child_processes.html#child_process.exec
There are options that can be passed in to the exec() command to increase the maximum buffer size, and to force binary encoding. I was getting this error:
"exec error: Error: maxBuffer exceeded."
with this command:
To solve the error I edited the PDF.prototype.convert function found in "node-wkhtml/lib/image.js" to pass in a larger maxBuffer argument like this:
Although this got rid of the error message, when I saved the resultant data into a database and tried to read it out, it was not parsable as an image file (although there was definitely the correct amount of data saved). To solve this final problem, I told exec to use binary encoding like this:
I think it makes sense that the encoding should always be set to binary in this case. As for the maxBuffer, I'm not sure if setting a large number has any effect beyond the potential for an extremely large image to hurt the system. It might be good if this was an argument a user could pass in through the convert() function since they should have a better idea of their size requirements.