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 May 15, 2023 9:54 am
Hello,
I have *.docx with some images. I would like to save the document content as HTML. Then to use the resulting HTML as a body of email. Currently I use the following code:
- Code: Select all
using (var doc = new Spire.Doc.Document())
{
doc.LoadFromFile(file);
doc.SaveToFile(tempLocation, Spire.Doc.FileFormat.Html);
}
This produce a
x.html,
x_styles.css and
x_images folder with all the images.
Is is possible to save the doc as HTML but all images to be base64 encoded?
Regards
-

profiler007
-
- Posts: 73
- Joined: Wed Nov 13, 2019 11:32 am
Tue May 16, 2023 3:55 am
Hi,
Thanks for your inquiry.
Please see the following code for reference.
- Code: Select all
//Open a Word document.
Document document = new Document();
document.LoadFromFile(@"test.docx");
//Set whether the css styles are embeded or not.
document.HtmlExportOptions.CssStyleSheetType = CssStyleSheetType.Internal;
//Set whether the images are embeded or not.
document.HtmlExportOptions.ImageEmbedded = true;
//Set the option whether to export form fields as plain text or not.
document.HtmlExportOptions.IsTextInputFormFieldAsText = true;
//Save the document to a html file.
document.SaveToFile(@"Sample.html", FileFormat.Html);
Please do not hesitate to contact us if you have any further questions or concerns.
Best regards,
Triste
E-iceblue support team
-


Triste.Dai
-
- Posts: 1000
- Joined: Tue Nov 15, 2022 3:59 am
Tue May 16, 2023 7:59 am
Works fine, thanks!
-

profiler007
-
- Posts: 73
- Joined: Wed Nov 13, 2019 11:32 am
Tue May 16, 2023 8:15 am
Hi,
Thanks for you feedback.
Glad to hear that the code works for your issue. If you have any other questions related to our products, just feel free to contact us.
Have a nice day!
Best regards,
Triste
E-iceblue support team
-


Triste.Dai
-
- Posts: 1000
- Joined: Tue Nov 15, 2022 3:59 am