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 Oct 18, 2019 8:25 am

Hi ,

I have project that i have read content control by tag name then convert its content to HTML including images and tables that has merged cells.
Does the Spire.Doc provide functionality to do this?

Thanks,
Sam

samgmail
 
Posts: 1
Joined: Thu Oct 17, 2019 2:28 pm

Fri Oct 18, 2019 10:30 am

Hi Sam,

Thanks for your inquiry.
There is no direct way to convert the content in content control to HTML. But you could get the content first and add it in a new document, then convert the document to HTML file.
Below code for your kind reference:
Code: Select all
             Document doc = new Document(FilePath + @"19264.docx");
           //create a new file for adding content of control
            Document NewDoc = new Document();
            Section sec = NewDoc.AddSection();
            foreach (Section section in doc.Sections)
            {
                foreach (Body body in section.ChildObjects)
                {
                    foreach (DocumentObject bodyObj in body.ChildObjects)
                    {
                        if (bodyObj is StructureDocumentTag)
                        {
                            IStructureDocument sdt = bodyObj as IStructureDocument;
                            //get the sdt by name
                            if (sdt.SDTProperties.Tag == "Textbox")
                            {
                                foreach (DocumentObject SObj in sdt.ChildObjects)
                                {
                                    //add the content
                                    sec.Body.ChildObjects.Add(SObj.Clone());
                                }
                            }
                        }
                    }
                }
            }
            NewDoc.SaveToFile("19264.html", FileFormat.Html);


If this doesn't meet your requirement, please provide your input document and tell us what is the tag name for further investigation.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Oct 29, 2019 6:20 am

Hi,

Greetings from E-iceblue.
Did the code I provided help you solve your issue? Has your issue been resolved?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc