Rank: Newbie
Groups: Registered
Joined: 11/24/2023(UTC) Posts: 2 Location: Landshut
|
Hello, how can I check whether the cursor is over a PathObject in a visible OCG when I mouse move in the PDF viewer? In the next Step i want to delete or move the Line or change the Color. I'm working with Patagames PDF version 4.10.10.35 Christian Edited by user Monday, November 27, 2023 3:36:43 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,104
Thanks: 7 times Was thanked: 129 time(s) in 126 post(s)
|
Hello, To solve this problem, three main steps are required. 1. Get Mouse coordinate in the control coordinate system and convert it to the page coordinate system using pdfViewer.ClientToPage method https://pdfium.patagames...er_CoordinateSystems.htm2. Enumerate all page objects and check the pageObject.BoundingBox property https://pdfium.patagames...ts.htm#enumerate-objects3. For each pageObject whose bounding rectangle surrounds a given point, find out its visibility group (Optional Content) and check if it is visible https://pdfium.patagames...gSDK_OptionalContent.htmCode:
var page = pdfViewer1.CurrentPage;
var pageObject = page.PageObjects[0];
var markedContent = pageObject.MarkedContent[0]; //The MarkedContent collection can contain multiple types of objects, so check them all, not just the first element as in this line.
var optionalcontent = markedContent as PdfOptionalContent; //You need an optional content only.
if(optionalcontent!= null)
{
var group = optionalcontent.Group;
if(group == null)
{
// optional content may be part of the membershop. In this case, the Group property is null
group = optionalcontent.Membership.OCGs[0]; //Collection OCGs may contain several groups. I think you need to check all of them, not just the first item as in the example.
}
bool isStateOn = pdfViewer1.Document.OCProperties.CheckVisibility(group);
}
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/24/2023(UTC) Posts: 2 Location: Landshut
|
Hello, thanks for the example. However, my version does not yet know Patagames.Pdf.Net.OptionalContent, and the Document does not yet have a property OCProperties. How can I avoid that?
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,104
Thanks: 7 times Was thanked: 129 time(s) in 126 post(s)
|
You can access OCG layers through the document dictionary (doc.Root property). However, you will have to dive deep into the PDF specification.
|
|
|
|
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