How to access the PDFViewerApplication inside the WiseJ.PdfViewer?


I’m still trying to set the download filename on the PdfViewer control when using pdf.js as the viewer. I’ve discovered that the underlying javascript object PDFViewerApplication, has a method setTitleUsingUrl() which takes a URL and then figures out the filename from it.

My problem now is that I cannot figure out how to access the PDFViewerApplication object. I’ve tried to do this from OnWebRender and from other objects and using Eval(string.Format(“PDFViewerApplication.setTitleUsingUrl(‘{0}’);”, Application.Url + fileName)); but I always get “PDFViewerApplication is undefined”

I’ve tried to debug the js but I just cannot find this object anywhere and as I’m a c# developer I don’t understand the js model or the development tools enough to find this object. I’ve spend a couple of days trying to work it out but am getting nowhere.

Can anyone point me in the right direction?



  • You must to post comments
Best Answer

The Mozilla pdf.js viewer ignores the content disposition filename:  Google viewer has the same issue.

It should already support using the URL name as the file name. But you have to set the PdfSource to a full URL otherwise Wisej will assume it’s a local file and sends it through the postback url. I tried using this.pdfViewer1.PdfSource = Application.Url + “Files/Wisej-Datasheet-V2.3.pdf”; and I get the file name. But you have to enable CORS in your web server since pdf.js is coming from another URL (unless you host it locally).

About the PDFViewerApplication object or any other javascript object they are walled off by the browser since the viewer runs in either an iframe or embed div and comes from a different URL. In addition, the code is extremely complicated and is executed in web workers making even more difficult to debug.

The best (only?) way to show the document file name is to return the document as a full URL and don’t use the postback handler. If you need to extract, compose the pdf file dynamically you may be able to register a URL path for an handler and process the file there.


  • Nic Adams
    As I thought – I just don’t know enough about browsers / javascript – I guess that is the beauty of WiseJ :)
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.