You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically, I have a project that consists in generating a pdf file from a template with a form inside of it.
My template is a double-sided pdf, the first one being the cover page, and the second one being the content. In the content, I have a form : a text-field, that will contain some text, and a button that will contain an image (I used the example in the fill form page of the PDF-Lib website for the button with image)
The goal is to generate a lot of pdfs at once from a json file that will contain a list of element with the text and the image that will be used.
How did you attempt to do it?
I'm iterating over my json input. For each iteration, I will get my TextField, my Button, and add my text and image into them. Then, I will use the copyPages method into my final pdfFile, and add the page to it.
Finally, I'm adding it to my response for my local client.
I get my PDF, I can open it. Each image is different, but the text displayed is the same for every page. Obviously, my json file has different text, and if I console.log(jsonInput.text), it will log the text that is supposed to be shown.
What did you expect to happen?
Each page of the pdf should have a different text and image.
How can we reproduce the issue?
Create a node.js local server, here's the post method code. I replaced the image by the one used in the pdf lib demo.
What were you trying to do?
Basically, I have a project that consists in generating a pdf file from a template with a form inside of it.
My template is a double-sided pdf, the first one being the cover page, and the second one being the content. In the content, I have a form : a text-field, that will contain some text, and a button that will contain an image (I used the example in the fill form page of the PDF-Lib website for the button with image)
The goal is to generate a lot of pdfs at once from a json file that will contain a list of element with the text and the image that will be used.
How did you attempt to do it?
I'm iterating over my json input. For each iteration, I will get my TextField, my Button, and add my text and image into them. Then, I will use the copyPages method into my final pdfFile, and add the page to it.
Finally, I'm adding it to my response for my local client.
`
const newPdfDoc = await PDFDocument.PDFDocument.create();
const jsonInput = JSON.parse(req.body.json);
for await (const element of jsonInput.keys) {
const pdfBuffer = await fs.readFile('./public/uploads/test.pdf');
const pdfDoc = await PDFDocument.PDFDocument.load(pdfBuffer);
`
What actually happened?
I get my PDF, I can open it. Each image is different, but the text displayed is the same for every page. Obviously, my json file has different text, and if I console.log(jsonInput.text), it will log the text that is supposed to be shown.
What did you expect to happen?
Each page of the pdf should have a different text and image.
How can we reproduce the issue?
Create a node.js local server, here's the post method code. I replaced the image by the one used in the pdf lib demo.
`
`
Also, here's the json I'm using:
keys.json
Version
1.17.1
What environment are you running pdf-lib in?
Browser, Node
Checklist
Additional Notes
No response
The text was updated successfully, but these errors were encountered: