Hello,
I would like to find out which PDF annotations are visible (to the user) within the innerDocWindowRect.
Best regards,
Andreas
Annotations within innerDocWindowRect
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
- User
- Posts: 63
- Joined: Fri Apr 27, 2018 11:17 am
Re: Annotations within innerDocWindowRect
Alternatively: It would be sufficient for us to find out the upper left and lower right corners (as PDF coordinates with respect to the PDF currently displayed) of what is currently visible for the user.
-
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Annotations within innerDocWindowRect
Hi Andreas
You may do it by the following procedure:
Cheers.
You may do it by the following procedure:
Code: Select all
public static tagRECT IntersectRects(tagRECT r1, tagRECT r2)
{
tagRECT res;
res.left = Math.Max(r1.left, r2.left);
res.right = Math.Min(r1.right, r2.right);
if (res.right < res.left)
res.right = res.left;
res.top = Math.Max(r1.top, r2.top);
res.bottom = Math.Min(r1.bottom, r2.bottom);
if (res.top > res.bottom)
res.top = res.bottom;
return res;
}
public bool GetVisibleAnnots(IPXV_Document doc, ref List<IPXC_Annotation> visibleAnnots)
{
visibleAnnots.Clear();
if (doc == null)
return false;
IPXC_Document coreDoc = doc.CoreDoc;
IPXV_DocumentView docView = doc.ActiveView;
if (docView == null)
return false;
IPXV_PagesView pagesView = docView.PagesView;
if (pagesView == null)
return false;
IPXC_OCContext ocCtx = pagesView.OCContext;
tagRECT viewRect = pagesView.Obj.ClientRect;
IPXV_PagesLayoutManager pagesLayout = pagesView.Layout;
IPXV_PagesLayoutRegions visibleRegions = pagesLayout.LayoutRegions;
uint rgnCount = visibleRegions.Count;
for (uint i = 0; i < rgnCount; i++)
{
PXV_PagesLayoutRegion rgn = visibleRegions[i];
uint pageIndex = rgn.nPage;
if ((rgn.rcVisibleRect.right - rgn.rcVisibleRect.left) < 1 || (rgn.rcVisibleRect.bottom - rgn.rcVisibleRect.top) < 1)
continue; // page is outside of current view area (but decorative page-shadow can be visible)
IPXC_Page page = coreDoc.Pages[pageIndex];
IPXC_AnnotsList annots = page.GetAnnotsList();
if (annots == null)
continue;
uint annotsCount = annots.Count;
for (uint j = 0; i < annotsCount; j++)
{
IPXC_Annotation annot = annots[i];
if (!ocCtx.IsAnnotVisible(coreDoc, annot))
continue; // annot is hidden
PXC_Rect annotRectOnPage = annot.get_Rect();
tagRECT viewAnnotRect = pagesLayout.PageRectToDeviceRect(pageIndex, ref annotRectOnPage, true);
tagRECT rc = IntersectRects(viewAnnotRect, rgn.rcVisibleRect);
if ((rc.right - rc.left) < 1 || (rc.bottom - rc.top) < 1)
continue; // there is no intersection between annot-rect and visible part of page
visibleAnnots.Add(annot);
}
}
return (visibleAnnots.Count != 0);
}
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.