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
Paul Rayman  
#1 Posted : Monday, September 11, 2017 6:37:13 PM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 898

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
Hi,

You should use PdfTextObject.Font property to get the font parameters.

To find the match between selected text and PdfTextObject you can find the intersection between bounded rectangles of the selection and the bounded rectangle of the each PdfTextObject on the pages where that selection is located.
gffranca  
#2 Posted : Tuesday, June 2, 2020 3:08:24 PM(UTC)
Quote
gffranca

Rank: Newbie

Groups: Registered
Joined: 11/1/2019(UTC)
Posts: 6
Brazil
Location: Rio de Janeiro

Thanks: 2 times
Originally Posted by: Paul Rayman Go to Quoted Post
Hi,

You should use PdfTextObject.Font property to get the font parameters.

To find the match between selected text and PdfTextObject you can find the intersection between bounded rectangles of the selection and the bounded rectangle of the each PdfTextObject on the pages where that selection is located.



I wrote the following:


Code:
HighlightInfo hi = new HighlightInfo();
hi.CharIndex = pdfViewerOriginal.SelectInfo.StartIndex;
hi.CharsCount = pdfViewerOriginal.SelectedText.Length;
var rects = new List<System.Drawing.Rectangle>();
for (int page = pdfViewerOriginal.SelectInfo.StartPage; page <= pdfViewerOriginal.SelectInfo.EndPage; page++)
{
     rects.AddRange(pdfViewerOriginal.GetHighlightedRects(page, hi));
}
for(int i = 0; i < rects.Count; i++)
{
     foreach(PdfTextObject pto in allTextObjOriginal)
     {
     var r = pto.BoundingBox;
     if (rects[i].IntersectsWith(new System.Drawing.Rectangle((int)r.left, (int)r.top, (int)r.Width, (int)r.Height)))
     {
           fulltext += pto.TextAnsi;
           break;
     }
}



But it seems GetHighlightedRects() return Rects that change location according to the viewer's zoom.

I want to get every PdfTextObject of my selected text.



Kind Regars,

Paul Rayman  
#3 Posted : Monday, June 8, 2020 8:56:01 PM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 898

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
You should convert the coordinates of bounding box of text object to the control coordinate system
https://pdfium.patagames...fViewer_PageToClient.htm

Or, vise versus, convert the coordinates of selection to the page coordinate system
https://pdfium.patagames...fViewer_ClientToPage.htm

Edited by user Monday, June 8, 2020 9:01:10 PM(UTC)  | Reason: Not specified

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.