Beispiel #1
0
        public void TestInkAnnotation()
        {
            Document document = new Document();

            document.Pages.Add(new Page(PaperFormat.A4));

            Random  rnd  = new Random();
            InkList list = new InkList();

            PointF[] f = new PointF[5];
            for (int j = 0; j < 5; ++j)
            {
                int min = rnd.Next(100);
                int max = rnd.Next(100, 600);
                for (int i = 0; i < f.Length; ++i)
                {
                    f[i].X = rnd.Next(min, max);
                    f[i].Y = rnd.Next(min, max);
                }
                list.AddArray(new PointsArray(f));
            }
            InkAnnotation annot = new InkAnnotation(list);

            annot.Contents = "PDF ink annotation";
            annot.Color    = new ColorRGB(80, 80, 50);

            document.Pages[0].Annotations.Add(annot);
            document.Save(OutputFolder + @"\TestInkAnnotation.pdf");
            document.Dispose();

            //Process.Start("TestInkAnnotation.pdf");
        }
        public static void Run()
        {
            // ExStart:AddlnkAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            Document doc = new Document();
            Page pdfPage = doc.Pages.Add();
            System.Drawing.Rectangle drect = new System.Drawing.Rectangle();
            drect.Height = (int)pdfPage.Rect.Height;
            drect.Width = (int)pdfPage.Rect.Width;
            drect.X = 0;
            drect.Y = 0;
            Aspose.Pdf.Rectangle arect = Aspose.Pdf.Rectangle.FromRect(drect);
            ArrayList inkList = new ArrayList();
            Aspose.Pdf.Point[] arrpt = new Aspose.Pdf.Point[3];
            inkList.Add(arrpt);
            arrpt[0] = new Aspose.Pdf.Point(100, 800);
            arrpt[1] = new Aspose.Pdf.Point(200, 800);
            arrpt[2] = new Aspose.Pdf.Point(200, 700);
            InkAnnotation ia = new InkAnnotation(pdfPage, arect, inkList);
            ia.Title = "XXX";
            ia.Color = Aspose.Pdf.Color.LightBlue; // (GetColorFromString(stroke.InkColor));
            ia.CapStyle = CapStyle.Rounded;
            Border border = new Border(ia);
            border.Width = 25;
            ia.Opacity = 0.5;
            pdfPage.Annotations.Add(ia);

            dataDir = dataDir + "AddlnkAnnotation_out.pdf";
            // Save output file
            doc.Save(dataDir);
            // ExEnd:AddlnkAnnotation
            Console.WriteLine("\nlnk annotation added successfully.\nFile saved at " + dataDir);
        }
Beispiel #3
0
        private void ReadScribbles()
        {
            InkAnnotation ink = annotation as InkAnnotation;
            IList <IList <Datalogics.PDFL.Point> > scribbles = new List <IList <Datalogics.PDFL.Point> >();

            for (int i = 0; i < ink.NumScribbles; ++i)
            {
                scribbles.Add(ink.GetScribble(i));
            }
            properties.SetProperty <IList <IList <Datalogics.PDFL.Point> > >(AnnotationConsts.SCRIBBLES, scribbles, true);
        }
Beispiel #4
0
        private void WriteScribbles(IList <IList <Datalogics.PDFL.Point> > scribbles)
        {
            InkAnnotation ink = annotation as InkAnnotation;

            while (ink.NumScribbles > 0)
            {
                ink.RemoveScribble(0);
            }
            foreach (IList <Datalogics.PDFL.Point> scribble in scribbles)
            {
                ink.AddScribble(scribble);
            }
        }
        public static void Run()
        {
            // ExStart:lnkAnnotationLineWidth
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            Document doc = new Document();

            doc.Pages.Add();
            IList <Point[]> inkList  = new List <Point[]>();
            LineInfo        lineInfo = new LineInfo();

            lineInfo.VerticeCoordinate = new float[] { 55, 55, 70, 70, 70, 90, 150, 60 };
            lineInfo.Visibility        = true;
            lineInfo.LineColor         = System.Drawing.Color.Red;
            lineInfo.LineWidth         = 2;
            int length = lineInfo.VerticeCoordinate.Length / 2;

            Aspose.Pdf.Point[] gesture = new Aspose.Pdf.Point[length];
            for (int i = 0; i < length; i++)
            {
                gesture[i] = new Aspose.Pdf.Point(lineInfo.VerticeCoordinate[2 * i], lineInfo.VerticeCoordinate[2 * i + 1]);
            }

            inkList.Add(gesture);
            InkAnnotation a1 = new InkAnnotation(doc.Pages[1], new Aspose.Pdf.Rectangle(100, 100, 300, 300), inkList);

            a1.Subject = "Test";
            a1.Title   = "Title";
            a1.Color   = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);
            Border border = new Border(a1);

            border.Width  = 3;
            border.Effect = BorderEffect.Cloudy;
            border.Dash   = new Dash(1, 1);
            border.Style  = BorderStyle.Solid;
            doc.Pages[1].Annotations.Add(a1);

            dataDir = dataDir + "lnkAnnotationLineWidth_out.pdf";
            // Save output file
            doc.Save(dataDir);
            // ExEnd:lnkAnnotationLineWidth
            Console.WriteLine("\nlnk annotation line width setup successfully.\nFile saved at " + dataDir);
        }
Beispiel #6
0
        public void PutInkAnnotationExample()
        {
            //ExStart: PutInkAnnotationExample
            InkAnnotation annotation = new InkAnnotation()
            {
                Name  = "Example Ink Annotation Updated",
                Rect  = new Rectangle(101, 101, 201, 201),
                Flags = new List <AnnotationFlags> {
                    AnnotationFlags.Hidden, AnnotationFlags.NoView
                },
                HorizontalAlignment = HorizontalAlignment.Center,
                RichText            = "Rich Text Updated",
                Subject             = "Subj Updated",
                ZIndex  = 1,
                Title   = "Title Updated",
                InkList = new List <List <Point> >
                {
                    new List <Point>
                    {
                        new Point(10, 40),
                        new Point(30, 40)
                    },
                    new List <Point>
                    {
                        new Point(10, 20),
                        new Point(20, 20),
                        new Point(30, 20)
                    }
                },
                CapStyle = CapStyle.Rounded,
                Modified = "02/02/2018 00:00:00.000 AM"
            };

            var    lineResponse = api.GetDocumentInkAnnotations(Name, folder: FolderName);
            string annotationId = lineResponse.Annotations.List[0].Id;

            var response = api.PutInkAnnotation(Name, annotationId, annotation, folder: FolderName);

            Console.WriteLine(response);
            //ExEnd: PutInkAnnotationExample
        }
        public static void Run()
        {
            // ExStart:AddlnkAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            Document doc     = new Document();
            Page     pdfPage = doc.Pages.Add();

            System.Drawing.Rectangle drect = new System.Drawing.Rectangle();
            drect.Height = (int)pdfPage.Rect.Height;
            drect.Width  = (int)pdfPage.Rect.Width;
            drect.X      = 0;
            drect.Y      = 0;
            Aspose.Pdf.Rectangle arect   = Aspose.Pdf.Rectangle.FromRect(drect);
            IList <Point[]>      inkList = new List <Point[]>();

            Aspose.Pdf.Point[] arrpt = new Aspose.Pdf.Point[3];
            inkList.Add(arrpt);
            arrpt[0] = new Aspose.Pdf.Point(100, 800);
            arrpt[1] = new Aspose.Pdf.Point(200, 800);
            arrpt[2] = new Aspose.Pdf.Point(200, 700);
            InkAnnotation ia = new InkAnnotation(pdfPage, arect, inkList);

            ia.Title    = "XXX";
            ia.Color    = Aspose.Pdf.Color.LightBlue; // (GetColorFromString(stroke.InkColor));
            ia.CapStyle = CapStyle.Rounded;
            Border border = new Border(ia);

            border.Width = 25;
            ia.Opacity   = 0.5;
            pdfPage.Annotations.Add(ia);

            dataDir = dataDir + "AddlnkAnnotation_out.pdf";
            // Save output file
            doc.Save(dataDir);
            // ExEnd:AddlnkAnnotation
            Console.WriteLine("\nlnk annotation added successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:lnkAnnotationLineWidth
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            Document doc = new Document();
            doc.Pages.Add();
            ArrayList inkList = new ArrayList();
            LineInfo lineInfo = new LineInfo();
            lineInfo.VerticeCoordinate = new float[] { 55, 55, 70, 70, 70, 90, 150, 60 };
            lineInfo.Visibility = true;
            lineInfo.LineColor = System.Drawing.Color.Red;
            lineInfo.LineWidth = 2;
            int length = lineInfo.VerticeCoordinate.Length / 2;
            Aspose.Pdf.Point[] gesture = new Aspose.Pdf.Point[length];
            for (int i = 0; i < length; i++)
            {
               gesture[i] = new Aspose.Pdf.Point(lineInfo.VerticeCoordinate[2 * i], lineInfo.VerticeCoordinate[2 * i + 1]);
            }

            inkList.Add(gesture);
            InkAnnotation a1 = new InkAnnotation(doc.Pages[1], new Aspose.Pdf.Rectangle(100, 100, 300, 300), inkList);
            a1.Subject = "Test";
            a1.Title = "Title";
            a1.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);
            Border border = new Border(a1);
            border.Width = 3;
            border.Effect = BorderEffect.Cloudy;
            border.Dash = new Dash(1, 1);
            border.Style = BorderStyle.Solid;
            doc.Pages[1].Annotations.Add(a1);

            dataDir = dataDir + "lnkAnnotationLineWidth_out.pdf";
            // Save output file
            doc.Save(dataDir);
            // ExEnd:lnkAnnotationLineWidth
            Console.WriteLine("\nlnk annotation line width setup successfully.\nFile saved at " + dataDir);
        }
Beispiel #9
0
        public void PutInkAnnotationTest()
        {
            InkAnnotation annotation = new InkAnnotation()
            {
                Name  = "Test Ink Annotation Updated",
                Rect  = new Rectangle(101, 101, 201, 201),
                Flags = new List <AnnotationFlags> {
                    AnnotationFlags.Hidden, AnnotationFlags.NoView
                },
                HorizontalAlignment = HorizontalAlignment.Center,
                RichText            = "Rich Text Updated",
                Subject             = "Subj Updated",
                ZIndex  = 1,
                Title   = "Title Updated",
                InkList = new List <List <Point> >
                {
                    new List <Point>
                    {
                        new Point(10, 40),
                        new Point(30, 40)
                    },
                    new List <Point>
                    {
                        new Point(10, 20),
                        new Point(20, 20),
                        new Point(30, 20)
                    }
                },
                CapStyle = CapStyle.Rounded,
                Modified = "02/02/2018 00:00:00.000 AM"
            };

            var    lineResponse = PdfApi.GetDocumentInkAnnotations(Name, folder: TempFolder);
            string annotationId = lineResponse.Annotations.List[0].Id;

            var response = PdfApi.PutInkAnnotation(Name, annotationId, annotation, folder: TempFolder);

            Assert.That(response.Code, Is.EqualTo(201));
        }
Beispiel #10
0
        /**
         * Creates annotation, type of annotation is taken from given properties
         */
        public static Annotation CreateAnnotation(Document doc, Page page, int index, AnnotationProperties props)
        {
            Annotation ann      = null;
            int        addAfter = index - 1;

            switch (props.Subtype)
            {
            case "Line": ann = new LineAnnotation(page, props.BoundingRect, props.StartPoint, props.EndPoint, addAfter); break;

            case "Circle": ann = new CircleAnnotation(page, props.BoundingRect, addAfter); break;

            case "Square": ann = new SquareAnnotation(page, props.BoundingRect, addAfter); break;

            case "FreeText": ann = new FreeTextAnnotation(page, props.BoundingRect, "", addAfter); break;

            case "PolyLine": ann = new PolyLineAnnotation(page, props.BoundingRect, props.Vertices, addAfter); break;

            case "Polygon": ann = new PolygonAnnotation(page, props.BoundingRect, props.Vertices, addAfter); break;

            case "Link": ann = new LinkAnnotation(page, props.BoundingRect, addAfter); break;

            case "Ink": ann = new InkAnnotation(page, props.BoundingRect, addAfter); break;

            case "Underline": ann = new UnderlineAnnotation(page, addAfter, props.Quads); break;

            case "Highlight": ann = new HighlightAnnotation(page, addAfter, props.Quads); break;

            default: throw new Exception("Logic error");
            }
            AnnotationAppearance app = new AnnotationAppearance(doc, ann);

            app.CaptureAnnotation();
            app.Properties.SetFrom(props);
            app.Properties.Dirty = true;
            app.UpdateAppearance();
            app.ReleaseAnnotation();
            return(ann);
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("InkAnnotations Sample:");
            using (Library lib = new Library())
            {
                Console.WriteLine("Initialized the library.");

                // Create a new document and blank first page
                Document doc  = new Document();
                Rect     rect = new Rect(0, 0, 612, 792);
                Page     page = doc.CreatePage(Document.BeforeFirstPage, rect);
                Console.WriteLine("Created new document and first page.");

                // Create and add a new InkAnnotation to the 0th element of first page's annotation array
                InkAnnotation inkAnnot = new InkAnnotation(page, rect, -1);
                Console.WriteLine("Created new InkAnnotation as 0th element of annotation array.");

                // Ask how many scribbles are in the ink annotation
                Console.WriteLine("Number of scribbles in ink annotation: " + inkAnnot.NumScribbles);

                // Create a vector of scribble vertices
                List <Point> scribble = new List <Point>();
                Point        p        = new Point(100, 100);
                scribble.Add(p);
                p = new Point(200, 300);
                scribble.Add(p);
                p = new Point(400, 200);
                scribble.Add(p);
                Console.WriteLine("Created an array of scribble points.");

                // Add the scribble to the ink annotation
                inkAnnot.AddScribble(scribble);
                Console.WriteLine("Added the scribble to the ink annotation.");

                // Ask how many scribbles are in the ink annotation
                Console.WriteLine("Number of scribbles in ink annotation: " + inkAnnot.NumScribbles);

                // Create another vector of scribble vertices
                scribble = new List <Point>();
                p        = new Point(200, 200);
                scribble.Add(p);
                p = new Point(200, 300);
                scribble.Add(p);
                p = new Point(300, 300);
                scribble.Add(p);
                p = new Point(300, 200);
                scribble.Add(p);
                p = new Point(200, 100);
                scribble.Add(p);
                Console.WriteLine("Created another array of scribble points.");

                // Add the scribble to the ink annotation
                inkAnnot.AddScribble(scribble);
                Console.WriteLine("Added the scribble to the ink annotation.");

                // Create another vector of scribble vertices
                scribble = new List <Point>();
                p        = new Point(300, 400);
                scribble.Add(p);
                p = new Point(200, 300);
                scribble.Add(p);
                p = new Point(300, 300);
                scribble.Add(p);
                Console.WriteLine("Created another array of scribble points.");

                // Add the scribble to the ink annotation
                inkAnnot.AddScribble(scribble);
                Console.WriteLine("Added the scribble to the ink annotation.");

                // Ask how many scribbles are in the ink annotation
                Console.WriteLine("Number of scribbles in ink annotation: " + inkAnnot.NumScribbles);

                // Get and display the points in ink annotation 0
                IList <Point> scribbleToGet = inkAnnot.GetScribble(0);
                for (int i = 0; i < scribbleToGet.Count; i++)
                {
                    Console.WriteLine("Scribble 0, point" + i + " :" + scribbleToGet[i]);
                }

                // Get and display the points in ink annotation 1
                scribbleToGet = new List <Point>();
                scribbleToGet = inkAnnot.GetScribble(1);
                for (int i = 0; i < scribbleToGet.Count; i++)
                {
                    Console.WriteLine("Scribble 1, point" + i + " :" + scribbleToGet[i]);
                }

                // Let's set the color and then ask the ink annotation to generate an appearance stream
                Color color = new Color(0.5, 0.3, 0.8);
                inkAnnot.Color = color;
                Console.WriteLine("Set the stroke color.");
                Form form = inkAnnot.GenerateAppearance();
                inkAnnot.NormalAppearance = form;
                Console.WriteLine("Generated the appearance stream.");

                // Update the page's content and save the file with clipping
                page.UpdateContent();
                doc.Save(SaveFlags.Full, "InkAnnotations-out1.pdf");
                Console.WriteLine("Saved InkAnnotations-out1.pdf");

                // Remove 0th scribble
                inkAnnot.RemoveScribble(0);
                // Ask how many scribbles are in the ink annotation
                Console.WriteLine("Number of scribbles in ink annotation: " + inkAnnot.NumScribbles);

                // Generate a new appearance stream, since we have removed the first scribble.
                inkAnnot.NormalAppearance = inkAnnot.GenerateAppearance();

                // Update the page's content and save the file with clipping
                page.UpdateContent();
                doc.Save(SaveFlags.Full, "InkAnnotations-out2.pdf");

                // Kill the doc object
                doc.Dispose();
                Console.WriteLine("Killed document object.");
            }
        }
Beispiel #12
0
        public int CreatePDF(Stream stream)
        {
            var doc  = new GcPdfDocument();
            var page = doc.NewPage();
            // User name for the annotation's author:
            var user1 = "Jaime Smith";

            var rc = Common.Util.AddNote(
                "This sample creates an ink annotation and shows how to use the InkAnnotation.Paths property " +
                "to render the annotation's content. The content is specified by discrete points that should be " +
                "connected when a PDF viewer renders them. The points can be connected either by straight or " +
                "curved lines depending on the viewer implementation.",
                page);

            var inkAnnot = new InkAnnotation()
            {
                UserName  = user1,
                Rect      = new RectangleF(rc.Left, rc.Bottom + 20, 72 * 5, 72 * 2),
                LineWidth = 2,
                Color     = Color.DarkBlue,
                Contents  = "This is an ink annotation drawn via InkAnnotation.Paths."
            };
            float x0 = 80, x = 80, y = rc.Bottom + 24, h = 18, dx = 2, dy = 4, dx2 = 4, w = 10, xoff = 15;

            // Scribble 'ink annotation' text:

            // i
            inkAnnot.Paths.Add(new[] { new PointF(x + w / 2, y), new PointF(x + w / 2, y + h), new PointF(x + w, y + h * .7f) });
            inkAnnot.Paths.Add(new[] { new PointF(x + w / 2 - dx, y - h / 3 + dy), new PointF(x + w / 2 + dx, y - h / 3) });
            // n
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x, y), new PointF(x, y + h), new PointF(x, y + h - dy), new PointF(x + w * 0.7f, y),
                                       new PointF(x + w - dx / 2, y + h * .6f), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h * .7f) });
            // k
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x, y - h / 3), new PointF(x, y + h) });
            inkAnnot.Paths.Add(new[] { new PointF(x + w, y), new PointF(x + dx, y + h / 2 - dy), new PointF(x, y + h / 2),
                                       new PointF(x + dx2, y + h / 2 + dy), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h * .7f) });

            // a
            x += xoff * 2;
            inkAnnot.Paths.Add(new[] { new PointF(x + w, y + dy), new PointF(x + w / 2, y), new PointF(x, y + h / 2), new PointF(x + w / 2, y + h),
                                       new PointF(x + w, y + dy), new PointF(x + w, y), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h * .7f) });
            // n
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x, y), new PointF(x, y + h), new PointF(x, y + h - dy), new PointF(x + w * 0.7f, y),
                                       new PointF(x + w - dx / 2, y + h * .6f), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h * .7f) });
            // n
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x, y), new PointF(x, y + h), new PointF(x, y + h - dy), new PointF(x + w * 0.7f, y),
                                       new PointF(x + w - dx / 2, y + h * .6f), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h * .7f) });
            // o
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x + w / 2, y), new PointF(x + w / 2 - dx, y), new PointF(x, y + h / 2), new PointF(x + w / 2, y + h),
                                       new PointF(x + w, y + h / 2), new PointF(x + w / 2 + dx, y), new PointF(x + w / 2, y) });
            // t
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x + w / 2, y - h / 3), new PointF(x + w / 2, y + h), new PointF(x + w, y + h * .7f) });
            inkAnnot.Paths.Add(new[] { new PointF(x, y), new PointF(x + w, y) });
            // a
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x + w, y + dy), new PointF(x + w / 2, y), new PointF(x, y + h / 2), new PointF(x + w / 2, y + h),
                                       new PointF(x + w, y + dy), new PointF(x + w, y), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h * .7f) });
            // t
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x + w / 2, y - h / 3), new PointF(x + w / 2, y + h), new PointF(x + w, y + h * .7f) });
            inkAnnot.Paths.Add(new[] { new PointF(x, y), new PointF(x + w, y) });
            // i
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x + w / 2, y), new PointF(x + w / 2, y + h), new PointF(x + w, y + h * .7f) });
            inkAnnot.Paths.Add(new[] { new PointF(x + w / 2 - dx, y - h / 3 + dy), new PointF(x + w / 2 + dx, y - h / 3) });
            // o
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x + w / 2, y), new PointF(x + w / 2 - dx, y), new PointF(x, y + h / 2),
                                       new PointF(x + w / 2, y + h), new PointF(x + w, y + h / 2), new PointF(x + w / 2 + dx, y), new PointF(x + w / 2, y) });
            // n
            x += xoff;
            inkAnnot.Paths.Add(new[] { new PointF(x, y), new PointF(x, y + h), new PointF(x, y + h - dy), new PointF(x + w * 0.7f, y),
                                       new PointF(x + w - dx / 2, y + h * .6f), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h * .7f),
                                       new PointF(x + w * 3, y + h * .4f), new PointF(x + w + dx2, y + h + dy * 2), new PointF(x0, y + h + dy) });

            page.Annotations.Add(inkAnnot);

            // Done:
            doc.Save(stream);
            return(doc.Pages.Count);
        }
Beispiel #13
0
        private void parseAnnotations()
        {
            for (int i = 0; i < _array.Count; ++i)
            {
                PDFDictionary annotDict = _array[i] as PDFDictionary;
                if (annotDict != null)
                {
                    if (annotDict["IRT"] == null)
                    {
                        PDFName subtype = annotDict["Subtype"] as PDFName;
                        if (subtype != null)
                        {
                            Annotation annot = null;
                            switch (subtype.GetValue())
                            {
                            case "Text":
                                annot = new TextAnnotation(annotDict, _owner);
                                break;

                            case "Link":
                                annot = new LinkAnnotation(annotDict, _owner);
                                break;

                            case "FreeText":
                                annot = new FreeTextAnnotation(annotDict, _owner);
                                break;

                            case "Line":
                                annot = new LineAnnotation(annotDict, _owner);
                                break;

                            case "Square":
                                annot = new SquareAnnotation(annotDict, _owner);
                                break;

                            case "Circle":
                                annot = new CircleAnnotation(annotDict, _owner);
                                break;

                            case "Polygon":
                                annot = new PolygonAnnotation(annotDict, _owner);
                                break;

                            case "PolyLine":
                                annot = new PolylineAnnotation(annotDict, _owner);
                                break;

                            case "Highlight":
                                annot = new HighlightAnnotation(annotDict, _owner);
                                break;

                            case "Underline":
                                annot = new UnderlineAnnotation(annotDict, _owner);
                                break;

                            case "Squiggly":
                                annot = new SquigglyAnnotation(annotDict, _owner);
                                break;

                            case "StrikeOut":
                                annot = new StrikeOutAnnotation(annotDict, _owner);
                                break;

                            case "Stamp":
                                annot = new RubberStampAnnotation(annotDict, _owner);
                                break;

                            case "Caret":
                                annot = new CaretAnnotation(annotDict, _owner);
                                break;

                            case "Ink":
                                annot = new InkAnnotation(annotDict, _owner);
                                break;

                            case "FileAttachment":
                                annot = new FileAttachmentAnnotation(annotDict, _owner);
                                break;

                            case "Sound":
                                annot = new SoundAnnotation(annotDict, _owner);
                                break;

                            case "Movie":
                                annot = new MovieAnnotation(annotDict, _owner);
                                break;

                            case "Screen":
                                annot = new ScreenAnnotation(annotDict, _owner);
                                break;

                            case "3D":
                                annot = new ThreeDAnnotation(annotDict, _owner);
                                break;

                            case "Widget":
                                PDFName ft = annotDict["FT"] as PDFName;
                                if (ft == null)
                                {
                                    PDFDictionary parent = annotDict["Parent"] as PDFDictionary;
                                    if (parent != null)
                                    {
                                        ft = parent["FT"] as PDFName;
                                    }
                                }

                                if (ft != null)
                                {
                                    switch (ft.GetValue())
                                    {
                                    case "Tx":
                                        annot = new EditBox(annotDict, _owner);
                                        break;

                                    case "Ch":
                                        uint flag = getFlag(annotDict);
                                        if ((flag >> 17) % 2 != 0)
                                        {
                                            annot = new ComboBox(annotDict, _owner);
                                        }
                                        else
                                        {
                                            annot = new ListBox(annotDict, _owner);
                                        }
                                        break;

                                    case "Btn":
                                        flag = getFlag(annotDict);
                                        if ((flag >> 16) % 2 != 0)
                                        {
                                            annot = new PushButton(annotDict, _owner);
                                        }
                                        else if ((flag >> 15) % 2 != 0)
                                        {
                                            annot = new RadioButton(annotDict, _owner);
                                        }
                                        else
                                        {
                                            annot = new CheckBox(annotDict, _owner);
                                        }
                                        break;
                                    }
                                }
                                break;
                            }

                            if (annot != null)
                            {
                                annot.SetPage(_page, false);
                                _annotations.Add(annot);
                            }
                        }
                    }
                }
            }
        }
Beispiel #14
0
        internal override Annotation Clone(IDocumentEssential owner, Page page)
        {
            if (Page == null)
            {
                InkList lst = InkList;

                ApplyOwner(owner);
                SetPage(page, true);

                for (int i = 0; i < lst.Count; ++i)
                {
                    PointF[] points = lst[i].ToArray();
                    lst[i].Clear();
                    lst[i].Page = page;
                    lst[i].AddRange(points);
                }
                lst.Page = page;

                return(this);
            }

            PDFDictionary res = AnnotationBase.Copy(Dictionary);

            MarkupAnnotationBase.CopyTo(Dictionary, res);

            PDFDictionary bs = Dictionary["BS"] as PDFDictionary;

            if (bs != null)
            {
                res.AddItem("BS", AnnotationBorderStyle.Copy(bs));
            }

            PDFArray inkList = Dictionary["InkList"] as PDFArray;

            if (inkList != null)
            {
                PDFArray newInkList = new PDFArray();
                for (int i = 0; i < inkList.Count; ++i)
                {
                    PDFArray points = inkList[i] as PDFArray;
                    if (points != null)
                    {
                        RectangleF oldRect;
                        if (Page == null)
                        {
                            oldRect = new RectangleF();
                        }
                        else
                        {
                            oldRect = Page.PageRect;
                        }

                        newInkList.AddItem(CloneUtility.CopyArrayCoordinates(points, oldRect, page.PageRect, Page == null));
                    }
                }
                res.AddItem("InkList", newInkList);
            }

            InkAnnotation annot = new InkAnnotation(res, owner);

            annot.SetPage(Page, false);
            annot.SetPage(page, true);
            return(annot);
        }