Page 1 of 1

Draw line using“AddLineAnnotation()" method of GDPicture PDF

Posted: Fri Aug 03, 2012 11:59 am
by hardikv
Hi All,

i have one application into that i have displayed PDF file in GDViewer control.
i want to draw highlight line on pdf file using “AddLineAnnotation()" method of GDPicture PDF class when the user left clicks and then when they release the left click of mouse.
i know there is method available inside annotation class but i have no license of that. thats why i need same kind of functionality using "AddLineAnnotation()" method.

Below is Annotation class method to draw line on PDF file of GDViewer class

Code: Select all

GdViewer1.AddLineAnnotInteractive(Color.DarkViolet.ToArgb(),(float)0.1,(float)0.5);

but i had trid belwo code to do same thing via "AddLineAnnotation()" method of GDPicture PDF class but line is draw without opacity and i want to do same functionality like when mouse press and move then line should be display and when mouse release then line should be end.

but in below code it will work like when mouse press line is not displayed, it will display only after mouse release. also i need like if mouse if move up and down then line will also be move up and down.

Please help me to solve this problem, if possible then please provide me the example with code.

Code: Select all


private void GdViewer1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (isDrag == true)
                {
                    int a = 0, b = 0;
                    GdViewer1.CoordViewerToDocument(e.X, e.Y, ref a, ref b);
                    startPoint = new Point(a, b);

                    int docXPix = 0, docYPix = 0;
                    GdViewer1.CoordViewerToDocument(e.X, e.Y, ref docXPix, ref docYPix);

                     doXInches = docXPix / GdViewer1.HorizontalResolution;
                     doYInches = docYPix / GdViewer1.VerticalResolution;
                }
            }
        }

        private void GdViewer1_MouseUp(object sender, MouseEventArgs e)
        {

            if (isDrag == true)
            {
                int docXPix = 0, docYPix = 0;
                GdViewer1.CoordViewerToDocument(e.X, e.Y, ref docXPix, ref docYPix);

               double  doXInches1 = docXPix / GdViewer1.HorizontalResolution;
               double doYInches1 = docYPix / GdViewer1.VerticalResolution;

                obj.SelectPage(1);
            
                obj.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
                obj.SetOrigin(PdfOrigin.PdfOriginTopLeft);

                int annot = obj.AddLineAnnotation(
                (float) doXInches,
                (float)doYInches,
                (float)doXInches1,
                (float)doYInches1,
                "Demo",
                "",
                PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleNone,
                PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleNone,
                false,
                (float) 0.1,
                PdfAnnotationBorderStyle.PdfAnnotationBorderStyleSolid,
                0,
                0,
                (float)0.3,
                255,
                0,
                0);
                GdViewer1.Redraw();
                GdViewer1.Refresh();
                isDrag = false;
            }          
      }

Thanks

Re: Draw line using“AddLineAnnotation()" method of GDPicture

Posted: Sun Aug 05, 2012 10:29 am
by SamiKharma
Hi,

The opacity will show in the next minor release, for now it shows in Adobe Reader.
My advice to you is to purchase the annotations plugin, why:
Because what you are trying to do is implement an Annotations mechanism from scratch, basically you might as well be trying to implement Annotations using a drawing function.
In order to get what you want, your best option, if you do not want to implement an annotation mechanism from scratch is to go ahead and use the Annotations Plugin.

Best Regards,
Sami