Open MatheusLuiz2000 opened 4 years ago
You could use toStream()
instead.
Example:
pdf.create(html).toStream((error, stream) => {
stream.pipe(() => {
let pass = new stream.PassThrough();
s3.upload({
Bucket: "",
Key: "",
ContentType: "application/pdf",
Body: pass
}, (error, data) => {
// Finished uploading or error
});
return pass;
});
});
Have you tried adding phantomPath
?
pdf.create(html, {
phantomPath: path.resolve(
process.cwd(),
"node_modules/phantomjs-prebuilt/bin/phantomjs"
),
})
您是否尝试过添加 ?
phantomPath
pdf.create(html, { phantomPath: path.resolve( process.cwd(), "node_modules/phantomjs-prebuilt/bin/phantomjs" ), })
ReferenceError: path is not defined, What's the path here?
@Jiale-Li path is a node module. You will need to require it like so:
const path = require('path')
In your code what the resolve method does is basically combines your current working directory and the path for phantomjs into an absolute path.
@Jiale-Li path is a node module. You will need to require it like so:
const path = require('path')
In your code what the resolve method does is basically combines your current working directory and the path for phantomjs into an absolute path.
Ah, thank you. I see, but it didn't work. I tried to convert HTML directly to PDF, Error reporting looks like a problem with the pipeline, I should learn something about it.
Error: write EPIPE at afterWriteDispatched (internal/stream_base_commons.js:154:25) at writeGeneric (internal/stream_base_commons.js:145:3) at Socket._writeGeneric (net.js:784:11) at Socket._write (net.js:796:8) at doWrite (_stream_writable.js:442:12) at writeOrBuffer (_stream_writable.js:426:5) at Socket.Writable.write (_stream_writable.js:317:11) at PDF.PdfExec [as exec] (D:\Workspace\dpdf\node_modules\html-pdf\lib\pdf.js:154:15) at PDF.PdfToFile [as toFile] (D:\Workspace\dpdf\node_modules\html-pdf\lib\pdf.js:83:8) at D:\Workspace\dpdf\app.js:53:31
So I believe that write EPIPE
errors usually mean that the writing failed because the receiving end closed the connection.
Which bit of your code is on line 53 in app.js?
So I believe that
write EPIPE
errors usually mean that the writing failed because the receiving end closed the connection.Which bit of your code is on line 53 in app.js?
I found that I did not install phantomjs prebuild and am trying to install it now
pdf.create(html, options).toFile('./tmp/test.pdf', (err, data) => {
if (err) {
res.send({
code: 1,
msg: 'err!'
})
} else {
res.sendFile(data)
}
});
So I believe that
write EPIPE
errors usually mean that the writing failed because the receiving end closed the connection.Which bit of your code is on line 53 in app.js?
Thank you. I've solved it. Your suggestion is valid only if phantomjs prebuild is installed; After the correct phantompath is configured, everything is normal; Although a "referenceerror: can't find variable: $" error occurred later, I removed the script through regular expressions and everything went back to normal.
Glad to hear you got it working! :)
So I believe that
write EPIPE
errors usually mean that the writing failed because the receiving end closed the connection. Which bit of your code is on line 53 in app.js?Thank you. I've solved it. Your suggestion is valid only if phantomjs prebuild is installed; After the correct phantompath is configured, everything is normal; Although a "referenceerror: can't find variable: $" error occurred later, I removed the script through regular expressions and everything went back to normal.
Hi, I think I'm having a very similar issue. I'm not an experienced dev, could you please share the steps you did to fix it¿?
This is my error, i'm using pdf-creator- node which uses phantom.js
events.js:292 throw er; // Unhandled 'error' event ^
Error: write EPIPE
at afterWriteDispatched (internal/stream_base_commons.js:156:25)
at writeGeneric (internal/stream_base_commons.js:147:3)
at Socket._writeGeneric (net.js:785:11)
at Socket._write (net.js:797:8)
at writeOrBuffer (internal/streams/writable.js:358:12)
at Socket.Writable.write (internal/streams/writable.js:303:10)
at PDF.PdfExec [as exec] (/app/node_modules/html-pdf/lib/pdf.js:156:15)
at PDF.PdfToFile [as toFile] (/app/node_modules/html-pdf/lib/pdf.js:85:8)
at /app/node_modules/pdf-creator-node/index.js:69:20
at new Promise (
Hey guys,
I having this error when i get the buffer of content of pdf and save in S3.
The error:
How i doing the generate PDF