logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
Bazi101  
#1 Posted : Sunday, November 26, 2023 8:27:26 AM(UTC)
Quote
Bazi101

Rank: Newbie

Groups: Registered
Joined: 11/24/2023(UTC)
Posts: 2
Germany
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

Paul Rayman  
#2 Posted : Thursday, November 30, 2023 10:30:43 PM(UTC)
Quote
Paul Rayman

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.htm

2. Enumerate all page objects and check the pageObject.BoundingBox property
https://pdfium.patagames...ts.htm#enumerate-objects

3. 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.htm

Code:

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);
}
Bazi101  
#3 Posted : Friday, December 1, 2023 3:04:34 AM(UTC)
Quote
Bazi101

Rank: Newbie

Groups: Registered
Joined: 11/24/2023(UTC)
Posts: 2
Germany
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?
Paul Rayman  
#4 Posted : Friday, December 8, 2023 3:19:39 AM(UTC)
Quote
Paul Rayman

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.
Quick Reply Show Quick Reply
Users browsing this topic
New Topic Post Reply
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.