Free Support Forum - groupdocs.com

Convert Docx to html and render it on webform

Hi We are trying to upgrade groupdoc to its latest version and facing following issue:

I am trying to render word file to our UI as HTML.I did docx to html conversion using htmlsaveoption by following code:

HtmlOptions htmlOptions = new HtmlOptions();

htmlOptions.IsResourcesEmbedded = true;

List pages = htmlHandler.GetPages(filename, htmlOptions);



but I am getting exception “Void Aspose.Words.Fonts.Font Settings.set_Default FontName(System.String)”



I tried adding Aspose.Words and applied font settings but still getting that exception. Also converted html pages has empty content because of this exception.



On UI side I have added all JS libraries, CSS files and following method to render the document on UI:



$(function () {

var viewerSyle = {

ScrollView: 1,

DoublePageFlip: 2,

OnePageInRow: 3,

TwoPagesInRow: 4,

CoverThenTwoPagesInRow: 5

};



$(’#documentViewer’).groupdocsViewer({

//filePath: ‘http://groupdocs.com/images/banner/carousel2/signature.png’,

filePath: ‘word.doc’,

zoomToFitWidth: true,

//zoomToFitHeight: true,

showFolderBrowser: true,

showHeader: true,

showPaging: true,

showThumbnails: true,

showZoom: true,

width: 650,

height: 900,

isResourcesEmbedded: true,

useHtmlBasedEngine: true,

showDownload: true,

downloadPdfFile: true,

showPrint: true,

preloadPagesCount: 1,

usePdfPrinting: true,

showDocumentNavigation: true,

//supportPageRotation: true



});

EnableRightClickMenu = false;

$(’#documentViewer’)[0].oncontextmenu = function () { return EnableRightClickMenu; };

});



I am getting all groupdocs control on screen but document is not getting loaded.



Please provide me a possible solution for this

Hi there,


Thanks for using GroupDocs.Viewer for .NET.

First of all, please note that GroupDocs.Viewer for .NET uses Aspose.Words internally and you do not need to add it separately in your project. Furthermore, to investigate your reported issue, we will require following details from your side.

  • Version of GroupDocs.Viewer API you are using.
  • Are you using <a rel=“nofollow” href=“https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/tree/master/Showcases/ASP.NET_WebForm_Front_End” class=“js-navigation-open” id=“3b1c9237c5322dddadcbaffe9171d725-c3928a6374e531544af6dfc83173dafe44ef67d0” title=“ASP.NET_WebForm_Front_End” style=“box-sizing: border-box; color: rgb(64, 120, 192); text-decoration: none; font-family: -apple-system, BlinkMacSystemFont, “Segoe UI”, Roboto, Helvetica, Arial, sans-serif, “Apple Color Emoji”, “Segoe UI Emoji”, “Segoe UI Symbol”; font-size: 14px; line-height: 20px; white-space: nowrap; background-color: rgb(255, 255, 255);”>ASP.NET_WebForm_Front_End or you have configured your own application?
  • Please provide problematic Word document.

We shall be waiting for your response.

Warm Regards

1:Using GroupDocs.Viewer 3.5.

2:Configuring my own application

3:I am using word.doc given under example project ASP.NET_WebForm_Front_End for testing purpose.





Here is the code which I am using :

string filename = “word.doc”;

FontSettings font = new FontSettings();

font.SetFontsFolder(Server.MapPath("~/css/fonts"),false);

font.DefaultFontName = “Arial Unicode MS”;

HtmlOptions htmlOptions = new HtmlOptions();

htmlOptions.IsResourcesEmbedded = true;

List pages = htmlHandler.GetPages(filename, htmlOptions);



foreach (PageHtml page in pages)

{

//Save each page at disk

SaveAsHtml(page.PageNumber + “_” + filename, page.HtmlContent);

}

Using fontsetting to resolve exception but not working.



If you have any other simple solution to load docx file on web form that complete part will also help. Please provide front end .aspx code also in this case.



Thanks.

Hi there,


Thanks for providing us the required details.

I have checked your reported exception but the document is rendering without any issue. The document is rendered into html pages and I am also able to load it in our sample WebForms front end application without using font settings. Therefore, I suggest you to download and try our open source <a rel=“nofollow” href=“https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/tree/master/Showcases/ASP.NET_WebForm_Front_End” class=“js-navigation-open” id=“3b1c9237c5322dddadcbaffe9171d725-c3928a6374e531544af6dfc83173dafe44ef67d0” title=“ASP.NET_WebForm_Front_End” style=“box-sizing: border-box; color: rgb(64, 120, 192); text-decoration: none; font-family: -apple-system, BlinkMacSystemFont, “Segoe UI”, Roboto, Helvetica, Arial, sans-serif, “Apple Color Emoji”, “Segoe UI Emoji”, “Segoe UI Symbol”; font-size: 14px; line-height: 20px; white-space: nowrap; background-color: rgb(255, 255, 255);”>ASP.NET_WebForm_Front_End application. This sample application will surely help you to understand the the implementation of a document viewer in web forms. Furthermore, as this application is open source, you can also modify it according to your requirements.

In case of any confusion, please feel free to ask.

Warm Regards