I'm using wkhtmltopdf as service to download pdf in a web app, in local server work perfectly, but when I send to production on heroku show this error:
Error: write EPIPE
at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:66:16)
Emitted 'error' event at:
at errorOrDestroy (internal/streams/destroy.js:98:12)
at onwriteError (_stream_writable.js:436:5)
at onwrite (_stream_writable.js:461:5)
at _destroy (internal/streams/destroy.js:40:7)
at Socket._destroy (net.js:618:3)
at Socket.destroy (internal/streams/destroy.js:32:8)
at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:67:12)
The code that I'm using is this:
const htmlToPdf = async ({ body: { html } }, res) => {
const decodedHTml = decodeURI(html);
fs.readFile(path.join(__dirname, "", "style.css"), (err, data)=> {
if (error) throw error;
const style = `<style>${data}</style>`
wkhtmltopdf(style + decodedHTml, { pageSize: "A4" }).pipe(res);
});
};
The error is caused when you have not installed the command line version of wkhtmltopdf since this is just a wrapper.
Check available builds: