node-html-pdf icon indicating copy to clipboard operation
node-html-pdf copied to clipboard

Error write EPIPE

Open tashikomaaa opened this issue 7 years ago • 8 comments

Hello i try to build a bill generator i create a html content and i put it to this script ``import

pdf from 'html-pdf';

function createPDF(html) { console.log('createPDF'); const options = { height: '10.5in', // allowed units: mm, cm, in, px width: '8in', border: 0, type: 'pdf', }; pdf.create(html, options).toFile('tmp/facture.pdf', (err, data) => { if (err) { return err; } else { console.log('pdf created'); return data; } }); }

export default createPDF;``

but he allways say to me this error !?

SOme one can help me ?

{ Error: write EPIPE at exports._errnoException (util.js:1050:11) at Socket._writeGeneric (net.js:724:26) at Socket._write (net.js:743:8) at doWrite (_stream_writable.js:329:12) at writeOrBuffer (_stream_writable.js:315:5) at Socket.Writable.write (_stream_writable.js:241:11) at Socket.write (net.js:670:40) at PDF.PdfExec [as exec] (C:\Users\tttt\Documents\OYEZ\monoprix-order\node_modules\html-pdf\lib\pdf.js:141:15) at PDF.PdfToFile [as toFile] (C:\Users\tttt\Documents\OYEZ\monoprix-order\node_modules\html-pdf\lib\pdf.js:83:8) at createPDF (C:\Users\tttt\Documents\OYEZ\monoprix-order\dist\bundle.js:837:29) code: 'EPIPE', errno: 'EPIPE', syscall: 'write' }

tashikomaaa avatar Jan 18 '18 13:01 tashikomaaa

Install libfontconfig

$ apt-get install -y libfontconfig

adeyahya avatar Feb 04 '18 12:02 adeyahya

Did this solve the problem ????

premaddx avatar Mar 16 '18 07:03 premaddx

I get this error when phantomjs cannot be found. Confirm you have phantomjs-prebuilt in your node_modules. Phantomjs is also platform dependant so if you are building on windows and then trying to run on mac or something phantomjs will not work and you will get this error. You can download specific version of phantomjs based on an OS flag. https://www.npmjs.com/package/phantomjs-prebuilt

See section on Cross-Platform Repositories.

MattCBelanger avatar Apr 04 '18 13:04 MattCBelanger

Specify the phantomJS path phantomPath: './node_modules/phantomjs-prebuilt/bin/phantomjs',

worked for me

rdbmax avatar Sep 04 '18 08:09 rdbmax

Do this In case you are running the app inside docker alpine image, because phantomjs-prebuilt doesn't work on alpine

eitanpinchover avatar Aug 18 '20 07:08 eitanpinchover

Do this In case you are running the app inside docker alpine image, because phantomjs-prebuilt doesn't work on alpine

Thx! Answers from link helped me

theart84 avatar Nov 08 '21 18:11 theart84

Install libfontconfig

$ apt-get install -y libfontconfig

How to solve it in windows 10? I added phantomjs-prebuilt and corrected the path. but no luck

icecreamsandwich avatar Jan 05 '22 05:01 icecreamsandwich

For anyone using Amazon Linux 2 the following command fixes the issue:

sudo yum -y install fontconfig freetype

phil-warner avatar Jul 25 '22 14:07 phil-warner