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.

Fri Jul 17, 2020 8:52 am

Hi,
I using already Spire.Doc to convert from Doc to PDF and works very well. But now i need to make one conversion from HTML string to RTF string. Can you do this with Spire.Doc , and if i can please give me instructions
Thanks!

Dzenan

nilex.developer
 
Posts: 6
Joined: Thu May 07, 2020 10:18 am

Fri Jul 17, 2020 9:43 am

Hello Dzenan,

Thanks for your inquiry.
You can use the "Paragraph.AppendHTML()" method to add html string to paragraph, and then save the file in RTF format. Below is the sample code for your reference. If there is any question, please feel free to write back.
Code: Select all
    String HTML = "<H1>Spire.Doc for .NET</H1>";

    //Create a new document
    Document document = new Document();

    //Add a section
    Section sec = document.AddSection();

    //Add a paragraph and append html string
    sec.AddParagraph().AppendHTML(HTML);

    //Save to RTF file
    document.SaveToFile("Result.rtf", FileFormat.Rtf);

    //Get the rtf string
    string rtf = File.ReadAllText("Result.rtf");


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Jul 17, 2020 10:48 am

Hi,
Thanks, i tried and i can see one issue. If i have inside in HTML <img src="https://..."/> is not showing images, and also html is not converted correctly, do you have any tips for this ?
Regards
Dzenan

nilex.developer
 
Posts: 6
Joined: Thu May 07, 2020 10:18 am

Fri Jul 17, 2020 11:37 am

Hello,

Thanks for your prompt response.
Please make sure your computer can access the online image. I tested the following code with the latest Spire.Doc Pack(hot fix) Version:8.7.5 but found the the image displays as expected, attached is my output file. To help us investigate further, please provide us with your HTML string.
Code: Select all
    String HTML = "<img src='https://www.e-iceblue.com/images/Intro/intro_office.png'/>";
    //Create a new document
    Document document = new Document();

    //Add a section
    Section sec = document.AddSection();

    //Add a paragraph and append html string
    sec.AddParagraph().AppendHTML(HTML);

    //Save to RTF file
    document.SaveToFile("Result.rtf", Spire.Doc.FileFormat.Rtf);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Jul 17, 2020 12:00 pm

Hi,
I have latest 8.7.5.0 version installed via nuget.
Can you test on your environment with this html ?

Thanks
Dzenan

nilex.developer
 
Posts: 6
Joined: Thu May 07, 2020 10:18 am

Mon Jul 20, 2020 6:52 am

Hello,

Thanks for your sharing.
I tested the code below to append your html string to paragraph but got the "XmlException" error. Have you encountered the same issue? If not, please provide your test environment information for further investigation, such as your OS information (E.g. Windows 7, 64 bit) and region setting (E.g. China, Chinese).
Code: Select all
            String HTML = File.ReadAllText("oneStringHtml.txt");
            Document document = new Document();
            Section sec = document.AddSection();
            sec.AddParagraph().AppendHTML(HTML);
            document.SaveToFile("Result.rtf", Spire.Doc.FileFormat.Rtf);

Anyway, the "XmlException" issue has been posted to our Dev team with the ticket SPIREDOC-4820 for further investigation. If there is any update, we will inform you.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Mon Aug 17, 2020 11:01 am

Hello,

Hope you are doing well.
The issue of ticket SPIREDOC-4820 is now been resolved. Welcome to download the newly released Spire.Doc Pack(hot fix) Version:8.8.2 from the following links.
Our website: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget: https://www.nuget.org/packages/Spire.Doc/8.8.2

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Aug 21, 2020 8:10 am

Hello,

Greetings from E-iceblue!
Could you please let us know how is your issue going? Thanks in advance for your feedback.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Sep 08, 2020 8:21 am

Hi,
Works ok!
Thanks!

Dzenan

nilex.developer
 
Posts: 6
Joined: Thu May 07, 2020 10:18 am

Tue Sep 08, 2020 9:12 am

Hello,

Glad to hear that!
Feel free to contact us if you have further questions.
Wish you all the best!

Sincerely,
Rachel
E-iceblue support team.
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc