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

Notification

Icon
Error

Options
Go to last post Go to first unread
cbrit  
#1 Posted : Thursday, February 4, 2021 2:57:40 PM(UTC)
cbrit

Rank: Member

Groups: Registered
Joined: 1/4/2021(UTC)
Posts: 11

Thanks: 1 times
Hello,

I have a scenario where I am using the WinForms Graphics to highlight signature fields because I was unable to figure out how to highlight signature fields in a different color than other fields using the .NET SDK.

My current approach is to get every signature field (or control) and then highlight it's rectangle using the Viewer.PageToClient() method. The problem with this approach is that it seems to be putting the highlights of every control on every page onto each page, instead of just the controls that belong to a given page.

My thinking is that I need a way to only consider controls on visible pages in the viewer, taking into account the viewer's Zoom value. Is there a way to do this? Or is there a better approach?

EDIT: Maybe the more important question is how to I check if a control is visible on the viewer?

Thank you

Edited by user Thursday, February 4, 2021 3:11:34 PM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Thursday, February 4, 2021 4:45:44 PM(UTC)
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)
Hello,

Here's an example.

Code:

protected override void DrawFillForms(PdfBitmap bmp, PdfPage page, Rectangle actualRect)
{
	base.DrawFillForms(bmp, page, actualRect);

	var ctrls = Document.FormFill.InterForm.GetPageControls(page);
	foreach(var ctrl in ctrls)
    {
		if (ctrl.Type != Patagames.Pdf.Enums.FormFieldTypesEx.Sign)
			continue;

		var lb = PageToClient(page.PageIndex, new PointF(ctrl.BoundRect.left, ctrl.BoundRect.bottom));
		var rt = PageToClient(page.PageIndex, new PointF(ctrl.BoundRect.right, ctrl.BoundRect.top));

		int x = Math.Min(lb.X, rt.X);
		int y = Math.Min(lb.Y, rt.Y);
		int w = Math.Abs(lb.X - rt.X);
		int h = Math.Abs(lb.Y - rt.Y);
		bmp.FillRect(x, y, w, h, FS_COLOR.Red, Patagames.Pdf.Enums.BlendTypes.FXDIB_BLEND_MULTIPLY);
	}
}


or with transparency
Code:
bmp.FillRect(x, y, w, h, new FS_COLOR(50, 255, 0, 0));

Edited by user Thursday, February 4, 2021 4:50:43 PM(UTC)  | Reason: Not specified

cbrit  
#3 Posted : Friday, February 5, 2021 6:23:02 AM(UTC)
cbrit

Rank: Member

Groups: Registered
Joined: 1/4/2021(UTC)
Posts: 11

Thanks: 1 times
Hi Paul,

Could you explain what that Bitmap is exactly? Is this method I am highlighting unsigned (and signed) fields.

It seems like these are supplied by the Patagames code in the background somewhere and I won't have to pass in those arguments, but I want to be sure.

Edited by user Friday, February 5, 2021 6:26:29 AM(UTC)  | Reason: Not specified

Paul Rayman  
#4 Posted : Friday, February 5, 2021 6:57:28 AM(UTC)
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)
It seems I didn't understand your question properly.

I'll clarify just in case.

Method DrawFillForms is a protected virtual method of the PdfViewer class. It is called by the engine during the rendering of the PDF page.
You shouldn't call this method and pass any parameters there.

All you need to do is create a child class and override this method.

Code:
public class MyPdfViewer : PdfViewer
{
    protected override void DrawFillForms(PdfBitmap bmp, PdfPage page, Rectangle actualRect)
    {
        ...
    }
}
cbrit  
#5 Posted : Friday, February 5, 2021 9:24:16 AM(UTC)
cbrit

Rank: Member

Groups: Registered
Joined: 1/4/2021(UTC)
Posts: 11

Thanks: 1 times
Thanks Paul, works great.
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.