Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Mon Sep 12, 2011 8:58 am


We are evaluating Spire.Doc and found a strange issue that can be a real showstopper for us.

When processing what appears to be a single block of text in Word document, Spire represents it as several text ranges, for example, text
{{Customer.Postal address.Street and number}}
is split into "{{", "Customer", ".Postal address.Street and number}}" parts, while visually these parts have the same font, style etc.

It's really important to us, because we use document as a template based on which the resulting document will be generated, and splitting of placeholder strings prevents it to be done. Sometimes problem goes away if I just type in the required string from scratch, but we can't use this workaround because template is supplied by the end user and it's hard to tell them what's wrong. Is there a way to return those parts as a single text range?

I'm attaching an example document and project exhibiting this behavior. We use Spire.Doc version
You do not have the required permissions to view the files attached to this post.

Posts: 1
Joined: Thu Aug 25, 2011 2:56 pm

Wed Sep 14, 2011 5:48 am

Thank for evaluating our spire.Doc product
But Spire.Doc will not split the TextRange during loading the doc file. The code below will show you that:
Code: Select all
Document document = new Document();

Paragraph paragraph = document.Sections[0].AddParagraph();
paragraph.AppendText("{{Customer.Postal address.Street and number}}");

//Save doc file.
document.SaveToFile("test.doc", FileFormat.Doc);

//reload the new doc file
document = new Document("test.doc");

var allObjects = LoadObjectsTree(document);
foreach (var textRange in allObjects.OfType<ITextRange>())

Console.WriteLine(">>>Done. Press any key to continue.");


//Launching the MS Word file.

We think the TextRange is split by other tools like MS-Word.
If you want to replce the text {{Customer.Postal address.Street and number}} with other data, you can try MailMerge. Please check http://www.e-iceblue.com/Knowledgebase/ ... eport.html.
If you still have any questions, please contact us
Technical Support/Developer,
e-iceblue Support Team
User avatar

Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Return to Spire.Doc