Patagames Software Support Forum
»
Pdfium.Net SDK
»
Common Questions
»
How to find which fonts are used in a selected part of text
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 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.
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 11/1/2019(UTC) Posts: 23  Location: Rio de Janeiro Thanks: 2 times Was thanked: 4 time(s) in 3 post(s)
|
Originally Posted by: Paul Rayman  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,
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
|
|
|
|
|
|
Patagames Software Support Forum
»
Pdfium.Net SDK
»
Common Questions
»
How to find which fonts are used in a selected part of text
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