Patagames Software Support Forum
»
Pdfium.Net SDK
»
FAQ
»
How to turn on "touch pinch gesture" on viewer?
Rank: Newbie
Groups: Registered
Joined: 3/14/2016(UTC) Posts: 4
Thanks: 2 times
|
May I know how to turn on "touch pinch gesture" on the viewer and also allow "Ctrl" key + mouse wheel for zooming? Edited by user Monday, March 14, 2016 5:50:27 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,107
Thanks: 7 times Was thanked: 130 time(s) in 127 post(s)
|
To implement the Zoom with Ctrl+MouseWeel you can create derived class like shown below. Please note, the PdfViewer.SizeMode should be set to SizeModes.Zoom. Code:
public class MyPdfViewer : PdfViewer
{
private float _maxPageSize = 0;
protected override void OnDocumentLoaded(EventArgs e)
{
foreach(var p in Document.Pages)
{
if (p.Width > _maxPageSize)
_maxPageSize = p.Width;
if (p.Height > _maxPageSize)
_maxPageSize = p.Height;
}
base.OnDocumentLoaded(e);
SizeMode = SizeModes.Zoom;
Zoom = 1;
}
protected override void OnMouseWheel(MouseEventArgs e)
{
if ((ModifierKeys & Keys.Control) == Keys.Control)
{
float newZoom = Zoom;
if (e.Delta < 0)
newZoom *= 0.9f;
else
newZoom /= 0.9f;
if (_maxPageSize * newZoom >100 &&_maxPageSize * newZoom < 5000)
Zoom = newZoom;
}
else
base.OnMouseWheel(e);
}
}
To implement touch pinch gesture you can use the same technique. Edited by user Tuesday, March 15, 2016 1:04:53 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 3/14/2016(UTC) Posts: 4
Thanks: 2 times
|
If PdfViewer.SizeModes is set to SizeModes.Zoom, the web link will not be clickable. I used Pdfium (not .Net SDK) PdfRenderer to display PDF, it allows Ctrl-MouseWheel as well as clickable web link. Will it be any workaround way?
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,107
Thanks: 7 times Was thanked: 130 time(s) in 127 post(s)
|
I am checked it - everything works fine. The WebLinks and PdfLinks are clickable in a Zoom size mode.
What do you mean then talking "PdfRenderer to display PDF"? Pdfium does not have anything called "PdfRenderer"
|
1 user thanked Paul Rayman for this useful post.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 3/14/2016(UTC) Posts: 4
Thanks: 2 times
|
- Because I tried using Zoom size but not clickable, I'll check it out with your code.
- PdfRenderer
Thx Edited by user Wednesday, March 16, 2016 4:23:53 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/28/2019(UTC) Posts: 5
|
Hello, Would it be possible to share a sample for pinch zoom for touch screens? The pinch gestures work great with the touchpad of the laptop, but I have not had much luck to get it to work with touch screens. I have tried using the touch events, but I am not sure I get all the pertinent information. Best regards, Apostol Bakalov Originally Posted by: Paul Rayman To implement the Zoom with Ctrl+MouseWeel you can create derived class like shown below. Please note, the PdfViewer.SizeMode should be set to SizeModes.Zoom. Code:
public class MyPdfViewer : PdfViewer
{
private float _maxPageSize = 0;
protected override void OnDocumentLoaded(EventArgs e)
{
foreach(var p in Document.Pages)
{
if (p.Width > _maxPageSize)
_maxPageSize = p.Width;
if (p.Height > _maxPageSize)
_maxPageSize = p.Height;
}
base.OnDocumentLoaded(e);
SizeMode = SizeModes.Zoom;
Zoom = 1;
}
protected override void OnMouseWheel(MouseEventArgs e)
{
if ((ModifierKeys & Keys.Control) == Keys.Control)
{
float newZoom = Zoom;
if (e.Delta < 0)
newZoom *= 0.9f;
else
newZoom /= 0.9f;
if (_maxPageSize * newZoom >100 &&_maxPageSize * newZoom < 5000)
Zoom = newZoom;
}
else
base.OnMouseWheel(e);
}
}
To implement touch pinch gesture you can use the same technique.
|
|
|
|
Patagames Software Support Forum
»
Pdfium.Net SDK
»
FAQ
»
How to turn on "touch pinch gesture" on viewer?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close