I have a work around for these issues, but I'm interested to know if there is a fix for either.
After setting a Word Template and generating the Word file, my headers are automatically changed from 0" to 0.5". I can change the template's headers to 0.5" in advance, but that makes the content of my Word doc more crowded.
I cannot change text within a text box from Word_Export_SetText, so I have to remove the text boxes from my templates.
I am on v5.5
Thanks!
Simon Foster
Hi Simon, and sorry for the late reaction.
This is a very useful "catch". Thank you!
Contrary to the the "header top margin issue", this one can be fully addressed on the OfficeUtils side, without touching NPOI. So I will publishing a new version of OfficeUtils with the fix within the next couple of days.
Thanks again,
Bruno
Hi Simon,
I went to troubleshoot the header top margin issue, and concluded that between the template import and the document export NPOI (OfficeUtils underlying library) is loosing the margin setting. As a result, when one opens the exported document it applies the default top margin (0.5 inches). The only possibility to fix this is inside NPOIs implementation, and I will be assessing if I can do so.
Replacing text inside text boxes is expected to work, and it is even part of the "Set Text" example of "OfficeUtils Demo". Clearly there is something in your template I'm not accounting for, so it would be great if you could share the template for me to inspect it. Is it possible? You can of course anonymize it and remove most of the content. One "problematic" text box is all I need.
Best,
Hi Bruno,
Thank you so much for taking a look at these issues. I've attached a file with everything removed except for two textboxes.
A couple of updates:
Hope this information helps.
Thanks again for your help on these.
Updates from me:
Header top margin: This worked!
Replace text inside textboxes: I did some more testing and the error comes from entering a null value into a text box. Entering a null value works outside of a text box, but inside this throws a null value error.
The workaround I applied is to add logic that enters chr(160) as a replacement for a null value. Similar to the header issue, there is "something there" and the text replace works.
Thanks again!