Open turbo2ltr opened 7 months ago
Note, up until recently, my work around for this was to Rename the Form Fields on each page to include the page number. Page 1 Field "Name" => renamed to Name1 Page 2 Field "Name" => Name2 Rename is done before the copy over.
Note: This has issues with radio buttons.
Note 2: Recent Edge PDF reader update, now doesn't display field data. Not sure if related, still troubleshooting
Follow up: With the new Edge Acrobat Reader, one hack that was working is to "copy field by field" and place new field in the same location with the value set. This worked for base 1 page form becoming multi-page form. I am still working through this to do Multi-Page forms to Mega-Multipage form.
Note: If you use the edge Acrobat Reader to Print to pdf/printer, entries are there. Also, Flatting the form also makes it work (not the solution, but a possible workaround)
So found a solution that covers 1 page form into multi-page form and multi=>multi
I built a "Copy Form" Function
const sourceAnnotation = PDFAnnotation.fromDict(field.acroField.dict); const sourceRect = sourceAnnotation.getRectangle();
const newField = toForm.createTextField(name); newField.addToPage(destPage, { x: sourceRect.x, y: sourceRect.y, width: sourceRect.width, height: sourceRect.height, textColor: rgb(0, 0, 0) }); const currentAnnotation = PDFAnnotation.fromDict(newField.acroField.dict); currentAnnotation.setRectangle(sourceRect); newField.setText(value);
Note: you must manage copying to the correct page outside of this.I have only tested this with text fields.
Hopefully, this will help someone
What were you trying to do?
I have a one page fillable PDF document (a roster list) that I use PDF-LIB to fill in with the list of people that have RSVPd. No problem. Sometimes I need multiple pages if there are more than x number of people. Since I only have one template document, I create multiple pdf-lib documents and fill in each one separately. Then I create a new blank master document and merge all the individual pages into the master using
copyPages
. When viewed in Chrome based browsers, the document is as expected.When viewed in Adobe Reader, the first page is filled out, the rest of the pages, the PDF is there, but all the fields are blank.
How did you attempt to do it?
Overall approach was:
What actually happened?
The code works. It generates a PDF. But the PDF renders differently in Adobe than other readers. In Chrome and Foxit, the PDF has all pages and all fields on all pages are properly filled In Adobe, the first page has a fully filled PDF, but any additional pages have the original template PDF, but none of the field data is displayed.
What did you expect to happen?
I expected the PDF to show all the fields on all readers.
How can we reproduce the issue?
Some simplified pseudo code.
Version
1.17.1
What environment are you running pdf-lib in?
Browser
Checklist
Additional Notes
No response