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

Error when no initial document

1 Answer 197 Views
PdfViewer
This is a migrated thread and some comments may be shown as answers.
Brete
Top achievements
Rank 1
Brete asked on 03 Mar 2020, 04:21 PM

 Is there a requirement that the RadPdfViewer load a file on page load?  

When I call pdfviewer.fromfile() when no initial document is set I get the attached error.  If I set the initial file to any valid pdf 

IE:  (  <PdfjsProcessingSettings File="/default2.pdf">
            </PdfjsProcessingSettings>

)

 

I do not get the error.  

 

 

     <telerik:RadPdfViewer runat="server" ID="RadPdfViewer1" Height="650px" Width="100%" Scale="0.9">
                <ToolBarSettings Items="pager, spacer, zoom, toggleSelection, spacer, search, print" />
 
           
        </telerik:RadPdfViewer>

 

 function loadFile(name) {


                var pdfViewer = $find("<%=RadPdfViewer1.ClientID %>");
               
            

                     
                    pdfViewer.fromFile(name);
               
            }

 

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 06 Mar 2020, 12:07 PM

Hi Brete,

Thank you for reporting this bug!

The problem is already fixed as noted here so once we update the Kendo scripts in the AJAX suite it will go away.

There is a workaround you can use - highlighted in the sample below:

        <asp:ScriptManager runat="server"></asp:ScriptManager>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.js"></script>
        <script type="text/javascript">
            window.pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.worker.js';
        </script>
        <telerik:RadPdfViewer runat="server" ID="RadPdfViewer1" RenderMode="Lightweight" Height="550px" Width="900px" Scale="1.5" ActivePage="3" ClientEvents-OnLoad="OnClientLoad">
            
        </telerik:RadPdfViewer>
        <input type="button" onclick="loadFile('images/test1.pdf');return false;" value="Load File" />
        <script>
            kendo.pdfviewer.pdfjs.processor.fn._updateDocument = function (file) {
                if (this.pdf) {
                    this.pdf.loadingTask.destroy();
                }

                this.file = file;
            };

            function loadFile(name) {
                var pdfViewerObject = $find("<%=RadPdfViewer1.ClientID %>"); //the standard script control object
                var kendoPdfViewerObject = pdfViewerObject.get_kendoWidget(); //the Kendo widget
                kendoPdfViewerObject.fromFile(name);
            }
        </script>

        <script>
            var name = "images/Ticket.pdf";
            function OnClientLoad(sender, args) {
                var pdfViewerObject = sender //the standard script control object
                var kendoPdfViewerObject = pdfViewerObject.get_kendoWidget(); //the Kendo widget
                kendoPdfViewerObject.fromFile(name);

            }
        </script>

Regards,
Rumen
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Tags
PdfViewer
Asked by
Brete
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or