We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Convert doc to HTML

Thread ID:

Created:

Updated:

Platform:

Replies:

120638 Sep 29,2015 02:15 PM Oct 1,2015 04:17 AM ASP.NET Web Forms 3
loading
Tags: DocIO
Gary Rumble
Asked On September 29, 2015 02:15 PM

Is it possible to get DocIO to save to HTML as one file per page?

The default is one HTML file for the entire document.



Sathish K [Syncfusion]
Replied On September 30, 2015 01:56 AM

Hi Gary,

Thank you for contacting Syncfusion support.

If your requirement is to save each and every pages of the Word document as separate HTML file, then kindly keep each and every pages as separate sections in the Word document and iterate each sections from the Word document then save them as separate HTML files using the below code example.

Code example:
//Opens the source document

WordDocument sourceDocument = new WordDocument(@"File location");

int i = 1;

//Iterates the sections

foreach (WSection section in sourceDocument.Sections)

{              

//Instatiating the new WordDocument object

WordDocument htmlDocument = new WordDocument();

//Add the current section to the new Word document

htmlDocument.Sections.Add(section.Clone());

//Saves the document.

htmlDocument.Save("DocIOHTML" + i.ToString() + ".html", FormatType.Html);

//Closing WordDocument instance

htmlDocument.Close();

i++;

}

//Closing source document instance
sourceDocument.Close();

Regards,
Sathish


Gary Rumble
Replied On September 30, 2015 11:42 AM

Unfortunately, I don't have any control over the doc file, it's provided by someone else.

Currently, it looks like the file has one section, but multiple pages, so the code below doesn't work.

I can use the render as images to get individual pages, but save to HTML just gives me one file.


Divyalakshmi Vasudevan [Syncfusion]
Replied On October 1, 2015 04:17 AM

Hi Gary,

Thank you for your update.


The Word document is a flow document in which contents will not be preserved page by page; instead the contents will be preserved sequentially section by section. Each section may extend to various pages based on its contents like table, text, images etc. Word viewer/editor renders the contents of the Word document page by page dynamically when opened for viewing or editing and these page wise rendered information will not be preserved in the document level as per the Word file format specification. Whereas Essential DocIO is a non UI component that provides a full-fledged document object model to manipulate the Word document contents. Hence currently it is not feasible to meet your requirement.


Please let us know in case of any other questions.

Regards,
Divyalakshmi V


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;