Patagames Software Support Forum
»
Pdfium.Net SDK
»
Common Questions
»
I would like my PDF to be on a floating position and not centered (Vertically)
Rank: Guest
Groups: Guests
Joined: 1/5/2016(UTC) Posts: 162
Was thanked: 5 time(s) in 5 post(s)
|
Hello everyone, With your help, and more specifically, Paul Rayman's help (thanks again), I have been able to put a nice mouse wheel zoom on my application. I'm now facing a new zoom problem. When I zoom out on my PDF, there is no problem, but when i zoom in, the zoom isn't very precise at the beginning because the PDF page is vertically centered when the vertical scrollbar is visible. I would like that the PDF stay focus on where the mouse cursor is (vertically). I would like to end up with a floating margin top and bottom. Can someone tell me where (or how) the PDF position is managed. Thank you very much ! Edited by user Sunday, November 19, 2017 10:47:56 PM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
The pages in the viewer are aligned according to the PageAlign property. In your case, you have PageAlign = MiddleCenter.
There is only one way to influence to page position. If you know the displayed size of the page and the client size of the viewer, then you can calculate the page offset from its normal position. Accordingly, you can set the padding value of the viewer and thus move the page to the desired position vertically. Summarizing: 1. set pdfViewer.PageAlign to ContentAlignment.TopCenter 2. Calculate page offset from the top border of the viewer 3. set pdfViewer.Padding.Top to calculated value.
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 2/6/2018(UTC) Posts: 11  Location: Paris Thanks: 6 times
|
Hello Paul,
I've tried that:
PageHAlign : Center PageVAlign: Top VerticalAlignement: Stretch Vertical contentAlignement : Top
And then i tried with this code:
private void pdfViewerMouseWheel(object sender, MouseWheelEventArgs e) { if (e.Delta < 0 || e.Delta > 0) { // Get the x and y coordinates of the mouse pointer. System.Windows.Point position = e.GetPosition(this); double pY = position.Y; double pX = position.X;
// Sets the Height/Width of the circle to the mouse coordinates. pdfViewer.Height = pY; pdfViewer.Width = pX;
} }
The problem is that all the pdfViewer move and i would like that only the open PDF follows the mouse cursor... Can you help me?
Thanks
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
If I understood you correctly, you should change pdfViewer1.Padding property Edited by user Tuesday, February 6, 2018 5:26:04 PM(UTC)
| Reason: Not specified
|
 1 user thanked Paul Rayman for this useful post.
|
|
|
|
Rank: Member
Groups: Registered
Joined: 2/6/2018(UTC) Posts: 11  Location: Paris Thanks: 6 times
|
Thank you, it works perfectly !!!!!
|
|
|
|
|
|
Patagames Software Support Forum
»
Pdfium.Net SDK
»
Common Questions
»
I would like my PDF to be on a floating position and not centered (Vertically)
Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can 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