Free Support Forum -

Override GroupdocsViewerController in MVC

Hello Deric,

Sorry that this taken so many time. But when we tried to fix your issue we found out a bug in our library. It means that you can't use ViewerController in such approach. The issue will be fixed in the Viewer 2.16.0 and example project will be also created for this feature.

As a workaround you can use approach which we described in our previous posts - you need to create wrappers around all GroupDocs.Viewer HTTP-handlers, which take part in document rendering process. For image-based mode they are: "GetScriptHandler", "GetCssHandler", "ViewDocumentHandler", "LoadFileBrowserTreeDataHandler", "GetImageUrlsHandler", "GetDocumentPageImageHandler", "GetPdf2JavaScriptHandler". For other options like file downloading, printing, rotating etc you also need to wrap "GetFileHandler", "GetPdfWithPrintDialogHandler", "GetPdfWithPrintDialogHandler", "GetPrintableHtmlHandler", "ReorderPageHandler", "RotatePageHandler". For HTML-based rendering you also need several more HTTP-handlers, you can find all of them, for example, here: "How to use GroupDocs.Viewer for .NET in an ASP.NET Project"

The main idea of that wrapper is described here: "How to Replace HTTP Handlers to Set Up User Permissions in the GroupDocs.Viewer for .NET Library" You need to create your own HTTP-handler, which should supersede original handler. In your custom handler you check authorization status and if it is successful, you invoke the original handler.

Summing all these: you have two variants - 1. Wait for the new version of the library with example project. 2. Use HTTP handlers approach.

Best regards.

Continuing thread Authorization on /document-viewer/GetDocumentPageImage

Hi Deric,

Attached ticket.

Best regards.

All set! Thank you!

Hi Deric,

We have fixed the issue and created a sample project which shows how to override ViewerController. Please download and investigate it here.

Best regards.

Thank you, Pavel! I have included the wrapper in our solution and it works great with new dll v 2.16.0!

Hi Deric,

Glad to hear that.

Best regards.

Hello Team,

Could you please provide another project for overriding GroupdocsViewerController in MVC since the parameters have changed in 2.17.0 version?

Thank you in advance.

Hi Deric,

We haven’t change any parameters so you should be able to use same example with the Viewer 2.17.0

Best regards.

Hi Pavel,

For example

return this._viewerController.GetPdfWithPrintDialog(path, displayName, watermarkText, watermarkColor,watermarkPosition, watermarkWidth, useHtmlBasedEngine, supportPageRotation, instanceIdToken);

is changed into

return this._viewerController.GetPdfWithPrintDialog(parameters);

It turned out to be fairly simple, so I have added the changes and project works well.

Thank you!

Hi again,

Yes, well done.

Best regards.