Rank: Newbie
Groups: Registered
Joined: 7/6/2020(UTC) Posts: 3  Location: Prague Thanks: 1 times
|
Hi there,
I've been trying to figure out how to add a custom shape (like a zone, which purpose is highliting the selected place) on the pdf page in WPF. It's easy to do it in WinForms using PdfViewer.OnPaint method, but there is nothing like that in WPF if I'm right and please correct me if not.
Therefore I've tried a numerous ways and did it by adding a shape in a grid or canvas which is fine, but the problem occured when started zooming the page. I used the methods such as PdfViewer.CalcActualRect etc. to get the coords of the page rect, then a difference between the shape rect and page rect and so on, but it still doesn't scale properly when zooming the page or resizing a window.
Is there any way how to bound the shape's size to the page (its content)? Or can you explain me a bit how it works please? I would really appreciate it!
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)
|
Originally Posted by: nobody  I've been trying to figure out how to add a custom shape (like a zone, which purpose is highliting the selected place) on the pdf page in WPF. It's easy to do it in WinForms using PdfViewer.OnPaint method, but there is nothing like that in WPF if I'm right and please correct me if not. PdfViewer.OnRenderQuote: Is there any way how to bound the shape's size to the page (its content)?
Try ClientToPage / PageToClient to translate point between the coordinate space of the page and the control. Edited by user Tuesday, July 7, 2020 5:48:02 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/6/2020(UTC) Posts: 3  Location: Prague Thanks: 1 times
|
Don't exactly know how to use this, but it won't be necessary I guess as I don't wanna draw the rectangle on the page directly. I would prefer to use like another layer and that's why I've been trying to use a canvas or grid instead, but thanks anyway. Maybe I'll try later on... Quote:Try ClientToPage / PageToClient to translate point between the coordinate space of the page and the control. In this case if I use PageToClient method, it seems to be the same as CalcActualRect meaning, that I can get these values from the CalcActualRect. I haven't got a lot of experience with such a computing so I might be wrong or just don't know how to use it properly. Could you lead me more please? 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)
|
Call ClientToPage before scaling to find out the coordinates of your point in the page coordinate space. After scaling, call PageToclient to find out the new coordinates of your point in the coordinate space of the control. Now you can draw this point in any WPF-specific way. And this point will be in the same place as before relative to the page elements. The coordinates of the point in the page coordinate space are the same regardless of the scale or rotation of the page. Edited by user Thursday, July 9, 2020 5:08:20 AM(UTC)
| Reason: Not specified
|
 1 user thanked Paul Rayman for this useful post.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/6/2020(UTC) Posts: 3  Location: Prague Thanks: 1 times
|
Works like a charm, thanks a lot again!
|
|
|
|
|
|
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