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 14, 2015 4:00 pm

I am trying to insert addresses into a template letter using the Replace function to replace some placeholder text.
I need to keep the address together using soft line breaks, so that it best fits the space allowed. The replacement text is provided by a database and is in plain text. I have no control over the final formatting of the document, I can only replace the placeholder texts.

One solution would be to force our users to have one placeholder per line of the address, but this may leave blank lines where an address field is not present, which is undesirable.

I have tried sending just a line feed (LF) character, just a carriage return (CR) character, and a combination CRLF but they all result in new paragraphs.

Can you give me any advice on how to achieve this.


Kind Regards
Darren

dazfitzg
 
Posts: 5
Joined: Thu Jun 25, 2015 3:28 pm

Tue Sep 15, 2015 7:14 am

Hello,

Thanks for your inquiry.
Please try to use the character "\v" in your replacement text.
Here is the sample code for your reference.
Code: Select all
 Document doc = new Document();
  doc.LoadFromFile(@"..\..\test5813.docx");   
  string x = "address1 \v address2 \v address3";
  doc.Replace("change", x, false, true);
  doc.SaveToFile("..\\..\\5813.docx");


Best Regards,
Sweety
E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Thu Sep 17, 2015 3:08 am

Hello,

Have you tried the code?
Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Sweety
E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Fri Sep 21, 2018 11:17 am

Hi

I have the same problem.

When i have a "\v" in the replace value, it results in an underscore "_" instead of a soft line break.

Code: Select all
var pattern = new Regex($@"\<%{placeholder}%\>");
_document.ReplaceInLine(pattern, "hello \v world);


Results in "hello _ world"

Best regards, nicolas.

BSD
 
Posts: 13
Joined: Wed Feb 04, 2015 3:42 pm

Mon Sep 24, 2018 1:58 am

Dear nicolas,

Thanks for your inquiry and sorry for late reply as weekend.
After an initial test with our latest Spire.Doc Pack(hot fix) Version:6.8.16, I didn't reproduce the underscore "_" issue you faced. To help us further investigate your issue, please provide your Word document. You could send it to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Tue Sep 25, 2018 6:32 am

Dear Nicolas,

Thank you for sharing requested information.
I have noticed the “\v” was written as the underscore "_" after saving to rtf file, and forwarded the issue to our dev team for further analyses. If there is any update, I will let you know. BTW, if you save to docx file after doing replacement, the “\v” will be written correctly.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Sun Sep 30, 2018 2:56 am

Hello,

Glad to inform you that the reported issue has been fixed. Welcome to download the hotfix from the following link.
Spire.Doc Pack(hot fix) Version:6.9.13

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Tue Oct 09, 2018 9:42 am

Hi,

Greetings from E-iceblue.
Has your issue been resolved with the hotfix?
Thanks in advance for your valuable feedback and time.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.Doc

cron