raffaem / pdfsak

Utility to manipulate PDF files.
MIT License
43 stars 8 forks source link

Merge PDFs with Form Field LOST! #10

Open mgip opened 2 years ago

mgip commented 2 years ago

I try to merge 2 pdf, one of them has a few form field filled allready, but, when i merged in the output file the fields do not show.

raffaem commented 2 years ago

Hi,

Thanks for the issue.

PDFsak uses latex's pdfpages package for merging, which treats PDFs as images and ignore forms as well as comments (source 1, source 2).

The easiest way for your use cases is probably to use qpdf. To merge a.pdf with b.pdf into c.pdf you can run:

qpdf --empty --pages a.pdf b.pdf -- c.pdf

and forms will be preserved.

In alternative, to use PDFsak we would need to first "flatten" the PDF, that is, convert it into an image, and then merging. This would be achieved with something like:

magick convert -density 300 a.pdf a2.pdf
pdfsak -if a2.pdf -if b.pdf -o c.pdf

we could implement that in PDFsak, however the form will not be editable anymore in the final document.