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: Friday, June 29, 2018 4:53:09 AM(UTC)
 
What's wrong with this code? It works great for me.
The only one thing to consider is that the controls of the field can be placed on a several pages.
matt.smokeball Posted: Thursday, June 28, 2018 8:36:31 PM(UTC)
 
Hi

Great product, I'm loving using it and how customizable it can be!

I'm trying to determine if the first control on a field is currently visible in the viewer. I'm using the current code in an extended PdfViewer (WPF) class.

There's definitely something wrong with it. Was hoping you could please point me in the right direction. I think what I have is completely wrong, even though it works sometimes.

Thanks for your help

Code:


private Rect GetControlDimensions(PdfControl ctrl, int pageIndex)
{
    Point pt1 = PageToClient(pageIndex, new Point(ctrl.BoundRect.left, ctrl.BoundRect.top));
    Point pt2 = PageToClient(pageIndex, new Point(ctrl.BoundRect.right, ctrl.BoundRect.bottom));

    //The page may be rotated, so we must take it into account
    int left = (int)Math.Min(pt1.X, pt2.X);
    int top = (int)Math.Min(pt1.Y, pt2.Y);
    int right = (int)Math.Max(pt1.X, pt2.X);
    int bottom = (int)Math.Max(pt1.Y, pt2.Y);

    return new Rect(left, top, right - left, bottom - top);
}

private bool IsFieldVisible(PdfField field)
{
   PdfControl ctrl = field.Controls.FirstOrDefault();

    if (ctrl != null)
    {
        Rect dimensions = GetControlDimensions(ctrl, CurrentIndex);

        if (dimensions.Top > 0 && dimensions.Bottom < ViewportHeight)
        {
            return true;
        }
    }

    return false;
}