Declined
Last Updated: 03 Sep 2021 13:29 by ADMIN
Created by: Mugurel
Comments: 1
Category: PDFViewer
Type: Bug Report
0

I load a pdf on a PDFViewer component using loadDefault function, but Open event is not fired.

Also, I want to scroll to the end of the document and for that, I need to retrieve the count of the pages and activate the last page in the render event, even it's called multiple times.

How can I get the count of the pages and scroll to the end of the .pdf document after it is loaded?

    @(Html.Kendo().PDFViewer().Name("documentViewer")
        .PdfjsProcessing(pdf => pdf.File(Url.Content("~/Content/data/default.pdf")))
        .Events(e => e
            .Error("(function(e) { onDocumentViewerError(e); })")
            .Render("(function(e) { onDocumentViewerRender(e); })")
            .Open("(function(e) { onDocumentViewerOpen(e); })")
        )
    )
...
<script type="text/javascript">
...

function loadDefault() {
    var docUrl = window.location.origin + window.location.pathname + "Content/data/default.pdf";

    var pdfViewer = $("#documentViewer").data("kendoPDFViewer");
    pdfViewer.fromFile(docUrl);
 }

onDocumentViewerRender = function(e) {
    console.log("render");

    if (goToEnd) {
         goToEnd = false;

         setTimeout(function () {
              var pdfViewer = $("#documentViewer").data("kendoPDFViewer");
              pdfViewer.activatePage(pagesCount); // how to get pagesCount
         }, 2000);
    }
}

onDocumentViewerOpen = function(e) {
    console.log("open"); // not shown in Console
}
...
</script>