@@ -41,9 +41,25 @@ Optionally, you can structure the document by adding the desired HTML elements l
4141```
4242{% endif %}
4343
44- ## 2. Initialize the PDFViewer
44+ ## 2. Enable the RenderAsModule option
45+ Enable the ` RenderAsModule ` option, which will add ` type="module" ` to the initialization scripts of all Telerik UI components in the application:
4546
46- Load the ` pdf.js ` library and use the PDFViewer HtmlHelper {% if site.core %}or TagHelper{% endif %} to add the component to the view:
47+ {% if site.core %}
48+ ``` Program.cs
49+ builder .Services .AddKendo (x => x .RenderAsModule = true );
50+ ```
51+ {% else %}
52+ ``` Global.asax
53+ KendoMvc.Setup(options =>
54+ {
55+ options.RenderAsModule = true;
56+ });
57+ ```
58+ {% endif %}
59+
60+ ## 3. Initialize the PDFViewer
61+
62+ Load the ` pdf.js ` library and use the PDFViewer HtmlHelper {% if site.core %}or TagHelper{% endif %} to add the component to the view. :
4763
4864* The ` Name() ` configuration method is mandatory as its value is used for the ` id ` and the ` name ` attributes of the PDFViewer element.
4965* The ` Height() ` configuration allows you to control the height of the component.
@@ -53,7 +69,11 @@ Load the `pdf.js` library and use the PDFViewer HtmlHelper {% if site.core %}or
5369
5470<h4>PDFViewer</h4>
5571<div>
56- <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.js"></script>
72+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.mjs" type="module"></script>
73+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.worker.mjs" type="module"></script>
74+ <script src="https://code.jquery.com/jquery-3.7.1.min.js" type="module"></script>
75+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.all.min.js" type="module"></script>
76+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.aspnetmvc.min.js" type="module"></script>
5777
5878 <div>
5979 @(Html.Kendo().PDFViewer()
@@ -72,26 +92,30 @@ Load the `pdf.js` library and use the PDFViewer HtmlHelper {% if site.core %}or
7292```
7393{% if site.core %}
7494``` TagHelper
75- @addTagHelper *, Kendo.Mvc
95+ @addTagHelper *, Kendo.Mvc
7696
77- <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.js"></script>
97+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.mjs" type="module"></script>
98+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.worker.mjs" type="module"></script>
99+ <script src="https://code.jquery.com/jquery-3.7.1.min.js" type="module"></script>
100+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.all.min.js" type="module"></script>
101+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.aspnetmvc.min.js" type="module"></script>
78102
79- <div id="example">
80- <kendo-pdfviewer name="pdfviewer"
81- height="400">
82- </kendo-pdfviewer>
83- </div>
103+ <div id="example">
104+ <kendo-pdfviewer name="pdfviewer"
105+ height="400">
106+ </kendo-pdfviewer>
107+ </div>
84108
85- <style>
86- html body #pdfviewer {
87- width: 100% !important;
88- }
89- </style>
109+ <style>
110+ html body #pdfviewer {
111+ width: 100% !important;
112+ }
113+ </style>
90114
91115```
92116{% endif %}
93117
94- ## 3 . Load an Initial PDF Document
118+ ## 4 . Load an Initial PDF Document
95119
96120To load and visualize an initial PDF document, set the ` PdfjsProcessing ` configuration and specify the path to the PDF file.
97121
@@ -100,7 +124,11 @@ To load and visualize an initial PDF document, set the `PdfjsProcessing` configu
100124
101125<h4>PDFViewer</h4>
102126<div>
103- <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.js"></script>
127+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.mjs" type="module"></script>
128+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.worker.mjs" type="module"></script>
129+ <script src="https://code.jquery.com/jquery-3.7.1.min.js" type="module"></script>
130+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.all.min.js" type="module"></script>
131+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.aspnetmvc.min.js" type="module"></script>
104132
105133 <div>
106134 @(Html.Kendo().PDFViewer()
@@ -120,27 +148,30 @@ To load and visualize an initial PDF document, set the `PdfjsProcessing` configu
120148```
121149{% if site.core %}
122150``` TagHelper
123- @addTagHelper *, Kendo.Mvc
124-
125- <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.js"></script>
126-
127- <div id="example">
128- <kendo-pdfviewer name="pdfviewer"
129- height="400">
130- <pdfjs-processing file="@Url.Content("~/shared/web/pdfViewer/sample.pdf")" />
131- </kendo-pdfviewer>
132- </div>
151+ @addTagHelper *, Kendo.Mvc
133152
134- <style>
135- html body #pdfviewer {
136- width: 100% !important;
137- }
138- </style>
153+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.mjs" type="module"></script>
154+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.worker.mjs" type="module"></script>
155+ <script src="https://code.jquery.com/jquery-3.7.1.min.js" type="module"></script>
156+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.all.min.js" type="module"></script>
157+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.aspnetmvc.min.js" type="module"></script>
158+
159+ <div id="example">
160+ <kendo-pdfviewer name="pdfviewer"
161+ height="400">
162+ <pdfjs-processing file="@Url.Content("~/shared/web/pdfViewer/sample.pdf")" />
163+ </kendo-pdfviewer>
164+ </div>
139165
166+ <style>
167+ html body #pdfviewer {
168+ width: 100% !important;
169+ }
170+ </style>
140171```
141172{% endif %}
142173
143- ## 4 . Handle a PDFViewer Event
174+ ## 5 . Handle a PDFViewer Event
144175
145176The PDFViewer exposes various [ events] ( /api/kendo.mvc.ui.fluent/pdfviewerbuilder ) that you can handle and further customize the functionality of the component. In this example, you will use the ` Open ` event, which fires when a PDF is opened in the PDFViewer. As a result, the browser console will log a message when you open a PDF file.
146177
@@ -149,7 +180,11 @@ The PDFViewer exposes various [events](/api/kendo.mvc.ui.fluent/pdfviewerbuilder
149180
150181<h4>PDFViewer</h4>
151182<div>
152- <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.js"></script>
183+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.mjs" type="module"></script>
184+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.worker.mjs" type="module"></script>
185+ <script src="https://code.jquery.com/jquery-3.7.1.min.js" type="module"></script>
186+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.all.min.js" type="module"></script>
187+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.aspnetmvc.min.js" type="module"></script>
153188
154189 <div>
155190 @(Html.Kendo().PDFViewer()
@@ -178,34 +213,38 @@ The PDFViewer exposes various [events](/api/kendo.mvc.ui.fluent/pdfviewerbuilder
178213```
179214{% if site.core %}
180215``` TagHelper
181- @addTagHelper *, Kendo.Mvc
182-
183- <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.2/pdf.js"></script>
216+ @addTagHelper *, Kendo.Mvc
184217
185- <div id="example">
186- <kendo-pdfviewer name="pdfviewer"
187- <pdfjs-processing file="@Url.Content("~/shared/web/pdfViewer/sample.pdf")" />
188- height="400"
189- on-open="onOpen">
190- </kendo-pdfviewer>
191- </div>
218+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.mjs" type="module"></script>
219+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.worker.mjs" type="module"></script>
220+ <script src="https://code.jquery.com/jquery-3.7.1.min.js" type="module"></script>
221+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.all.min.js" type="module"></script>
222+ <script src="https://cdn.kendostatic.com/2024.4.1112/js/kendo.aspnetmvc.min.js" type="module"></script>
223+
224+ <div id="example">
225+ <kendo-pdfviewer name="pdfviewer"
226+ <pdfjs-processing file="@Url.Content("~/shared/web/pdfViewer/sample.pdf")" />
227+ height="400"
228+ on-open="onOpen">
229+ </kendo-pdfviewer>
230+ </div>
192231
193- <script>
194- function onOpen(e) {
195- console.log("file open: " + e.file.name);
196- }
197- </script>
232+ <script>
233+ function onOpen(e) {
234+ console.log("file open: " + e.file.name);
235+ }
236+ </script>
198237
199- <style>
200- html body #pdfviewer {
201- width: 100% !important;
202- }
203- </style>
238+ <style>
239+ html body #pdfviewer {
240+ width: 100% !important;
241+ }
242+ </style>
204243
205244```
206245{% endif %}
207246
208- ## 5 . (Optional) Reference Existing PDFViewer Instances
247+ ## 6 . (Optional) Reference Existing PDFViewer Instances
209248
210249You can reference the PDFViewer instances that you have created and build on top of their existing configuration:
211250
0 commit comments