Free Support Forum - groupdocs.com

Viewer does not show text files

Hi,


I’ve managed to get our application to work the same as the demo in https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/tree/master/Showcases/ASP.NET_MVC_Front_End

I had to change the name of the div that we’ve got our viewer in (created by installableviewer.js) since the div is expected to be named viewerHtmlDiv in groupdocsviewer.all.js when it calculates the size of the elements - causing emails to not display at all (i.e. it worked in your demo, but not in our code).

Now I’ve got that working and checked that we are using exactly the same CSS, JavaScript and C# code from the demo - our viewer behaves just like yours. However neither of them can display text file contents.

I used a simple text file (attached) with the single line Hello! in it.

The div for that contains the text is in the DOM but not visible. This is what is shown in Chrome debugging tools:

Hello!

But the parent div (with the class text_document_wrapper) has a size of 0x0 suggesting that Chrome thinks the div is empty. I have tried to find the cause of this but I failed.

Please can you investigate this?

Thanks,
Darryl

This is tested with API v17.1.0


I tried using API v17.2.0 but it cannot render some documents because the temp folder is created with . characters replaced with _ characters but the GroupDocs API in version 17.2.0 is looking for a folder with . in the name. I will post the exception and the full stack trace shortly.

Hi Darryl,


Thanks for using GroupDocs.Viewer for .NET.

We have investigated the issue related to text files and implemented its fix in ASP.NET_MVC_Front_End. Please download the updated GroupdocsViewer.all.js file from the GitHub repository and check if the issue is resolved at your end.

Furthermore, we have successfully reproduced the issue related to .msg file at our end and it is good to know that you have fixed it. We have logged this issue as https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/issues/118.

In case you would have any other queries, please do let us know.

Warm Regards

<span style=“font-family: “PT Sans”, Helvetica, Arial, sans-serif; font-size: 14px; background-color: rgb(242, 242, 242);”>Error shown:

<span style=“font-family: “PT Sans”, Helvetica, Arial, sans-serif; font-size: 14px; background-color: rgb(242, 242, 242);”>
<span style=“font-family: “PT Sans”, Helvetica, Arial, sans-serif; font-size: 14px; background-color: rgb(242, 242, 242);”>Could not find a part of the path ‘D:\temp\2017-05-03 ASP.NET_MVC_Front_End\ASP.NET_MVC_Front_End\App_Data\temp\A4464.C490.ClaimControl TEST.msg\html\resources\page1\styles.css’.
<span style=“font-family: “PT Sans”, Helvetica, Arial, sans-serif; font-size: 14px; background-color: rgb(242, 242, 242);”>
<span style=“font-family: “PT Sans”, Helvetica, Arial, sans-serif; font-size: 14px; background-color: rgb(242, 242, 242);”>But the temp folder contains a folder called:
A4464_C490_ClaimControl TEST_msg

This was done with a download of the MVC_Front_End source code today.

Downgrading to version 17.1.0 with nuget package manager:
uninstall-package groupdocs-viewer-dotnet
install-package groupdocs-viewer-dotnet -version 17.1.0

Results in compilation errors due to changes in the API. (Changes to HtmlOptions and RotatePageOptions) so I am unable to test that scenario with this version of the MVC_Front_End app.

Note - this error only occurs when viewing .MSG files in HTML mode - Image mode is working in the demo app.

The error is thrown from the File.WriteAllText() call as _tempPath contains the . characters:
MvcSample.dll!MvcSample.Controllers.ViewerController.GetHtmlPages(string filePath, GroupDocs.Viewer.Converter.Options.HtmlOptions htmlOptions, out System.Collections.Generic.List cssList) Line 599 C#
MvcSample.dll!MvcSample.Controllers.ViewerController.ViewDocumentAsHtml(MvcSample.Models.ViewDocumentParameters request, MvcSample.Models.ViewDocumentResponse result, string fileName) Line 780 C#
MvcSample.dll!MvcSample.Controllers.ViewerController.ViewDocument(MvcSample.Models.ViewDocumentParameters request) Line 91 C#

However I can now see that tempPath is calculated in the demo app rather than from the GroupDocs.DLL - so the fix is to the demo app - add .Replace(".", "") to the file name at line 602:
if (needResave)
{
var fullPath = Path.Combine(tempPath, filePath.Replace(’.’, '’), “html”, “resources”,
string.Format(“page{0}”, page.PageNumber), resource.ResourceName);

System.IO.File.WriteAllText(fullPath, text);
}

Hi Usman,


As a workaround I set our application to use the image mode for text files. I’ll give your fix a try shortly.

Thanks,
Darryl

Hi Darryl,


Sure, we’ll be looking forward to your feedback.

Warm Regards
Hi Darryl,

We are happy to inform you that your reported issue logged in GitHub issues as https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/issues/118 has been resolved. Please download the latest source code from the GitHub repository.

Warm Regards

I can confirm that the fix for text files worked. Thanks for the speedy response.