We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem when saving to HTML

            In our software, our document previewer works by converting a document into an html file and displays it in a web browser inside of our app (this is so that we can handle all different types of document, i.e. msg, doc, xls, png etc….. in one way).

            We used to use Word itself, by automating it and getting it to open the word file and do a save as a html file.

            We have now changed that to use Aspose itself, to open and save the word file. i.e. so that it is much quicker.

            However we have hit an issue with Word documents which contain text in textboxes.

            In the old method the text in the textboxes could be selected in the web browser. However, with the new method they cannot be. So Aspose is not providing the same type of conversion as native word does.

            Further investigation has shown that Aspose converts textboxes in the word document into .png files on disk and the html file it produces references them. When using word to save the file as a html file, it embeds all of the textbox information into the html file.

            I have tried to play around with the save options with the aspose method, but to no avail.

@gregglinnell,

Thanks for your inquiry. HtmlSaveOptions.ExportTextBoxAsSvg property controls how textboxes represented by Shape are saved to HTML, MHTML or EPUB. Default value is false. When it is set to true, exports textboxes as inline <svg> elements. When false, exports as <img> elements.

var document = new Document(MyDir + "input.docx");
HtmlSaveOptions options = new HtmlSaveOptions();
options.ExportTextBoxAsSvg = true;
document.Save(MyDir + "output.html", options);

If you still face problem, please share your input and expected output documents. We will then provide you more information about your query.

I have tried that. Unfortunately it does not render correctly in the WebBrowser Control:

image.png (6.2 KB)

@gregglinnell,

Thanks for your inquiry. Could you please share simplified application (source code without compilation errors) that helps us to reproduce your problem on our end? We will investigate the issue and provide you more information about your query.

As I need to include the aspose dll in the solution it is too big (even when zipped) to upload to this forum.

Can you give me an email address to send it too.

Regards

@gregglinnell,

Thanks for your inquiry. Please remove Aspose.Words DLL from your application and share it here for testing. Please ZIP and attach it. Thanks for your cooperation.

AsposeProblem.zip (288.5 KB)

See attached example for reproduction.

I have included an example word document in there too.

@gregglinnell,

Thanks for sharing the detail. The output generated by Aspose.Words renders correctly in browser e.g. google chrome. However, it does not render correctly in WebBrowser control. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-15974. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@gregglinnell,

Thanks for your patience. The WebBrowser control renders HTML document in IE7 mode. You are exporting text boxes with HtmlSaveOptions.ExportTextBoxAsSvg=true, so they are written as SVG shapes, which are not supported in IE7 and are thus rendered as plain inline text in WebBrowser.

MS Word exports text boxes as VML shapes which are supported in IE7 (WebBrowser control). However, since VML is outdated and is no longer supported in modern browsers, Aspose.Words doesn’t save text boxes to VML, and we have no plans on implementing this feature.

A possible workaround is to export text boxes to SVG and change the version of the engine that WebBrowser uses from IE7 (default) to IE9 (that supports SVG), as described here:
Web Browser Control & Specifying the IE Version

Following code example shows how to save Word document to SVNG.

Document doc = new Document(MyDir + "TestDocument.docx");
doc.Save(MyDir + "output.svg", SaveFormat.Svg);