Aspose.Words: Print email address

Hello,

I try to print email address in RTL document.

Aspose.Words.DocumentBuilder builder = new DocumentBuilder(AsposeDocument);
builder.MoveToMergeField(FieldName);
builder.Write("aaaaa@bbb.co.il"); //its printed in wrong direction : il.co.bbb@aaaaa

How can I solve this problem?

Best regards,

ladpc

Hello

Thanks for your request. Could you please provide me more information? Do you print your document on a paper, or just write the line and save as DOC? Also could you please attach you input and output documents here for testing? I will check them and provide some feedback.

Best regards,

Hello,

I want write the line and save as Doc.

Here is the code and files “Before” and “After”:

Aspose.Words.Document AsposeDocument = new Aspose.Words.Document("D:\\before.doc");
Aspose.Words.DocumentBuilder builder = new DocumentBuilder(AsposeDocument);
builder.MoveToMergeField("eMail");
builder.Write("aaaaa@bbb.co.il");
AsposeDocument.Save("D:\\after.doc");

Thanks,

ladpc

Hello

Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words (9.4.0). Could you please try using the latest version and let me know how it goes on your side.

You can download the latest version from here:

https://downloads.aspose.com/words/net

Best regards,

Hello.

Thanks for the replay.

I tried the latest version. It really solved the problem of mail, but now we have new.

  1. It prints the words in reverse order.
    If I use a table then it prints correctly, but if a sentence contains numbers then it prints not correctly too.

  2. In the old version if the document contains several identical tags, it changed everything and now only the first.

Here is the code and files “Before” and “After”:

System.Xml.XmlDocument DocumentKeyXml = new System.Xml.XmlDocument();
DocumentKeyXml.Load("D:\\Test.xml");
System.Xml.XmlNode node = null;
string sTemp;
Aspose.Words.Document AsposeDocument = new Aspose.Words.Document("D:\\before.doc");
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(AsposeDocument);
node = DocumentKeyXml.SelectSingleNode("//Address1");
sTemp = node.InnerText.Trim();
builder.MoveToMergeField("Address1");
builder.Write(sTemp);
builder.MoveToMergeField("AddressT1");
builder.Write(sTemp);
node = DocumentKeyXml.SelectSingleNode("//Address2");
sTemp = node.InnerText.Trim();
builder.MoveToMergeField("Address2");
builder.Write(sTemp);
builder.MoveToMergeField("AddressT2");
builder.Write(sTemp);
node = DocumentKeyXml.SelectSingleNode("//Address3");
sTemp = node.InnerText.Trim();
builder.MoveToMergeField("Address3");
builder.Write(sTemp);
builder.MoveToMergeField("AddressT3");
builder.Write(sTemp);
sTemp = "aaaaa@bbb.co.il";
builder.MoveToMergeField("eMail");
builder.Write(sTemp);
builder.MoveToMergeField("eMailT");
builder.Write(sTemp);
AsposeDocument.Save("D:\\after.doc");

Hello

Thanks for your request. I think in this case, you should try using the code like the following:

XmlDocument DocumentKeyXml = new System.Xml.XmlDocument();
DocumentKeyXml.Load("Test.xml");
Document doc = new Document("before.doc");
string address1 = DocumentKeyXml.SelectSingleNode("//Address1").InnerText.Trim();
string address2 = DocumentKeyXml.SelectSingleNode("//Address2").InnerText.Trim();
string address3 = DocumentKeyXml.SelectSingleNode("//Address3").InnerText.Trim();
doc.MailMerge.Execute(new string[] { "Address1", "AddressT1", "Address2", "AddressT2", "Address3", "AddressT3", "eMail", "eMailT" },
new string[] { address1, address1, address2, address2, address3, address3, "aaaaa@bbb.co.il", "aaaaa@bbb.co.il" });
doc.Save("after.doc");

I use this code and the output document looks as expected on my side.

Best regards,

Hello,

Thanks for the reply.

This code actually works. And all printed correctly except the email address.

Thanks,

ladpc

Hello

Thanks for your request. This problem occurs because the “Direction” of the paragraph is “Right-To-Left”. Actually it is not a problem it is normal behavior. Please see the attached screenshot. As a workaround you can try modifying your template.

Please let me know in case of any issues. I will be glad to help you.

Best regards,

Hello

Thanks for the reply.

In this case, it changes the direction of the line.
Solution: add email address to textbox.

ladpc

Hello

It is perfect, that you already found the solution. If you need more assistance, I will be glad to help you.

Best regards,

Hello,

Date printed incorrectly, too.

string Date1 = "17/02/2011";
AsposeDocument.MailMerge.Execute(new string[] { "Date1"}, new string[] { Date1 });

ladpc

Hello

Thanks for your request. I cannot reproduce the problem on my side. Please try using the following code:

Document doc = new Document("before.doc");
XmlDocument DocumentKeyXml = new System.Xml.XmlDocument();
DocumentKeyXml.Load("Test.xml");
string address1 = DocumentKeyXml.SelectSingleNode("//Address1").InnerText.Trim();
string address2 = DocumentKeyXml.SelectSingleNode("//Address2").InnerText.Trim();
string address3 = DocumentKeyXml.SelectSingleNode("//Address3").InnerText.Trim();
doc.MailMerge.Execute(new string[] { "Address1", "Address2", "Address3", "eMail", "MyDate" },
new string[] { address1, address2, address3, "aaaaa@bbb.co.il", "17/02/2011" });
doc.Save("after.doc");

Also please see the attached input and output documents.

Best regards,

Hello

Thanks for the reply.

Here is the code and files “Before” and “After”:

AsposeDocument.MailMerge.Execute(new string[] { "Address1", "Address2", "Address3", "eMail", "MyDate", "MyTime" },
new string[] { address1, address2, address3, "aaaaa@bbb.co.il", "17/02/2011", "17:05" });

ladpc

Hello

Thank you for additional information. This problem occurs by the same reason as I mentioned you earlier (about Right-to-left). You should change your template, for example you can try using table (please see the attachment from my previous post). You can modify your template the same way.

Best regards,

Hello,

Thanks for the reply.

I saw your example.
Because the previous version it worked correctly, there are many templates in use of our clients that can not be changed. Therefore, we need another solution.

Best regards,

ladpc

Hello

Thank you for additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.

Best regards,

Hello.

I have a Word document that contains the textbox. (Attached)
When I try to open this document I get an error message:
"Unknown complex shape property id:937 with data. For free technical support, please post this error and the file in the Aspose.Words Forums."

try
{
    AsposeDocument = new Aspose.Words.Document("D:\\TestShape.doc");
}
catch (Exception err)
{
    MessageBox.Show(err.Message);
}

I use version 4.2.1.
I can not use the latest version because I get the old problem (see previous posts).

What should I do?

ladpc

Hello

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words 10.3.0. Please try using the latest version of Aspose.Words and let me know how it goes on your side.

You can download the latest version from here:

https://downloads.aspose.com/words/net

Also, you should note, all fixes and new features are added to new versions of Aspose.Words. So there is no way to get fix of the problem without update to the latest version.

Best regards,

Hello

I checked the latest version. This problem it is solved,but previous problem because of which I can not use this version remained. So what can I do now?

ladpc

Hello

Thank you for additional information. Currently I cannot suggest you any way to work the problem around. You should just wait for the fix of the original issue. We will keep you informed on any developments regarding this issue.

Best regards,