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

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Monday, June 8, 2020 5:56:01 PM(UTC)
 
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
gffranca Posted: Tuesday, June 2, 2020 12:08:24 PM(UTC)
 
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 Posted: Monday, September 11, 2017 3:37:13 PM(UTC)
 
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.