How to access the PDFViewerApplication inside the WiseJ.PdfViewer?

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
Answered
0
0

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?

TIA

Nic

  • You must to post comments
Best Answer
0
0

The Mozilla pdf.js viewer ignores the content disposition filename: https://github.com/mozilla/pdf.js/issues/6396  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
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json mixin.theme