How to save a paragraph with images to html

Hi everybody,
I need to save a paragraph with image to html string so I can put it into database. The image is needed to save on a directory on server the the image source needs to be updated to that image
The sample document is attached below. The paragragh which I want to save it highlight with yellow.
Many thanks

Hi Nguyen,

Thanks for your inquiry. Please try using the following code:

Document doc = new Document(MyDir + @"test.docx");
Paragraph para = doc.FirstSection.Body.FirstParagraph;
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html);
options.ExportImagesAsBase64 = true;
string html = para.ToString(options);

Hope, this helps.

Best regards,

Dear awais.hafeez,
Thank you for your quick reply.
Based on your instruction, the html result demonstrated as below.
The result has some problems which I need your help to solve:

  1. The result is same as mine althoug I do not use these:
    HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html);
    options.ExportImagesAsBase64 = true;
    my code is: string html = para.ToString(SaveFormat.Html)
  2. I highlight the img tag in the html result. As you can see, src point to encrypted data of image which can not display on a web page. I need the src point to a location where the image on my document is saved in order to display the image on web page.
"
Trong PowerPoint 2013, nút lệnh **<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAWBAMAAADDZPq4AAAAAXNSR0ICQMB9xQAAADBQTFRFAAAA/////584//fnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEXHcIQAAAAlwSFlzAAAOxgAADsQB2OOvEAAAADVJREFUKM9jUEIGCgyUcgXBQAgHVxFGQLmKQEkkLposXq4yyGBhZGcIoboKLxfsJmr4F8EFAOVNJt+CqhWsAAAAAElFTkSuQmCC\"** width=\"27\" height=\"22\" alt=\"\" style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" /> tương ứng với thao tác nhấn phím (tổ hợp phím) nào?
" string

Hi Nguyen,

Thanks for your inquiry. You can simply import target Paragraph in new empty document and convert it to Html as follows:

Document doc = new Document(MyDir + @"test.docx"); 
Paragraph para = doc.FirstSection.Body.FirstParagraph;
Document tempDoc = (Document)doc.Clone();
tempDoc.FirstSection.Body.RemoveAllChildren();
tempDoc.FirstSection.Body.AppendChild(tempDoc.ImportNode(para, true, ImportFormatMode.UseDestinationStyles));
tempDoc.Save(MyDir + @"16.3.0.html");

Hope, this helps.

Best regards,