Skip to content

883856: How to Restrict Zoom Percentage on Mobile Devices #2938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
layout: post
title: Restrict Zoom Percentage in EJ2 ASP.NET MVC PDF Viewer | Syncfusion
description: Learn here all how to restrict zoom percentage in ASP.NET MVC PDF Viewer component of Syncfusion Essential JS 2 and more.
platform: ej2-asp-core-mvc
control: PDF Viewer
publishingplatform: ##Platform_Name##
documentation: ug
---

# How to Restrict Zoom Percentage on Mobile Devices

In Syncfusion PDF Viewer, you can easily restrict the zoom percentage on mobile devices using the **maxZoom** and **minZoom** property. This feature allows you to set specific limits for zooming, ensuring smoother scrolling performance and efficient document loading, on mobile devices.

{% tabs %}
{% highlight html tabtitle="Standalone" %}

<div style="width:100%;height:600px">
@Html.EJS().PdfViewer("pdfviewer").DocumentLoad("documentLoad").DocumentPath("https://cdn.syncfusion.com/content/pdf/hive-succinctly.pdf").Render()
</div>

<script>
function documentLoad() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
if (ej2_base_1.Browser.isDevice && !viewer.enableDesktopMode) {
viewer.maxZoom = 200;
viewer.minZoom = 10;
}
else {
viewer.zoomMode = 'Default';
}
}
</script>

{% endhighlight %}
{% highlight html tabtitle="Server-Backed" %}

<div style="width:100%;height:600px">
@Html.EJS().PdfViewer("pdfviewer").ServiceUrl(VirtualPathUtility.ToAbsolute("~/api/PdfViewer/")).DocumentLoad("documentLoad").DocumentPath("https://cdn.syncfusion.com/content/pdf/hive-succinctly.pdf").Render()
</div>

<script>
function documentLoad() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
if (ej2_base_1.Browser.isDevice && !viewer.enableDesktopMode) {
viewer.maxZoom = 200;
viewer.minZoom = 10;
}
else {
viewer.zoomMode = 'Default';
}
}
</script>
{% endhighlight %}
{% endtabs %}

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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
layout: post
title: Restrict Zoom Percentage in ##Platform_Name## PDF Viewer Component| Syncfusion
description: Learn here all about how to restrict zoom percentage in Syncfusion ##Platform_Name## PDF Viewer component of Syncfusion Essential JS 2 and more.
platform: ej2-asp-core-mvc
control: PDF Viewer
publishingplatform: ##Platform_Name##
documentation: ug
---

# How to Restrict Zoom Percentage on Mobile Devices

In Syncfusion PDF Viewer, you can easily restrict the zoom percentage on mobile devices using the **maxZoom** and **minZoom** property. This feature allows you to set specific limits for zooming, ensuring smoother scrolling performance and efficient document loading, on mobile devices.

{% tabs %}
{% highlight html tabtitle="Standalone" %}

<div style="width:100%;height:600px">
<ejs-pdfviewer id="pdfviewer"
style="height:600px"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
</ejs-pdfviewer>
</div>

<script>
function documentLoad() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
if (ej2_base_1.Browser.isDevice && !viewer.enableDesktopMode) {
viewer.maxZoom = 200;
viewer.minZoom = 10;
}
else {
viewer.zoomMode = 'Default';
}
}
</script>

{% endhighlight %}
{% highlight html tabtitle="Server-Backed" %}

<div style="width:100%;height:600px">
<ejs-pdfviewer id="pdfviewer"
style="height:600px"
serviceUrl="/api/PdfViewer"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
</ejs-pdfviewer>
</div>

<script>
function documentLoad() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
if (ej2_base_1.Browser.isDevice && !viewer.enableDesktopMode) {
viewer.maxZoom = 200;
viewer.minZoom = 10;
}
else {
viewer.zoomMode = 'Default';
}
}
</script>

{% endhighlight %}
{% endtabs %}

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.
1 change: 1 addition & 0 deletions ej2-asp-core-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,7 @@
<li><a href="/ej2-asp-core/pdfviewer/how-to/signatureselect-signatureunselect">SignatureSelect and SignatureUnselect event</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/download-start-event">Controlling File Downloads</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/min-max-zoom">Minimum and Maximum Zoom Properties</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/restricting-zoom-in-mobile-mode">Restrict Zoom Percentage on Mobile Devices</a></li>
</ul>
</li>
<li>Troubleshooting
Expand Down
1 change: 1 addition & 0 deletions ej2-asp-mvc-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1863,6 +1863,7 @@
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/signatureselect-signatureunselect">SignatureSelect and SignatureUnselect event</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/download-start-event">Controlling File Downloads</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/min-max-zoom">Minimum and Maximum Zoom Properties</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/restricting-zoom-in-mobile-mode">Restrict Zoom Percentage on Mobile Devices</a></li>
</ul>
</li>
<li>Troubleshooting
Expand Down