-
I inherited a working project that generates a PDF using react-pdf/renderer. It currently brings up a development server, which then renders the PDF in a browser using static data (json). I would like to automate this process in a headless environment. Is it possible to invoke react-pdf/renderer as a headless, command line script? Are there any examples of this? The ideal for my needs is The current rendering code (server.js) is quite simple:
Edit 1: The outstanding issue is that |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
I think issue here is that you are not exporting the ReactDocument properly. Try adding the line |
Beta Was this translation helpful? Give feedback.
-
You can use react-pdf in node.js. Try const pdf = require('@react-pdf/renderer').pdf
const stream = pdf(DocumentJsx).toBuffer() //though the name is "buffer" it returns a readable
process.stdout.pipe(stream) // or however youd like to consume your stream |
Beta Was this translation helpful? Give feedback.
I think issue here is that you are not exporting the ReactDocument properly. Try adding the line
export default ReportDocument
at the end of the jsx file, and see if it works.