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
|
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
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)
{
...
}
}
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 1/4/2021(UTC) Posts: 11
Thanks: 1 times
|
Thanks Paul, works great.
|
|
|
|
|
|
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.
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