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
edwin.rafe  
#1 Posted : Sunday, March 25, 2018 9:05:49 AM(UTC)
Quote
edwin.rafe

Rank: Newbie

Groups: Registered
Joined: 9/21/2017(UTC)
Posts: 3

Thanks: 1 times
I'm creating an application where I have to highlight some characters in the pdf file to help the users locate those chars.

I'm using the highlight function but sometimes, where the char is small, like a comma or a point It's very difficult to see the highlight. From my understanding the height of the highlight is the same height as the char, so thats why in small chars is difficult to see.

Is there any way that I can change the height of the highlight to make easyer for my users to find the marked chars?

As an alternative solution I've tried to draw rectangles aroud the chars overriding the OnPaint method. But I got performance issues since the on paint is called everytime I move or zoom the pdf and I had to redraw all the rectangles again.

Thanks in advance!

Regards,

Ed.
Paul Rayman  
#2 Posted : Sunday, March 25, 2018 10:04:57 AM(UTC)
Quote
Paul Rayman

Rank: Administration

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

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Please make sure that you are using the latest version.
https://forum.patagames....released-on-Mar-19--2018

Maybe these fixes resolves your issue.

Concerning your question, you can override DrawTextHighlight method.
Code:

protected override void DrawTextHighlight(PdfBitmap bitmap, List<HighlightInfo> entries, int pageIndex)
{
    if (entries == null)
	return;

    foreach (var e in entries)
    {
        var textInfo = Document.Pages[pageIndex].Text.GetTextInfo(e.CharIndex, e.CharsCount);
        var rects = NormalizeRects(textInfo.Rects, pageIndex);
        foreach (var r in rects)
            bitmap.FillRect(r.Left, r.Top, r.Width, r.Height, e.Color, FormsBlendMode);
    }
}


The code above is a standard drawing of a text highlight using by viewer.
The code of NormilizeRects method may be found here https://github.com/Patag...aster/PdfViewer.cs#L2300


also you may override following method. In this way the standard drawing of text highlights will not be affected.
Code:

protected override void DrawTextHighlight(Graphics graphics, List<HighlightInfo> entries, int pageIndex)
Quick Reply Show Quick Reply
Users browsing this topic
Guest
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.