Losing Margins From a Word Template

I’m doing a mailmerge based on a word template (docx) and then saving as a word document. The problem I’m having is that the saved word document reverts to the standard 1in margin instead of keeping the margins created in the template. I’m using Aspose 10.2.0.0. The code I’m using is pretty straight forward,

Dim doc as New Aspose.Words.Document(wrdTmpl)
doc.MailMerge.Execute(afields, adata)

I took a look at the PageSetup.Margin as soon as it’s loaded an they’re all set to 72 right from the load.

Thanks,

Kevin

Hello
Thanks for your request. Could you please attach your input and output documents here for testing. I will check the issue and provide you more information.
Best regards,

Hey Andrey,

I may have jumped the gun on this one. The template that I thought had smaller margins looks like it had the normal 1" margins. I’ll delete this thread if you like and just watch and see how it goes.

Regards,

Kevin

Hi there,
Thanks for this additional information. Please feel free to ask if you have any queries, we are glad to help.
Thanks,

Upon further investigation, something does seem off. It works for some templates and not others. Here’s one where it doesn’t work. The Aspose_Input.docx is actually a dotx file but I had to rename it to upload it. You’ll see the template file has margins of 0.7" while for some reason the output file has margins of 1" and 1.25". As soon as I open the file New Aspose.Words.Document(wrdTmpl) and look at the margins I see that they’re changed. Any help you can provide is greatly appreciated.

Hello
Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words. It seems you are using an old version of Aspose.Words. The latest version of Aspose.Words is 10.4.0; you can download this version from here:
https://releases.aspose.com/words/net
Could you please try using the latest version of Aspose.Words and let me know how it goes on your side.
Best regards,

I was using version 10.2.0.0. But I did the upgrade anyway and still the same issue. My application is built using VS2008 on a .Net 3.5 framework.

I took everything out of the function except for loading the template (dotx) and saving it as a word document (docx) and the margins were still changed.
One of the libraries I import initially is Microsoft.Office.Interop that calls Word functions. This is the legacy code that I’m replacing with Aspose.

Hi
Thanks for your request. I still cannot reproduce the problem on my side using the latest version of Aspose.Words. I use the document from your previous post and the following code:

Document doc = new Document("Aspose_Input.dotx");
doc.Save("out.docx");

I have sent the document produced on my side to your e-mail.
Best regards,

Sorry about the delay in response. I’ve been busy sorting this out. What was happening was that the original word process that was being replaced as best as I could tell, would do some type of “fit to page” on the merged document. This would change margins and fonts from the established templates. Whereas ASPOSE was correctly translating the template exactly as designed by the user. It was leading to conflicting reports on which output was correct. We’re adjusting the templates as necessary, but are very happy with the results that Aspose is giving us.

Regards,

Kevin

Hi Kevin,
It is perfect, that it works for you. Please let me know in case of any issues, I will be glad to help you.
Best regards,