Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

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.

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

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

Thu Nov 21, 2019 4:44 pm

How can i keep list item number as serialize as original when i split a doc file by a delimiter

softcoder
 
Posts: 2
Joined: Thu Nov 21, 2019 4:31 pm

Fri Nov 22, 2019 2:58 am

Hi,

Thanks for your inquiry.
To help us investigate your issue accurately, please offer us the following information.
1. Your input Word file.
2. Your desired result file.
3. The delimiter value that you want to split by.

You could upload them here or send us(support@e-iceblue.com) via email.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Return to Spire.Doc