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' }
Install libfontconfig
$ apt-get install -y libfontconfig
Did this solve the problem ????
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.
Specify the phantomJS path
phantomPath: './node_modules/phantomjs-prebuilt/bin/phantomjs',
worked for me
Do this In case you are running the app inside docker alpine image, because phantomjs-prebuilt doesn't work on alpine
Most helpful comment
Install
libfontconfig