iulica / docx-mailmerge

Mail merge for Office Open XML (docx) files without the need for Microsoft Office Word.
MIT License
55 stars 7 forks source link

Add new content type footnotes+xml so mail merge fields are supported #16

Closed 402Martin closed 8 months ago

402Martin commented 8 months ago

Currently mail merged fields on footnotes are not getting replaced.

Expected Behavior

  1. Footnotes fields change to the correct value when the mailmerge is run.

Current Behavior

Currently mail merged fields on footnotes are not getting replaced.

Possible Solution

also attempting to just add "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" on CONTENT_TYPES_PARTS broke several tests

Steps to Reproduce (for bugs)

  1. try using mailmerge with the file attached to the issue
  2. see that on the body the mergefield is change but not on the footnote.

Your Environment

402Martin commented 8 months ago

I have been trying to implement this case but cant manage to solve the issues with the rest of the tests. @iulica could we add a label as enhancment/ feature to the issue?

iulica commented 8 months ago

I'll have to rework the main class for the cases where there is no section in the document.

iulica commented 8 months ago

I believe the same applies for headers and footers ?

402Martin commented 8 months ago

I just did a quick test and it looks like this issue also happens on footers and headers

I believe the same applies for headers and footers ?

iulica commented 8 months ago

I did a commit just now, adding the footnotes support and test for it. Currently, only document.merge() is supported, namely one document at a time, and not merge_templates() and variants. It should work for header/footer as well.

Please install directly from github and check if it works. When confirmed, I will release a new version.

402Martin commented 8 months ago

Tested it up with various docx files and seems to be working fine!

thanks @iulica !

iulica commented 8 months ago

Perfect, I will make a new release after adding some more features in the next couple of days.