Document streaming JS error in Viewer v3.0

Hi


We are looking into sample example which you have shared for the asp.net. In our requirement we need to read file from stream. There is a option to getpages from htmlhandler to pass stream but we are not sure to set following values.

Please let us know how we will get these values in case of stream. Also if we are not passing these value its generating an error in the JavaScript (GroupdocsViwer.all.js) and document is not rendering.

attached is the JS error for details and below is the code we are using.


var docInfo = _htmlHandler.GetDocumentInfo(new DocumentInfoOptions(request.Path));

result.documentDescription = new FileDataJsonSerializer(docInfo.Pages,new FileDataOptions()).Serialize(false);

result.docType = docInfo.DocumentType;

result.fileType = docInfo.FileType;


we are sharing stream example which we are using to get pages

List<string> r = new List<string>();

r.Add(“documentbody”);

DbService dbService = new DbService();

byte[] get = dbService.GetFromDb(“annotation”, r, “AnnotationId”,“a5ddf168-40d6-e511-9430-00155d10122c”);

ByteStream = new MemoryStream(get);

var htmlPages = htmlHandler.GetPages(ByteStream,“Dynamics CRM Online Pricing and Licensing Guide.pdf”);

result.pageHtml = htmlPages.Select( => _.HtmlContent).ToArray();

//NOTE: Fix for incomplete cells document

for (int i = 0; i < result.pageHtml.Length; i++)

{

var html = result.pageHtml[i];

var indexOfScript = html.IndexOf(“script”);

if (indexOfScript > 0)

result.pageHtml[i] = html.Substring(0, indexOfScript);

}

Please share your view and sample example to fix this issue.

Thanks


Hi Group Docs Support,

Can we have update on this ASAP?

Thanks,
[Parth Patel]
puneet.rajak1:
Hi

We are looking into sample example which you have shared for the asp.net. In our requirement we need to read file from stream. There is a option to getpages from htmlhandler to pass stream but we are not sure to set following values.

Please let us know how we will get these values in case of stream. Also if we are not passing these value its generating an error in the JavaScript (GroupdocsViwer.all.js) and document is not rendering.

attached is the JS error for details and below is the code we are using.


var docInfo = _htmlHandler.GetDocumentInfo(new DocumentInfoOptions(request.Path));

result.documentDescription = new FileDataJsonSerializer(docInfo.Pages,new FileDataOptions()).Serialize(false);

result.docType = docInfo.DocumentType;

result.fileType = docInfo.FileType;


we are sharing stream example which we are using to get pages

List<string> r = new List<string>();

r.Add("documentbody");

DbService dbService = new DbService();

byte[] get = dbService.GetFromDb("annotation", r, "AnnotationId","a5ddf168-40d6-e511-9430-00155d10122c");

ByteStream = new MemoryStream(get);

var htmlPages = _htmlHandler.GetPages(ByteStream,"Dynamics CRM Online Pricing and Licensing Guide.pdf");

result.pageHtml = htmlPages.Select(_ => _.HtmlContent).ToArray();

//NOTE: Fix for incomplete cells document

for (int i = 0; i < result.pageHtml.Length; i++)

{

var html = result.pageHtml[i];

var indexOfScript = html.IndexOf("script");

if (indexOfScript > 0)

result.pageHtml[i] = html.Substring(0, indexOfScript);

}

Please share your view and sample example to fix this issue.

Thanks




Hi Puneet,

As you mentioned above that you are using stream which is coming from DB.

1st make sure that stream is formatted accurately. You can check it to save as file.

You can try the stream like following code.

MemoryStream memStream=null;
using (FileStream fileStream = File.OpenRead(_storagePath + "/" + request.Path))
{
memStream = new MemoryStream();
memStream.SetLength(fileStream.Length);
fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length);
}
var htmlPages = _htmlHandler.GetPages(memStream,request.Path);
result.pageHtml = htmlPages.Select(_ => _.HtmlContent).ToArray();

Thank you for your patience.

Warm Regards

The issues you have found earlier (filed as VIEWERNET-451;VIEWERNET-472) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by groupdocs.notifier.

Hello There,


Thank you for your query,

Your status is showing that you have no subscription. Can you create a new thread with this issue by using a paid account?

Thanks in advance

Hi Umar,

Thanks for your response.

We are facing issue in the following yellow highlighted code. Could you please let us know how/what value we need to set in this while reading from stream? When we are not setting values of documentDescription, docType, and fileType, an error occurring in the JavaScript (GroupdocsViwer.all.js) and file is not rendering. I have attached screen shot of an error which we are getting.

We are readying file from DB as stream and passing to GetPages method of hander. As shared in the earlier post.

var docInfo = _htmlHandler.GetDocumentInfo(new DocumentInfoOptions(request.Path));

result.documentDescription = new FileDataJsonSerializer(docInfo.Pages,new FileDataOptions()).Serialize(false);

result.docType = docInfo.DocumentType;

result.fileType = docInfo.FileType;

Hi


The account is Paid.
please see the reference
http://groupdocs.com/Community/forums/11620/viewer-3.x-for-asp.net-implementation/showthread.aspx#11620

Waiting for your response.

Thanks,

Hi Parth,



Thank you for your deep investigation.

Please note the following points.

  • GetPages - returns collection of rendered pages.
  • GetDocumentInfo - returns document and pages information only. This method doesn’t render anything.

Main purpose of this DocumentInfoContainer is to get document’s information before rendering any page.
For example if you want to render page number 10, you need to know if this page exist in the document. Or if you need to display total page count, etc. There are no method available to return the stream’s information before rendering.

By the way how you are setting Request.Path Parameter?

Therefore, As quick solution I would like to suggest you to save your stream as file in the storage directory and the pass that file to the viewer.
As far as the Cache is concerned. Please set IsResourcesEmbedded as true in HtmlOptions. Like as following.

var htmlOptions = new HtmlOptions { IsResourcesEmbedded = true };
var htmlPages = _htmlHandler.GetPages(request.Path, htmlOptions);

Have a nice day!


Thanks Puneet.

Umar,

Let us know if you need anything else.

Umar,

Thanks for quick response

For the Request.Path – we have given default file = candy.pdf but this is getting overwrite from the code while rendering stream file.

We have implemented work around, saving stream data to file and passing that file location to GetDocumentInfo and GetPages method. Please see below example.

We are trying to achieve rendering of stream directly without saving it to file.

*Look like Cache issue fixed after applying changes you mentioned. I will verify in detail and update you in case having any further issue.

List<string> r = new List<string>();

r.Add("documentbody");

DbService dbService = new DbService();

byte[] get = dbService.GetFromDb("annotation", r, "AnnotationId", "a5ddf168-40d6-e511-9430-00155d10122c"); // Get Byte Arrary - Stream

ByteStream = new MemoryStream(get); //Convert to Memory Stream

File.WriteAllBytes(HttpContext.Current.Server.MapPath(@"~/testfiles/") + "\\D.pdf", get); // Saving Stream as file.

//Get Document Infomration

var docInfo = _htmlHandler.GetDocumentInfo(new DocumentInfoOptions(HttpContext.Current.Server.MapPath(@"~/testfiles/") + "\\D.pdf"));

result.documentDescription = new FileDataJsonSerializer(docInfo.Pages, new FileDataOptions()).Serialize(false);

result.docType = docInfo.DocumentType;

result.fileType = docInfo.FileType;

//Render HTML PAges.

var htmlOptions = new HtmlOptions { IsResourcesEmbedded = true };

var htmlPages = _htmlHandler.GetPages(ByteStream, "Dynamics CRM Online Pricing and Licensing Guide1.pdf", htmlOptions);

result.pageHtml = htmlPages.Select(_ => _.HtmlContent).ToArray();

//NOTE: Fix for incomplete cells document

for (int i = 0; i < result.pageHtml.Length; i++)

{

var html = result.pageHtml[i];

var indexOfScript = html.IndexOf("script");

if (indexOfScript > 0)

result.pageHtml[i] = html.Substring(0, indexOfScript);

}

Hi


*Please response the post - 11647(above).
we are still waiting for the response.

we further investigate on the sample you provided and found following.

We have
found cache is not working for the HTML rendering of the “Webform Front End
sample”.<o:p></o:p>

We are getting following output for the Candy.pdf for the giving sample.

Please see attached screen shots for more information. Look like file its looking for its not able to locate.

To replicate this issue try using different file (new file) or remove cache of candy.pdf.

*Please consider this account on behalf of Gap Consulting.

Thanks

Hi


If we download the document and then render it from storage path with DocumentInfoOption method using html rendering, It still does not render correctly for the pdf files.

I am sharing a screen capture video for more details on following link
Dropbox - Error - Simplify your life

Please stream the video file and following points for more details of issue.

1. When we hit the left side document node the document should be render on right side.
2. After hitting the node, pdf files render comparatively slowly than other type of document.
3. When pdf file get loaded it looks good for first few second but the thumbnail does not get loaded properly untill we scroll down it.
4. Once thumbnail get load after putting manual effort, the pdf view get disturb and display all content in blue. also the font size get automatically changed.
5. This shows that the rendering of files is incorrect.

Please consider below 3 points to response:
1. Thumbnail is not loading accuretly.
2. After few seconds, the pdf file formatting get disturb leading to unreadable file.

Please also response to thread 11727.

Thanks

Hi Puneet,


Thanks for your investigation.

Did you get my response against 11647. I quoted that in my last message. Moreover, we are investigating the cache issue. Once there is any further update, you will be updated via this forum thread

Thanks for your understanding and cooperation

Warm Regards


Hi


Please respond to the above query as soon as possible.
We urgently require to progress on this.

Let us know if you are facing any issue in getting the vidoe which is shared.

Thanks

Hi Puneet,


I watched the video you provided.

Please can you provide us the problematic PDF file? We want to reproduce the issue at our end.This thing may help us to investigate the actual problem.

Thanks in advance

Hi


attached is the problematic pdf file.
Please let me know if you require anything else.

Thanks

Hi Puneet,


Thank you to provide us the concerned file.

We couldn’t reproduce the issue by using the attached file. The file was running without any issue at our side.

However, at your side it might be an issue of processing speed or RAM capacity. It will take longer time if running at a system with slower hardware specs.

Thank you

Hi Umar,

I can confirm this is not working, even we have verified on sample application which shared on the following location.

https://github.com/groupdocsviewer/GroupDocs_Viewer_NET/tree/master/Showcases/WebForm_Front_End

Even sample file (Candy.pdf) is not rendering correctly in sample example.

If you are using any different project for your testing I would suggest you double check with this sample application.

FYI.

We are working on HTML base rendering.

Please look into this ASAP.

Let me know in case having any further query.

Hi Parthpatel,


Thank you for your explanation,

I would like to suggest you to use our example project which is actually a console based/command line tool. The accuracy rate of the output using this tool is much higher because no CSS or other layout effects are applying on the rendered output.

Kindly try to use the example C# or VB project and verify the Html output. If you still would have the issue then please write to us with specs of your system hardware and operating system.

Thanks in advance

Hi Umar,


we are bound from customer to use Legacy UI, so console based application would not be any option for us.

Please try to fix the issue in your CSS or your other layout and provide us solution.
I have investigate same document on Viewer v2.19 version and It works absuletly fine.
so believing if you have a fix in earlier version than possibly you should fix the issue in this version as well.
If also you think there would be some minor change set require Please share the details we would try to fix that.

Thanks.