How do I call the Controller to load a PDF using the PDFViewer Control

1 Answer 54 Views
PDFViewer
Brandon Renk
Top achievements
Rank 1
Brandon Renk asked on 20 Dec 2023, 09:12 PM

I am having an issue getting my controller code to get called from the UI.  Here is what I have tried. 

<script type="text/javascript">

    $(document).ready(function () {
        $("#pdfViewer").kendoPDFViewer({
            fromFile: {
                url: "@Url.Action("DetailsReport", "ReportViewer")"
            }
        });
    });


</script>

 

--RAZOR PAGE

 @(Html.Kendo().PDFViewer()
                              .Name("pdfViewer")

                        )

 

Controller ActionMethod (never gets called).  

returns File(bytes, mimeType).  

                              

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 25 Dec 2023, 08:38 AM

Hello Brandon,

For visibility and convenience to the community, I am sharing a summary of the solution from the related support thread.

The shared syntax is reinitializing the PdfViewer widget. Instead, you would get a reference to the existing widget and use its fromFile() method:

$(document).ready(function () {
    $("#pdfViewer").data("kendoPDFViewer").fromFile("@Url.Action("DetailsReport", "ReportViewer")");
});

To ensure there are no errors, place the script after the declaration of the PdfViewer, for example, to the end of the page.

Regards,
Peter Milchev
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
PDFViewer
Asked by
Brandon Renk
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or