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.

Sat Dec 03, 2011 4:09 pm

One More Question,

I have a RegX expression and I need to use it to replace a certain Text with a HyperLink.

Any Help on this Please ?

Regards,

moetarhini
 
Posts: 15
Joined: Tue Sep 27, 2011 6:49 pm

Mon Dec 05, 2011 3:20 am

Hello moetarhini,

Sorry for the inconvenience caused by us.

Spire.Doc regard <span style='font-family: "Times New Roman";'></span> as content of document. Spire.Doc just convert the content of the document to HTML.

If you want to keep the style in the html. You need to set the style of the text not use html tag.

Here is code. Please have a try.
Code: Select all
            Document document = new Document();
            document.LoadFromFile(@"..\..\Test.docx", FileFormat.Docx2010);
            Section section=document.Sections[0];

            ParagraphStyle myStyle = new ParagraphStyle(document);
            myStyle.Name = "myStyle";
            myStyle.CharacterFormat.FontName = "Times New Roman";
            document.Styles.Add(myStyle);

            for (int i = 0; i < section.Paragraphs.Count; i++)
            {
                section.Paragraphs[i].ApplyStyle(myStyle.Name);
            }


            document.SaveToFile(@"..\..\TestResult.docx", FileFormat.Docx);
            document.SaveToFile(@"..\..\TestResult.html", FileFormat.Html);
            System.Diagnostics.Process.Start(@"..\..\TestResult.html");


If you still have any other questions, please don't hesitate to contact us.

Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar

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

Mon Dec 05, 2011 6:04 am

Hello,

I have made a simple demo which may meet your requirement. Please try the following code:
Code: Select all
 Document document = new Document();
            document.LoadFromFile(@"..\..\Test.docx", FileFormat.Docx2010);

            Regex regex = new Regex(@"Spire.Office");
            TextSelection[] selections = document.FindAllPattern(regex);
            Section tempSection = document.AddSection();

            for (int i = selections.Length-1; i >=0; i--)
            {
                ITextRange txtRange = selections[i].GetAsOneRange();
                string txtVal = txtRange.Text;
                txtVal = txtVal.Replace(@"Spire.Office","http://www.e-iceblue.com");
                txtRange.Text = txtVal;           
          }
            document.Sections.Remove(tempSection);
            document.SaveToFile(@"..\..\TestResult.docx",FileFormat.Docx2010);
            System.Diagnostics.Process.Start(@"..\..\TestResult.docx");


If you still have any other questions, please don't hesitate to contact us.

Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar

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

Mon Dec 05, 2011 7:31 am

Tina.Lin wrote:Hello,

I have made a simple demo which may meet your requirement. Please try the following code:
Code: Select all
 Document document = new Document();
            document.LoadFromFile(@"..\..\Test.docx", FileFormat.Docx2010);

            Regex regex = new Regex(@"Spire.Office");
            TextSelection[] selections = document.FindAllPattern(regex);
            Section tempSection = document.AddSection();

            for (int i = selections.Length-1; i >=0; i--)
            {
                ITextRange txtRange = selections[i].GetAsOneRange();
                string txtVal = txtRange.Text;
                txtVal = txtVal.Replace(@"Spire.Office","http://www.e-iceblue.com");
                txtRange.Text = txtVal;           
          }
            document.Sections.Remove(tempSection);
            document.SaveToFile(@"..\..\TestResult.docx",FileFormat.Docx2010);
            System.Diagnostics.Process.Start(@"..\..\TestResult.docx");


If you still have any other questions, please don't hesitate to contact us.

Have a nice day.


Thank you for your Reply. I have one small question, we want to replace the Text with a Hyper Link that has Text and URL Link. How can we do this ?

moetarhini
 
Posts: 15
Joined: Tue Sep 27, 2011 6:49 pm

Fri Dec 09, 2011 2:42 am

Hello moetarhini,

Sorry for late reply and thank you for your patience.

I am sorry for that Spire.Doc support add hyperlink( paragraph.AppendHyperlink("http://www.e-iceblue.com", "E-ICEBLUE", HyperlinkType.WebLink);) but not support replace text with hyperlink's name.

Sorry again for the inconvenience caused by us.

If you still have any other questions, please don't hesitate to contact us.
Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar

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

Tue Dec 20, 2011 10:00 am

Hello moetarhini,

Sorry for late reply and thank you for your patience.

We have added the new feature "RTL and LTR" in the Spire.Doc HotFix 4.1.15. You can download it from the following address:http://www.e-iceblue.com/Download/download-word-for-net-now.html, and have a try.

If you still have any other questions, please don't hesitate to contact us.

Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar

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

Tue Dec 20, 2011 10:06 am

Thank you for the Update.

We will try it today and let you know the result.

Thanks.

moetarhini
 
Posts: 15
Joined: Tue Sep 27, 2011 6:49 pm

Tue Dec 20, 2011 10:25 am

Dear Sir,

We just tried it and it did not work correctly on some of the files, I think it still have some bugs.

Please check the attached word sample and try to convert it to html on your side to see the results.

Regards,

moetarhini
 
Posts: 15
Joined: Tue Sep 27, 2011 6:49 pm

Wed Dec 21, 2011 9:15 am

Hello moetarhini,

Sorry for the inconvenience caused by us.

We are reseaching this issue. Once we have any other progress, we will inform you.

Sorry again.
Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar

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

Wed Dec 28, 2011 11:30 am

Hello Sir,

Any update on this and when can we have it ready ?

Best Regards,

moetarhini
 
Posts: 15
Joined: Tue Sep 27, 2011 6:49 pm

Fri Dec 30, 2011 2:38 am

Hello moetarhini,

Sorry for late reply.

We have released the Spire.Doc HotFix 4.1.16 which has fixed your problem. You can download it from the following address:http://www.e-iceblue.com/Download/download-word-for-net-now.html.

If you still have any other questions, please don't hesitate to contact us.
Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar

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

Fri Dec 30, 2011 2:37 pm

Hello Support,

We Tested the new Patch on the attached Document. We noticed something strange. The Footnotes are not showing in the Correct Places as in the Word Document.

Can you please check it.

Best Regards,

moetarhini
 
Posts: 15
Joined: Tue Sep 27, 2011 6:49 pm

Return to Spire.Doc