Display Document in native format

Hi Usman,


I current group-docs version (17.2.0), generally (by analyzing API calls) each document is processed first based on html/image rendering and then save it to the temp folder in pdf, image and xml resources. In some cases, it might happens that document wont be the same after processing due to in between implicit rendering. My Question here is, can we display document directly to the viewer without processing it, I mean display document in native format so that it wont be changed as we have skipped rendering. Is this scenario valid or possible?

Regards,
Nikhilesh

Hi Nikhilesh,


Thank you for sharing your question,

Here, I am writing inline response against your main points.

it might happens that document wont be the same after processing due to in between implicit rendering
Basically, the GroupDocs.Viewer API is responsible to render a document(either in image or html) in its 100% of original visual form. However, if someone reports even very minor difference in the out put, the GroupDocs team is using the proper systems to fix the issues.

My Question here is, can we display document directly to the viewer without processing it, I mean display document in native format so that it wont be changed as we have skipped rendering. Is this scenario valid or possible?

Both the viewer handlers (ViewerHtmlHandler,ViewerImageHandler) provides a method GetFile which accepts document name as parameter and returns FileContainer.
The File stream can be fetched from the Stream property of the FileContainer

Please have a look at below link for further guidance:


https://docs.groupdocs.com/display/viewernet/Render+a+Document+as+it+is+(original+form)

Regards

Hi Umar,


Thanks for your response. We have gone through source code for rendering a document as it is and rendering a document as PDF. What we want to know is if its possible to send the original file stream to the browser(as opposed to Html/Images) and whether the browser can render the document using this file stream?

We want to know if its possible to avoid conversion of documents to html/images to render them.

Kindly let us know if its possible , even an example will help.

Hi Shashi,


Thank you for sharing your thoughts,

Since the GroupDocs.Viewer can render the docs of more than 50 different formats. While, every format has a native program to display or edit the relevant doc (like xls can be open in MS Excel). Therefore, if render/display the docs of different formats is a concern, it is inevitable for a successfull rendering engine to choose the most common formats for the output. That’s why GroupDocs.Viewer is rendering the docs in most common and generic formats like HTML and Image. But it doesn’t mean that the output might be disturbed. It is guaranteed by GroupDocs that the output would be 100% accurate.

As far as rendering a doc stream by the browser is concerned. It would be depended on what formats are supporting by the browser to display the files. Say as, if you want to display the PDF files, as this format is supported by many famous browsers like chrome, firefox etc. So that you can write stream by using the below C# code.
<pre class=“lang-cs prettyprint prettyprinted” style=“margin-top: 0px; margin-bottom: 1em; padding: 5px; border: 0px; font-size: 13px; width: auto; max-height: 600px; overflow: auto; font-family: Consolas, Menlo, Monaco, “Lucida Console”, “Liberation Mono”, “DejaVu Sans Mono”, “Bitstream Vera Sans Mono”, “Courier New”, monospace, sans-serif; background-color: rgb(239, 240, 241); color: rgb(57, 51, 24); word-wrap: normal;”><code style=“margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, “Lucida Console”, “Liberation Mono”, “DejaVu Sans Mono”, “Bitstream Vera Sans Mono”, “Courier New”, monospace, sans-serif; white-space: inherit;”> Response.ClearContent();
Response.ContentType = “application/pdf”;
Response.AddHeader(“Content-Disposition”, “inline; filename=” + docName);
Response.AddHeader(“Content-Length”, docSize.ToString());
Response.BinaryWrite((byte[])docStream);
Response.End();

If the browser wouldn’t support the format of the stream, it will ask to download the file.
Hope, it might be a closer answer to your question.We are looking forward to your feedback.

Regards