I am getting the error on this file
GroupdocsEditor.docx (471.2 KB)
The error is coming while trying to view the file.
the function is →
[HttpPost]
[Route("viewer/loadDocumentDescription")]
public HttpResponseMessage GetDocumentData(PostedDataEntity postedData)
{
try
{
LoadDocumentEntity loadDocumentEntity = GetDocumentPages(postedData, globalConfiguration.GetViewerConfiguration().GetPreloadPageCount() == 0);
// return document description
return this.Request.CreateResponse(HttpStatusCode.OK, loadDocumentEntity);
}
catch (PasswordRequiredException ex)
{
// set exception message
return this.Request.CreateResponse(HttpStatusCode.Forbidden, new Common.Resources.Resource().GenerateException(ex, postedData.password));
}
catch (Exception ex)
{
// set exception message
return this.Request.CreateResponse(HttpStatusCode.InternalServerError, new Common.Resources.Resource().GenerateException(ex, postedData.password));
}
}
private LoadDocumentEntity GetDocumentPages(PostedDataEntity postedData, bool loadAllPages)
{
// get/set parameters
string documentGuid = GetDocumentPath(postedData.guid); //postedData.guid;
string password = string.IsNullOrEmpty(postedData.password) ? null : postedData.password;
var fileFolderName = Path.GetFileName(documentGuid).Replace(".", "_");
string fileCacheSubFolder = Path.Combine(cachePath, fileFolderName);
if (!File.Exists(documentGuid))
{
throw new GroupDocsViewerException("File not found.");
}
IViewerCache cache = new FileViewerCache(cachePath, fileCacheSubFolder);
LoadDocumentEntity loadDocumentEntity;
var htmlMode = string.IsNullOrEmpty(postedData.IsHTMLMode) ? "false" : postedData.IsHTMLMode;
if (htmlMode != "false")
{
using (HtmlViewer htmlViewer = new HtmlViewer(documentGuid, cache, GetLoadOptions(password)))
{
loadDocumentEntity = GetLoadDocumentEntity(loadAllPages, documentGuid, fileCacheSubFolder, htmlViewer);
}
}
else
{
using (PngViewer pngViewer = new PngViewer(documentGuid, cache, GetLoadOptions(password)))
{
loadDocumentEntity = GetLoadDocumentEntity(loadAllPages, documentGuid, fileCacheSubFolder, pngViewer);
}
}
return loadDocumentEntity;
}
private static LoadDocumentEntity GetLoadDocumentEntity(bool loadAllPages, string documentGuid, string fileCacheSubFolder, ICustomViewer customViewer)
{
if (loadAllPages)
{
customViewer.CreateCache();
}
dynamic viewInfo = customViewer.GetViewer().GetViewInfo(ViewInfoOptions.ForHtmlView());
LoadDocumentEntity loadDocumentEntity = new LoadDocumentEntity();
if (!Directory.Exists(cachePath))
{
Directory.CreateDirectory(cachePath);
}
TryCreatePagesInfoXml(fileCacheSubFolder, viewInfo, out string pagesInfoPath);
foreach (Page page in viewInfo.Pages)
{
PageDescriptionEntity pageData = GetPageInfo(page, pagesInfoPath);
if (loadAllPages)
{
pageData.SetData(GetPageContent(page.Number, documentGuid, cachePath, "N"));
}
loadDocumentEntity.SetPages(pageData);
}
loadDocumentEntity.SetGuid(documentGuid);
return loadDocumentEntity;
}
on this line → dynamic viewInfo = customViewer.GetViewer().GetViewInfo(ViewInfoOptions.ForHtmlView());
I have checked it and the error is coming on word file and it is working on pdf file.