# PDFjs Processing

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

[PDF.js](https://mozilla.github.io/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 MVC and the PDF.js library. Versions before [2024.4.1112 (2024 Q4)](https://www.telerik.com/support/whats-new/aspnet-mvc/release-history/telerik-ui-for-asp-net-mvc-2024-4-1112-\(2024-q4\)) are not compatible with PDF.js 4.x.

| Major Releases                                                                                                                                                              | Compatible PDF.JS Versions |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------- |
| [Telerik UI for ASP.NET MVC 2025.1.211 (2025 Q1)](https://www.telerik.com/support/whats-new/aspnet-mvc/release-history/telerik-ui-for-asp-net-mvc-2025-1-211-\(2025-q1\))   | 4.6.82                     |
| [Telerik UI for ASP.NET MVC 2024.4.1112 (2024 Q4)](https://www.telerik.com/support/whats-new/aspnet-mvc/release-history/telerik-ui-for-asp-net-mvc-2024-4-1112-\(2024-q4\)) | 4.3.136                    |
| [Telerik UI for ASP.NET MVC 2024.3.1015](https://www.telerik.com/support/whats-new/aspnet-mvc/release-history/telerik-ui-for-asp-net-mvc-2024-3-1015)                       | 3.x, 2.x                   |

## Configuring with Telerik UI for ASP.NET MVC 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 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules" target="_blank">ECMAScript modules</a>, the [required Kendo UI scripts](https://www.telerik.com/aspnet-mvc/documentation/installation/adding-client-side-resources/getting-started-copy-client-resources) 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.

```C# Global.asax
    KendoMvc.Setup(options =>
    {
        options.RenderAsModule = true;
    });
```

```Razor _Layout
    <link href="https://cdn.jsdelivr.net/npm/@@progress/kendo-theme-default@10.0.1/dist/default-ocean-blue.css" rel="stylesheet" type="text/css" />
    <script src="https://code.jquery.com/jquery-3.7.1.min.js" type="module"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.8.69/pdf.mjs" type="module"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.8.69/pdf.worker.mjs" type="module"></script>
    <script src="https://cdn.jsdelivr.net/npm/@@progress/kendo-ui@2024.4.1112/umd/kendo.all.min.js" type="module"></script>
    <script src="https://cdn.jsdelivr.net/npm/@@progress/kendo-ui@2024.4.1112/umd/kendo.aspnetmvc.min.js" type="module"></script>
```

```Razor HtmlHelper
    @(Html.Kendo().PDFViewer()
        .Name("pdfviewer")
        .PdfjsProcessing(pdf => pdf.File("~/shared/web/pdfViewer/sample.pdf"))
        .Height(800)
    )

    <script type="module">
        $(document).ready(() => {
            var pdfviewer = $('#pdfviewer').data('kendoPdfViewer');
            console.log(pdfviewer);
        })  
    </script>
```

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

The Telerik UI for ASP.NET MVC 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 HtmlHelper
    <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

* [Server-Side API](https://www.telerik.com/aspnet-mvc/documentation/api/pdfviewer)
* [Using PDFViewer with PDF.js Version 4.x.x or Later](https://docs.telerik.com/aspnet-mvc/knowledge-base/pdfviewer-pdfjs-script-workarounds)
