This is a migrated thread and some comments may be shown as answers.

PDFViewer WithCredentials for CORS Request

1 Answer 56 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Janson
Top achievements
Rank 1
Janson asked on 01 Mar 2021, 04:07 PM
I need to pull pdf's from a different site, additionally the site requires authentication.  It looks like the PDF.js library supports xhr withcredentials, how do I specify this when using the Kendo wrapper?
@(Html.Kendo().PDFViewer()
        .Name("pdfviewer")
        .PdfjsProcessing(pdf => pdf
            .File(Url.Content("https://localhost:44335/test.pdf")) 
        )
    )

1 Answer, 1 is accepted

Sort by
0
Accepted
Aleksandar
Telerik team
answered on 04 Mar 2021, 10:16 AM

Hi Janson,

Currently setting the XHR headers using the HTML Helpers is not supported, as this options is not exposed in the jQuery API of the PDFViewer. I have therefore logged a Feature Request on your behalf to expose this option, so it translates to the HTML Helpers as well.

For the time being I can suggest considering initializing the PDFViewer using jQuery. While the httpHeaders options is not officially exposed setting the httpHeaders will allow you to pass headers with the request:

$("#pdfviewer").kendoPDFViewer({
        pdfjsProcessing: {
          file: {
            url: "https://demos.telerik.com/kendo-ui/content/web/pdfViewer/sample.pdf",
            httpHeaders: {
              authentication: "abcxyz",
            }
          }
        }
      });

Here is a dojo demonstrating the above. I hope this approach will be useful in your scenario until the feature is available out-of-the-box for the Telerik UI for ASP.NET Core PDFViewer.

Let me know if I can be of any further help.

Regards,
Aleksandar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
PDFViewer
Asked by
Janson
Top achievements
Rank 1
Answers by
Aleksandar
Telerik team
Share this question
or