Free Support Forum - groupdocs.com

Rendering in native format and pdf

Hi,


I have been using GroupDocs.Viewer Library from a while. I am able to render the documents in Html and Image mode. You have examples for rendering the document in pdf and native format, however all I can understand that it is simply saving the document stream. I have made a WebApi Service on top of GroupDocs.Viewer Library which render in html and Image mode and return the response containing HtmlContent. I can’t figure out what needs to be returned as response when rendered in native and pdf formats.

Is there an ambiguity when GroupDocs says rendering mode is native and pdf also?

Hi Pushpendra,


Thanks for using GroupDocs.Viewer for .NET API.

GroupDocs.Viewer API provides ViewerHandler.GetFile() and ViewerHandler.GetPdfFile() methods to get original file and PDF version of file respectively. Both methods return FileContainer object which contains the file stream and this stream can be saved as a physical file. Therefore, in your case, web API can return FileContainer.Stream as a response and you can then save that stream as file at receiving end afterwards.

In case of any confusion, please feel free to ask.

Warm Regards

Hello Usman,


Thanks for responding, If I send the stream as a response and save it as a physical file in the receiving end. How exactly can we render it then on the client side? Groupdocs.Viewer .net library says that it supports native rendering. When the rendering mode is html/image, it is sending a htmlresponse which I can render on client side, however how can I do it with a stream?

We have a feature release scheduled which requires this native rendering. Can you please let me know If it’s possible to render the document in native format/pdf?

Hi Pushpendra,


Yes, native document rendering is supported by GroupDocs.Viewer API. In this case, stream returned by GetFile() or GetPdfFile() method must be included/written in the header of HttpContext’s response. After the client app receives this response, it depends on the browser whether it supports to display that file format or not. In case the browser does not support the format, file will be downloaded automatically. We have implemented this feature in following sample front end application.

  • <a rel=“nofollow” href=“https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/tree/master/Showcases/ASP.NET_WebForm_Front_End” class=“js-navigation-open” id=“3b1c9237c5322dddadcbaffe9171d725-4afbe9c6154d0bc50f93628a5b4b694576cee4a3” title=“ASP.NET_WebForm_Front_End” style=“box-sizing: border-box; color: rgb(64, 120, 192); text-decoration: none; font-family: -apple-system, BlinkMacSystemFont, “Segoe UI”, Roboto, Helvetica, Arial, sans-serif, “Apple Color Emoji”, “Segoe UI Emoji”, “Segoe UI Symbol”; font-size: 14px; line-height: 20px; white-space: nowrap; background-color: rgb(255, 255, 255);”>ASP.NET_WebForm_Front_End

You can download this application and check the get file features implemented in it.

In case of any confusion, please feel free to ask.

Warm Regards