New to Telerik UI for ASP.NET CoreStart a free 30-day trial

PDFjs Processing

By default, if no processing configuration is defined, the PDFViewer uses the PDF.js library.

PDF.js is an open-source project that is developed by Mozilla.

Requirements

The following table showcases the compatibility between Telerik UI for ASP.NET Core and the PDF.js library. Versions before 2024.4.1112 (2024 Q4) are not compatible with PDF.js 4.x.

Configuring with Telerik UI for ASP.NET Core 2024 Q4 and Later

Starting with version 2024.4.1112 (2024 Q4), the PDFViewer requires PDF.js version 4.x.x or later.

Since PDF.js 4 (versions 4.x.x) uses ECMAScript modules, the required Kendo UI scripts must be included as modules. Also, enable the RenderAsModule option, which will add type="module" to the initialization scripts of all Telerik UI components in the application.

The following example demonstrates how to configure the PDFViewer to use PDF.js processing with PDF.js 4.

Program.cs
    builder.Services.AddKendo(x => x.RenderAsModule = true);

Configuring with Telerik UI for ASP.NET Core Before Version 2024 Q4

The Telerik UI for ASP.NET Core versions before 2024.4.1112 are not compatible with PDF.js version 4.x. You must use either PDF.js version 2.x or 3.x.

The following example demonstrates how to configure the PDFViewer to use PDF.js processing with PDF.js version 2.2.2.

Razor
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.js"></script>
    <script>
        window.pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.worker.js';
    </script>

    @(Html.Kendo().PDFViewer()
        .Name("pdfviewer")
        .PdfjsProcessing(pdf => pdf
            .File(Url.Content("~/Content/web/pdfViewer/sample.pdf"))
        )
        .Height(1200)
    )

See Also