pdf-lib icon indicating copy to clipboard operation
pdf-lib copied to clipboard

Merging pdf does not retain source pdf formatting

Open kimlambiguit opened this issue 6 years ago • 4 comments

Hello @Hopding,

First of all, awesome tool. the best, free library so far.

Anyway, I have an issue that I've been trying to resolve. I'm currently merging multiple pdfs using the example in your README. However, the merged pdf does not retain the original formatting of the source PDF. Is this an expected behavior? Since I've read from one of your comments here that copying pdf contents does not copy other underlying data (e.g. links ). Does this perhaps include the formatting as well? If so, can you suggest any workaround?

Thanks!!!

kimlambiguit avatar Jul 07 '20 14:07 kimlambiguit

Hello @kimlambiguit!

Can you share some sample PDFs and screenshots?

Hopding avatar Jul 07 '20 15:07 Hopding

Hi @Hopding

Forgot to mention this are Acrofields. So basically what happens is I have a bunch of PDFs with acrofields that are filled and saved. The saved PDFs are then merged. Below is a sample page.

Original, non merged PDF original

Merged. merged

Please ignore the blacked out portion. Just covering some company details :)

Thank you for taking notice and good day.

kimlambiguit avatar Jul 07 '20 15:07 kimlambiguit

Hello @Hopding. is there additional information that you need to help formulate a root cause or a workaround?

kimlambiguit avatar Jul 08 '20 08:07 kimlambiguit

@kimlambiguit pdf-lib doesn't currently copy AcroForms when copying or embedding pages. See https://github.com/Hopding/pdf-lib/issues/417#issuecomment-620900368. One thing you could try is "flattening" the form fields before using pdf-lib to load the documents. This would remove the form fields themselves while preserving their filled values. (Note, however, that you'll have to find a different tool to do the flattening. pdf-lib does not have APIs for that).

Hopding avatar Jul 10 '20 22:07 Hopding