|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Minimum and Maximum Zoom in EJ2 ASP.NET MVC PDF Viewer | Syncfusion |
| 4 | +description: Learn here all about Minimum and Maximum Zoom in ASP.NET MVC PDF Viewer component of Syncfusion Essential JS 2 and more. |
| 5 | +platform: ej2-asp-core-mvc |
| 6 | +control: PDF Viewer |
| 7 | +publishingplatform: ##Platform_Name## |
| 8 | +documentation: ug |
| 9 | +--- |
| 10 | + |
| 11 | +## Minimum and Maximum Zoom Properties |
| 12 | + |
| 13 | +The Syncfusion PDF Viewer provides the ability to control zoom levels for viewing PDF documents. The `minZoom` and `maxZoom` properties enable developers to set the minimum and maximum zoom levels, ensuring a consistent and controlled viewing experience. |
| 14 | + |
| 15 | +### minZoom |
| 16 | + |
| 17 | +The `minZoom` property specifies the minimum zoom percentage allowed in the PDF Viewer. This ensures that users cannot zoom out beyond a certain limit, which helps maintain readability and performance. Developers can set the `minZoom` property programmatically, defining the minimum zoom level based on the application's requirements. This is particularly useful for preventing users from zooming out too much, which could make the content difficult to read. |
| 18 | + |
| 19 | +### maxZoom |
| 20 | + |
| 21 | +The `maxZoom` property defines the maximum zoom percentage allowed in the PDF Viewer. By setting this property, developers can prevent users from zooming in too much, helping to avoid performance issues and maintain a smooth viewing experience. The `maxZoom` property can be set programmatically to control the upper limit of the zoom level. This is useful for applications where extremely high zoom levels might degrade performance or user experience. |
| 22 | + |
| 23 | +```cs |
| 24 | + |
| 25 | +@{ |
| 26 | + ViewBag.Title = "Home Page"; |
| 27 | + double maxZoom = 200; |
| 28 | + double minZoom = 20; |
| 29 | +} |
| 30 | + |
| 31 | +<div> |
| 32 | + <div style="height:100%; width: 100%;"> |
| 33 | + @Html.EJS().PdfViewer("pdfviewer").ServiceUrl(VirtualPathUtility.ToAbsolute("~/Home/")).DocumentPath("PDF_Succinctly.pdf").MaxZoom(maxZoom).MinZoom(minZoom).Render() |
| 34 | + </div> |
| 35 | +</div> |
| 36 | +``` |
| 37 | + |
| 38 | +#### Restrict Zoom Percentage on Mobile Devices |
| 39 | + |
| 40 | +You can easily restrict the zoom percentage on mobile devices using the `minZoom` and `maxZoom` properties. This feature allows you to set specific limits for zooming, ensuring smoother scrolling performance and efficient document loading on mobile devices. By controlling the zoom levels, you can provide a better user experience across different devices. |
| 41 | + |
| 42 | +{% tabs %} |
| 43 | +{% highlight html tabtitle="Standalone" %} |
| 44 | + |
| 45 | +<div style="width:100%;height:600px"> |
| 46 | + @Html.EJS().PdfViewer("pdfviewer").DocumentLoad("documentLoad").DocumentPath("https://cdn.syncfusion.com/content/pdf/hive-succinctly.pdf").Render() |
| 47 | +</div> |
| 48 | + |
| 49 | +<script> |
| 50 | + function documentLoad() { |
| 51 | + var viewer = document.getElementById('pdfviewer').ej2_instances[0]; |
| 52 | + if (ej2_base_1.Browser.isDevice && !viewer.enableDesktopMode) { |
| 53 | + viewer.maxZoom = 200; |
| 54 | + viewer.minZoom = 10; |
| 55 | + } |
| 56 | + else { |
| 57 | + viewer.zoomMode = 'Default'; |
| 58 | + } |
| 59 | + } |
| 60 | +</script> |
| 61 | + |
| 62 | +{% endhighlight %} |
| 63 | +{% highlight html tabtitle="Server-Backed" %} |
| 64 | + |
| 65 | +<div style="width:100%;height:600px"> |
| 66 | + @Html.EJS().PdfViewer("pdfviewer").ServiceUrl(VirtualPathUtility.ToAbsolute("~/api/PdfViewer/")).DocumentLoad("documentLoad").DocumentPath("https://cdn.syncfusion.com/content/pdf/hive-succinctly.pdf").Render() |
| 67 | +</div> |
| 68 | + |
| 69 | +<script> |
| 70 | + function documentLoad() { |
| 71 | + var viewer = document.getElementById('pdfviewer').ej2_instances[0]; |
| 72 | + if (ej2_base_1.Browser.isDevice && !viewer.enableDesktopMode) { |
| 73 | + viewer.maxZoom = 200; |
| 74 | + viewer.minZoom = 10; |
| 75 | + } |
| 76 | + else { |
| 77 | + viewer.zoomMode = 'Default'; |
| 78 | + } |
| 79 | + } |
| 80 | +</script> |
| 81 | +{% endhighlight %} |
| 82 | +{% endtabs %} |
| 83 | + |
| 84 | +By implementing this, you ensure that the maximum zoom percentage on mobile devices is limited to 200% and the minimum zoom percentage is set to 10%. This prevents performance issues that may arise from excessive zooming on mobile platforms. |
0 commit comments