[英]Error: write EPIPE with wkhtmltopdf + nodejs on Heroku
我使用 wkhtmltopdf 作為服務在 web 應用程序中下載 pdf,在本地服務器上工作正常,但是當我在 heroku 上發送到生產時顯示此錯誤:
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)
我正在使用的代碼是這樣的:
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);
});
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.