Reselect rectangle from annot after edit Quads

114 views
Skip to first unread message

Daniel Lutz

unread,
Nov 14, 2013, 11:46:50 AM11/14/13
to pdfne...@googlegroups.com

Hello 

when i add normaly an anot to a pdf page and select it with the annotedit-tool from Tools.dll (PDFViewWPF Control) then i have the following picture.

Now i edit the quads of the annot in the background and refresh the appereances. Then i select the same annot with the tool an get the following picture.

Now the quads are look in the right way but not the red rectangle of selection tool. How i can resize the rectangle (the red one!) I try  SetRect() of Annot-Class but when i refresh the appereance then i get an exception of PresentationCore.dll. How is the right way to resize the red rectangle?


with greetings


Daniel

Tomas Hofmann

unread,
Nov 14, 2013, 3:05:27 PM11/14/13
to pdfne...@googlegroups.com
Hi Daniel,

I am not quite sure how you are updating the quads.
Could you please post a code sample of how you are updating this?

When it comes to moving annotations, we would normally use Annot.Resize(newAnnotRect);
However, in general, Highlight annotations aren't moved. Is this what you are trying to do?

If you try with the Resize function , do you run into any problems?

Also, this week we will be releasing PDFNet version 6.1. In this release, the tools will be distributed as part of the sample code. You can then look directly at the tools. See the PDFViewWPFTools in the sample solution for the source code.
Annotations are moved in the class SelectionHelper, from Utilities -> SelectionHelper.cs.
The AnnotEdit tool does the selection and handles mouse input, but ultimately tells the SlectionHelper to move the annot in the page.

Best Regards,
Tomas Hofmann

Daniel Lutz

unread,
Nov 15, 2013, 2:17:45 AM11/15/13
to pdfne...@googlegroups.com
Hello Thomas,

thanks for answering my post. I try the function resize() but i havn't the right effect. There is no exception but the red rectangle in the picture is not the same!

To update the quads i to the following steps.

1. i create a highlight
2. i create a new highlight which is cuttingwith the first one in 2 parts
3. i show how cut the secound highlight the first one and search the exactly quads.
4. i clone the first highlight  then i have 3 highlights  with same  properties
5. i delete the first one
6. for the clone annots i rewrite with SetQuadPoint() Function the Quadpoints of Markup

var originalQuadPoint = _highlight.GetQuadPointCount();

            if (originalQuadPoint <= _quadrangleCollection.Count) // QuadrangleCollection has the new Quads inside
            {
                for (int i = 0; i < _quadrangleCollection.Count; i++)
                {
                    var qPoint = _quadrangleCollection[i];

                    _highlight.SetQuadPoint(i, new pdftron.PDF.QuadPoint(new pdftron.PDF.Point(qPoint.TopLeft.X, qPoint.TopLeft.Y),
                        new pdftron.PDF.Point(qPoint.TopRight.X, qPoint.TopRight.Y),
                        new pdftron.PDF.Point(qPoint.BottomRight.X, qPoint.BottomRight.Y),
                        new pdftron.PDF.Point(qPoint.BottomLeft.X, qPoint.BottomLeft.Y)));
                }
            }
            else
            {
                for (int i = 0; i < originalQuadPoint; i++)
                {
                    if (i < _quadrangleCollection.Count)
                    {
                        var qPoint = _quadrangleCollection[i];

                        _highlight.SetQuadPoint(i, new pdftron.PDF.QuadPoint(new pdftron.PDF.Point(qPoint.TopLeft.X, qPoint.TopLeft.Y),
                            new pdftron.PDF.Point(qPoint.TopRight.X, qPoint.TopRight.Y),
                            new pdftron.PDF.Point(qPoint.BottomRight.X, qPoint.BottomRight.Y),
                            new pdftron.PDF.Point(qPoint.BottomLeft.X, qPoint.BottomLeft.Y)));
                    }
                    else
                    {
                        _highlight.SetQuadPoint(i, new pdftron.PDF.QuadPoint()); // here i rewrite the old points with empty point because there is no function to remove the points 
                    }
                }

7. After rewriting i refresh the appereance and update the viewer

Best Regards 
Daniel

Daniel Lutz

unread,
Nov 17, 2013, 9:54:06 AM11/17/13
to pdfne...@googlegroups.com
Hello Thomas,

i found the solution. The method Annot.SetRect() is the right way. After the code i post i have a method to build a new rectangle from the quadpoints of the annot. The method build a rectangle with a wrong x value of the secound point of PDFRect.
After rebuild with the right methode, now the function Annot.SetRect() works fine!

Thank you very much for try helping!

Daniel
Reply all
Reply to author
Forward
0 new messages