I have a problem when merging word docs. If the template has text boxes or images, then the merging changes where they are placed. The text from text boxes is simply written on the page (left align) and images are also left aligned, regardless of their original position.
I am using the evaluation version of Aspose.Words while developing, can this be the reason? I was unable to find a list of diffenrences between the evaluation version and the full version, is there anything like that around here?
Hi
Evaluation version of Aspose.Words (without a license specified) provides full product functionality, but it injects an evaluation watermark at the top of the document on open and save and limits the maximum document size to several hundred paragraphs.
Please attach your source documents and document with problem. Then I will try to reproduce and solve this problem.
Best
Hi
Thanks for additional information. I have tried to generate a document from your template using MailMerge and it seems that all works fine. Please provide me the code that you use to generate document.
Also try to update your Aspose.Words component to latest version. The latest version is available at: https://releases.aspose.com/words/net
Best regards.
Thanks for your reply. Over the weekend I found a bug in my code that created this fault. So the problem has been solved for this document. However, I have another problem that I first thought was related. Please see the documents attached. The merging seems to be going fine, but the text boxes are placed all wrong in Word. Is this something that can be fixed or should I just try to avoid text boxes?
I merge to HTML because I sometimes need to send the content directly in an E-mail, can this have something to do with the issue? Also, there are images on the page which also gets the left-allinement that they shouldn’t have. These have been removed for privacy issues.
Hi
Thanks for your request. I have tried to execute mail merge using your template and it seem that all works fine on my side. See the attachment. I have used the following code to execute mail merge.
Thank you for your reply. I’m happy to see that the setup of the template isn’t the problem. I have, however, at bit of a problem, since I do not have the template placed on the server, as your code suggests. The document template I use is placed as an annotation i Microsoft CRM 3.0. So the code I use for merging is this:
// Get file
string server = ConfigurationManager.GetCRMUrl();
byte[] rawdata = GetAttachment(ann.annotationid.Value, server);
_entityGuid = entityguid;
// Convert data to a memorystream and merge it with data from a stored procedure
MemoryStream memStream = new MemoryStream(rawdata);
Document doc = new Document(memStream);
DataSet data = GetDataSet(entityguid, storedProcedure);
if (data != null)
{
doc.MailMerge.MergeField += new MergeFieldEventHandler(InsertSpecialFields);
doc.MailMerge.ExecuteWithRegions(data);
}
I hope it is readable.Can the use of a MemoryStream be the problem?
The InsertSpecialFields is a simple method that swaps the texts in the fields: