Free Support Forum - groupdocs.com

.txt files from stream


#1

Hello,

I having an issue integrating the annotations tool into my web forms .net project. I want to open files from stream but when i try to open .txt files viewer opens a popup and it say “The document couldn’t be loaded…”. But when i try to open same txt file with using filepath rather stream, it works.

First code doesnt work, second is works and i added my txt file as attachment

return Viewer.ClientCode()
.TargetElementSelector("#test").ShowFolderBrowser(false)
.Stream(new FileStream(@“C:\ViewerDemoDocs\testText.txt”, FileMode.Open, FileAccess.Read, FileShare.Read))
.EnableRightClickMenu(false)
.ShowThumbnails(true)
.OpenThumbnails(false)
.ZoomToFitWidth()
.Width(1000)
.Height(750).ToString();
return Viewer.ClientCode()
.TargetElementSelector("#test").ShowFolderBrowser(false)
.FilePath(@“C:\ViewerDemoDocs\testText.txt”)
.EnableRightClickMenu(false)
.ShowThumbnails(true)
.OpenThumbnails(false)
.ZoomToFitWidth()
.Width(1000)
.Height(750).ToString();

#2

I was trying different things and i noticed something. If i use like this;

return Viewer.ClientCode()
.TargetElementSelector("#test").ShowFolderBrowser(false)
.Stream(new FileStream(ddlFile.SelectedItem.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read), Path.GetFileNameWithoutExtension(ddlFile.SelectedItem.ToString())
, Path.GetExtension(ddlFile.SelectedItem.ToString()), Path.GetFileName(ddlFile.SelectedItem.ToString()), false)
.EnableRightClickMenu(false)
.ShowThumbnails(true)
.OpenThumbnails(false)
.ZoomToFitWidth()
.Width(1000)
.Height(750).ToString();

or in annotation this also works
return new WidgetFactory()
.Annotation()
.ElementId(“test”)
.Stream(new FileStream(@“C:\ViewerDemoDocs\testText.txt”, FileMode.Open, FileAccess.Read, FileShare.Read), Groupdocs.Common.FileType.Txt)
.Width(1000)
.Height(750).ToHtmlString();

But this dont work, it opens a popup and it say “The document couldn’t be loaded…”.
return new WidgetFactory()
.Annotation()
.ElementId(“test”)
.Stream(new FileStream(@“C:\ViewerDemoDocs\testText.txt”, FileMode.Open, FileAccess.Read, FileShare.Read),“testText.txt”)
.Width(1000)
.Height(750).ToHtmlString();

I need to work with second one


#3

The issues you have found earlier (filed as WEB-1431) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by GroupDocs Notifier.

#4

Hello fkucuk,

Thank you for notifying us about this - yes, it is the same bug. GroupDocs.Annotation internally uses a GroupDocs.Viewer, so the bug in the GroupDocs.Viewer is also present in the GroupDocs.Annotation.

This bug occurs only with the TXT and some other file formats; it works okay with PDF and DOC/DOCX, for example. Our developers started to work on it.

We will notify you in this forum thread when the bug will be fixed. Sorry for the inconvenience.


#5

Thanks for reply,

Yes, exactly. PDF, DOC/DOCX, XLS/XLSX works fine.