rkusa / pdfjs

A Portable Document Format (PDF) generation library targeting both the server- and client-side.
MIT License
775 stars 142 forks source link

PDF with XFA forms #104

Open andrewttran opened 6 years ago

andrewttran commented 6 years ago

Hello!

I noticed when trying to use pdfjs to add pages from PDFs that contain XFA forms that when the outputted PDFs are viewed in various viewers the text either isn't displayed or is displayed without any of the original fonts/styles. I've attached an example here. Are there any fixes/workarounds for this?

Thanks!

input.pdf output.pdf

rkusa commented 6 years ago

Thanks for reporting this issue. I'll have a look

rkusa commented 6 years ago

When adding an existing PDF document, the current implementation only adds the plain page-contents. However, AcroForms are set at document-level (Catalog dictionary). So, the current implementation has to be extended to take document-level properties into account. The main challenge here is to merge AcroForms when adding pages from multiple existing PDF documents.

Since this is not a quick implementation, it could take a while. In the meantime, the only workaround is to print the input.pdf as PDF and use this printed PDF as an input for pdfjs. This works, because it should remove the form elements. Though, I guess loosing the form elements is not what you are aiming for.