Spire.Doc splits text into several text ranges

Technical support for Spire.Doc

Moderator: iceblue support

Spire.Doc splits text into several text ranges

Postby binatest » Mon Sep 12, 2011 8:58 am

Hello,

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 4.0.10.4.
You do not have the required permissions to view the files attached to this post.
binatest
 
Posts: 1
Joined: Thu Aug 25, 2011 2:56 pm

Re: Spire.Doc splits text into several text ranges

Postby Tina.Lin » Wed Sep 14, 2011 5:48 am

Hi,
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();
document.LoadFromFile(@"..\..\example.doc");

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(textRange.Text);
}

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

Console.ReadKey();

//Launching the MS Word file.
System.Diagnostics.Process.Start("test.doc");

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
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar
Tina.Lin
 
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am


Return to Spire.Doc

Who is online

Users browsing this forum: No registered users and 0 guests