How to keep leading spaces in merge fields (MS Word)

311 views Asked by At

I have problem with merge field in word document , i created merge field like this:

{ MERGEFIELD string_data }

I try to add some text to the merge field with leading space, example: " Test String" after I added the value to merge field the result is "Test String" the merge field eliminating the leading space,

I'm used python to fill the merge field:

from mailmerge import MailMerge
def main():
   temp = "string.docx"
   str_data = "  Test String"
   doc = MailMerge(temp)
   doc.merge(string_data=str_data)
   file_name = "out_string.docx"
   doc.write(file_name)

is there a way to keep leading space in merge field ?

Thanks

0

There are 0 answers