Exemplo n.º 1
0
        private static void CreatePolylineAnnotations(PdfFixedDocument document, PdfFont font)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

            page.Graphics.DrawString("Polyline annotations", font, blackBrush, 50, 50);

            int[]  vertices = new int[] { 3, 4, 5, 6 };
            double centerY = 125, centerX = 150;
            double radius = 50;

            for (int i = 0; i < vertices.Length; i++)
            {
                PdfPoint[] points   = new PdfPoint[vertices[i]];
                double     angle    = 90;
                double     rotation = 360 / vertices[i];

                for (int j = 0; j < vertices[i]; j++)
                {
                    points[j]   = new PdfPoint();
                    points[j].X = centerX + radius * Math.Cos(Math.PI * angle / 180);
                    points[j].Y = centerY - radius * Math.Sin(Math.PI * angle / 180);
                    angle       = angle + rotation;
                }

                PdfPolylineAnnotation polyline = new PdfPolylineAnnotation();
                page.Annotations.Add(polyline);
                polyline.Author    = "Xfinium.Pdf";
                polyline.Contents  = "Polyline annotation with " + vertices[i] + " vertices.";
                polyline.Points    = points;
                polyline.LineColor = new PdfRgbColor(192, 0, 0);
                polyline.LineWidth = 3;

                centerY = centerY + 150;
            }
        }
Exemplo n.º 2
0
        private static void CreatePolylineAnnotations(PdfFixedDocument document, PdfFont font)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

            page.Graphics.DrawString("Polyline annotations", font, blackBrush, 50, 50);

            int[] vertices = new int[] { 3, 4, 5, 6 };
            double centerY = 125, centerX = 150;
            double radius = 50;

            for (int i = 0; i < vertices.Length; i++)
            {
                PdfPoint[] points = new PdfPoint[vertices[i]];
                double angle = 90;
                double rotation = 360 / vertices[i];

                for (int j = 0; j < vertices[i]; j++)
                {
                    points[j] = new PdfPoint();
                    points[j].X = centerX + radius * Math.Cos(Math.PI * angle / 180);
                    points[j].Y = centerY - radius * Math.Sin(Math.PI * angle / 180);
                    angle = angle + rotation;
                }

                PdfPolylineAnnotation polyline = new PdfPolylineAnnotation();
                page.Annotations.Add(polyline);
                polyline.Author = "Xfinium.Pdf";
                polyline.Contents = "Polyline annotation with " + vertices[i] + " vertices.";
                polyline.Points = points;
                polyline.LineColor = new PdfRgbColor(192, 0, 0);
                polyline.LineWidth = 3;

                centerY = centerY + 150;
            }
        }