How to insert value with leading and trailing whitespaces into a Word merge field in Python docx-mailmerge

101 views Asked by At

I'm trying to insert a string value that contains leading and trailing whitespaces into a Word document's merge fields using Python docx-mailmerge.

However everytime I do this, the value in the Word file seems to delete that whitespaces.

str_value = "    Hello I'm         John Doe  "

The result I'm trying to achieve in the Word document:

Phrase: "    Hello I'm         John Doe  "

The result I got after using doc.merge(phrase=str_value):

Phrase: "Hello I'm         John Doe"

Is there any way I can make docx-mailmerge to not remove those leading and trailing whitespaces?

0

There are 0 answers