Unplanned
Last Updated: 04 Nov 2019 15:06 by ADMIN

Bug report
Open a pdf file with links in PDF Viewer. Links are not clickable.

Reproduction of the problem
Open the demo for the PDF Viewer
Open a file, containing links
Click on a link

Current behavior
Clicking on a link does not redirect to the page

Expected/desired behavior
Clicking on a link should redirect to the link.

Environment
Kendo UI version: 2019.3.1023

Browser: [all]

Unplanned
Last Updated: 26 Mar 2024 13:33 by Raymond

Bug report

Reproduction of the problem

  1. Initialize a PDFViewer and add a button that calls a controller action on click.
<div id="pdfViewer">
</div>

<script type="text/javascript">
    $("#pdfViewer").kendoPDFViewer({
        pdfjsProcessing: {
            file: ""
        }
    });

    function loadFile() {
        $("#pdfViewer").data("kendoPDFViewer").fromFile("@Url.Action("GetPDF", "Home")");
    }
</script>
  1. Implement an action that returns a .pdf file or occasionally returns HttpNotFoundResult:
public ActionResult GetPDF()
{

    var name = "sample.pdf";
    string path = Server.MapPath("/Content/pdf/sample.pdf");

    //generate a random boolean:
    Random rng = new Random();
    bool randomBool = rng.Next(0, 2) > 0;
            
    if (randomBool)
    {
        byte[] fileBytes = System.IO.File.ReadAllBytes(path);
        return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, name);
    }
    else
    {
        return new HttpNotFoundResult("File not found.");
    }
}

Current behavior

In the case where the request returns HttpNotFoundResult, a number of js errors are thrown:

util.js:417 Uncaught (in promise)

The user loses the ability to load a file, because subsequent attempts to load a file by clicking the button result in another js exception:

api.js:1114 Uncaught TypeError: Cannot read properties of null (reading 'sendWithStream')

Expected/desired behavior

The component should show a message that a file is not found, without throwing js exceptions and should not become unusable after a failed attempt to load a file.

Environment

  • Kendo UI version: 2024.1.319
  • jQuery version: x.y
  • Browser: [all]