private float AddRubberStampAnnotation(PdfPageBase page, float y)
        {
            PdfTrueTypeFont font   = new PdfTrueTypeFont(new Font("Arial", 12f));
            PdfStringFormat format = new PdfStringFormat();

            format.MeasureTrailingSpaces = true;
            String prompt = "Markup incorrect spelling: ";
            SizeF  size   = font.MeasureString(prompt, format);

            page.Canvas.DrawString(prompt, font, PdfBrushes.DodgerBlue, 0, y);
            float x = size.Width;

            String label = "demo of annotation";

            page.Canvas.DrawString(label, font, PdfBrushes.OrangeRed, x, y);
            x = x + font.MeasureString(label, format).Width;
            String markupText = "Just a draft, not checked.";

            size = font.MeasureString(markupText);
            PdfRubberStampAnnotation annotation
                = new PdfRubberStampAnnotation(new RectangleF(x, y, font.Height, font.Height), markupText);

            annotation.Icon  = PdfRubberStampAnnotationIcon.Draft;
            annotation.Color = Color.Plum;
            (page as PdfNewPage).Annotations.Add(annotation);
            y = y + size.Height;

            return(y);
        }
        public static void Third()
        {
            // Create a so called rubber stamp annotation. I'm not sure if it is useful, but at least
            // it looks impressive...
            PdfRubberStampAnnotation rsAnnot = new PdfRubberStampAnnotation();

            rsAnnot.Icon  = PdfRubberStampAnnotationIcon.TopSecret;
            rsAnnot.Flags = PdfAnnotationFlags.ReadOnly;



            using (PdfDocument document = new PdfDocument())
            {
                PdfPage page = document.AddPage();
                page.Width  = XUnit.FromMillimeter(80).Point;
                page.Height = XUnit.FromMillimeter(800).Point;


                using (XGraphics gfx = XGraphics.FromPdfPage(page))
                {
                    XRect rect = gfx.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 400), new XSize(350, 150)));
                    rsAnnot.Rectangle = new PdfRectangle(rect);


                    // Add the rubber stamp annotation to the page
                    page.Annotations.Add(rsAnnot);
                }
            }
        } // End Sub Third
        private void button1_Click(object sender, EventArgs e)
        {
            //Load a pdf document
            string      input    = "..\\..\\..\\..\\..\\..\\Data\\AddImageStamp.pdf";
            PdfDocument document = new PdfDocument();

            document.LoadFromFile(input);
            //Get the first page
            PdfPageBase page = document.Pages[0];

            //Create a rubber stamp annotation
            PdfRubberStampAnnotation loStamp = new PdfRubberStampAnnotation(new RectangleF(new PointF(0, 0), new SizeF(60, 60)));

            //Create an instance of PdfAppearance
            PdfAppearance loApprearance = new PdfAppearance(loStamp);
            PdfImage      image         = PdfImage.FromFile("..\\..\\..\\..\\..\\..\\..\\Data\\image stamp.jpg");
            PdfTemplate   template      = new PdfTemplate(210, 210);

            //Draw a pdf image into pdf template
            template.Graphics.DrawImage(image, 60, 60);
            loApprearance.Normal = template;
            loStamp.Appearance   = loApprearance;

            //Add the rubber stamp annotation into pdf
            page.AnnotationsWidget.Add(loStamp);

            string output = "AddImageStamp.pdf";

            //Save pdf document
            document.SaveToFile(output);

            //Launch the file
            PDFDocumentViewer(output);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Load a pdf document
            string input = "..\\..\\..\\..\\..\\..\\Data\\AddTextStamp.pdf";

            //Open a pdf document
            PdfDocument document = new PdfDocument();

            document.LoadFromFile(input);
            //Get the first page
            PdfPageBase page = document.Pages[0];

            //Create a pdf template
            PdfTemplate     template     = new PdfTemplate(125, 55);
            PdfTrueTypeFont font1        = new PdfTrueTypeFont(new Font("Elephant", 10f, FontStyle.Italic), true);
            PdfSolidBrush   brush        = new PdfSolidBrush(Color.DarkRed);
            PdfPen          pen          = new PdfPen(brush);
            RectangleF      rectangle    = new RectangleF(new PointF(5, 5), template.Size);
            int             CornerRadius = 20;
            PdfPath         path         = new PdfPath();

            path.AddArc(template.GetBounds().X, template.GetBounds().Y, CornerRadius, CornerRadius, 180, 90);
            path.AddArc(template.GetBounds().X + template.Width - CornerRadius, template.GetBounds().Y, CornerRadius, CornerRadius, 270, 90);
            path.AddArc(template.GetBounds().X + template.Width - CornerRadius, template.GetBounds().Y + template.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
            path.AddArc(template.GetBounds().X, template.GetBounds().Y + template.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
            path.AddLine(template.GetBounds().X, template.GetBounds().Y + template.Height - CornerRadius, template.GetBounds().X, template.GetBounds().Y + CornerRadius / 2);
            template.Graphics.DrawPath(pen, path);

            //Draw stamp text
            String s1 = "REVISED\n";
            String s2 = "by E-iceblue at " + DateTime.Now.ToString("MM dd, yyyy");

            template.Graphics.DrawString(s1, font1, brush, new PointF(5, 10));
            PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("Lucida Sans Unicode", 9f, FontStyle.Bold), true);

            template.Graphics.DrawString(s2, font2, brush, new PointF(2, 30));

            //Create a rubber stamp
            PdfRubberStampAnnotation stamp       = new PdfRubberStampAnnotation(rectangle);
            PdfAppearance            apprearance = new PdfAppearance(stamp);

            apprearance.Normal = template;
            stamp.Appearance   = apprearance;

            //Draw stamp into page
            page.AnnotationsWidget.Add(stamp);

            string output = "AddTextStamp.pdf";

            //Save pdf document
            document.SaveToFile(output);

            //Launch the file
            PDFDocumentViewer(output);
        }
示例#5
0
        private void button1_Click(object sender, EventArgs e)
        {
            //pdf file
            string input = "..\\..\\..\\..\\..\\..\\..\\Data\\Sample5.pdf";

            //open a pdf document
            PdfDocument document = new PdfDocument(input);

            //get the first page
            PdfPageBase page = document.Pages[0];

            //create a pdf template
            PdfTemplate     template     = new PdfTemplate(200, 50);
            PdfTrueTypeFont font1        = new PdfTrueTypeFont(new Font("Elephant", 16f, FontStyle.Italic), true);
            PdfSolidBrush   brush        = new PdfSolidBrush(Color.DarkRed);
            PdfPen          pen          = new PdfPen(brush);
            RectangleF      rectangle    = new RectangleF(new PointF(0, 0), template.Size);
            int             CornerRadius = 20;
            PdfPath         path         = new PdfPath();

            path.AddArc(template.GetBounds().X, template.GetBounds().Y, CornerRadius, CornerRadius, 180, 90);
            path.AddArc(template.GetBounds().X + template.Width - CornerRadius, template.GetBounds().Y, CornerRadius, CornerRadius, 270, 90);
            path.AddArc(template.GetBounds().X + template.Width - CornerRadius, template.GetBounds().Y + template.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
            path.AddArc(template.GetBounds().X, template.GetBounds().Y + template.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
            path.AddLine(template.GetBounds().X, template.GetBounds().Y + template.Height - CornerRadius, template.GetBounds().X, template.GetBounds().Y + CornerRadius / 2);
            template.Graphics.DrawPath(pen, path);

            //draw stamp text
            String s1 = "REVISED\n";
            String s2 = "By Jack at " + DateTime.Now.ToString("HH:mm, MM dd, yyyy");

            template.Graphics.DrawString(s1, font1, brush, new PointF(5, 5));
            PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("Gadugi", 12f, FontStyle.Bold), true);

            template.Graphics.DrawString(s2, font2, brush, new PointF(2, 28));

            //create a rubber stamp
            PdfRubberStampAnnotation stamp       = new PdfRubberStampAnnotation(rectangle);
            PdfAppearance            apprearance = new PdfAppearance(stamp);

            apprearance.Normal = template;
            stamp.Appearance   = apprearance;

            //draw stamp into page
            page.AnnotationsWidget.Add(stamp);

            string output = "AddTextStamp.pdf";

            //save pdf document
            document.SaveToFile(output);

            //Launching the Pdf file
            PDFDocumentViewer(output);
        }
示例#6
0
        public static void AddAnnotationToPDF()
        {
            // Create a new PDF document.
            PdfDocument document = new PdfDocument();

            // Create a page.
            PdfPage page = document.AddPage();

            // Get current page graphics
            XGraphics g = XGraphics.FromPdfPage(page);

            // Create a PDF text annotation.
            PdfTextAnnotation textAnnot = new PdfTextAnnotation();

            textAnnot.Title    = "Title sample";
            textAnnot.Subject  = "Subject sample";
            textAnnot.Contents = "This is the first line of annotation.\rThis is the 2nd line.";
            textAnnot.Icon     = PdfTextAnnotationIcon.Comment;

            // Convert rectangle from world space to page space(visual to graphics drawing). This is necessary because
            // the annotation is placed relative to the bottom left corner of the page with units measured in point.
            XRect rect = g.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 60), new XSize(50, 50)));

            textAnnot.Rectangle = new PdfRectangle(rect);

            // Add the annotation to the page
            page.Annotations.Add(textAnnot);


            // Create a PDF rubber stamp annotation.
            PdfRubberStampAnnotation rsAnnot = new PdfRubberStampAnnotation();

            rsAnnot.Icon = PdfRubberStampAnnotationIcon.Approved;

            rect = g.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 200), new XSize(300, 150)));
            rsAnnot.Rectangle = new PdfRectangle(rect);

            // Add the rubber stamp annotation to the page.
            page.Annotations.Add(rsAnnot);


            // Create a PDF link annotation
            rect = g.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 400), new XSize(300, 150)));
            PdfLinkAnnotation linkAnnot = PdfLinkAnnotation.CreateWebLink(new PdfRectangle(rect), "http://www.xspdf.com");

            page.Annotations.Add(linkAnnot);


            // Save and show the document
            document.Save("Annotations.pdf");
            Process.Start("Annotations.pdf");
        }
示例#7
0
        private static void CreateRubberStampAnnotations(PdfFixedDocument document, PdfFont font)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

            string[] rubberStampAnnotationNames = new string[]
            {
                "Approved", "AsIs", "Confidential", "Departmental", "Draft", "Experimental", "Expired", "Final",
                "ForComment", "ForPublicRelease", "NotApproved", "NotForPublicRelease", "Sold", "TopSecret"
            };

            page.Graphics.DrawString("Rubber stamp annotations", font, blackBrush, 50, 50);
            for (int i = 0; i < rubberStampAnnotationNames.Length; i++)
            {
                PdfRubberStampAnnotation rsa = new PdfRubberStampAnnotation();
                rsa.Author    = "Xfinium.Pdf";
                rsa.Contents  = "I am a " + rubberStampAnnotationNames[i] + " rubber stamp annotation.";
                rsa.StampName = rubberStampAnnotationNames[i];
                page.Annotations.Add(rsa);
                rsa.VisualRectangle = new PdfVisualRectangle(50, 70 + 50 * i, 200, 40);
                page.Graphics.DrawString(rubberStampAnnotationNames[i], font, blackBrush, 270, 85 + 50 * i);
            }

            page.Graphics.DrawString("Stamp annotations with custom appearance", font, blackBrush, 350, 50);
            PdfRubberStampAnnotation customRubberStampAnnotation = new PdfRubberStampAnnotation();

            customRubberStampAnnotation.Contents  = "Rubber stamp annotation with custom appearance.";
            customRubberStampAnnotation.StampName = "Custom";
            page.Annotations.Add(customRubberStampAnnotation);
            customRubberStampAnnotation.VisualRectangle = new PdfVisualRectangle(350, 70, 200, 40);

            PdfAnnotationAppearance customAppearance = new PdfAnnotationAppearance(50, 50);
            PdfPen redPen  = new PdfPen(new PdfRgbColor(255, 0, 0), 10);
            PdfPen bluePen = new PdfPen(new PdfRgbColor(0, 0, 192), 10);

            customAppearance.Graphics.DrawRectangle(redPen, 5, 5, 40, 40);
            customAppearance.Graphics.DrawLine(bluePen, 0, 0, customAppearance.Width, customAppearance.Height);
            customAppearance.Graphics.DrawLine(bluePen, 0, customAppearance.Height, customAppearance.Width, 0);
            customAppearance.Graphics.CompressAndClose();
            customRubberStampAnnotation.NormalAppearance = customAppearance;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Load a Pdf document from disk
            PdfDocument document = new PdfDocument();

            document.LoadFromFile("../../../../../../Data/PDFTemplate_N.pdf");

            //Get the first page
            PdfPageBase page = document.Pages[0];

            //Set the font and brush
            PdfTrueTypeFont font  = new PdfTrueTypeFont(new Font("Arial", 12f, FontStyle.Regular), true);
            PdfSolidBrush   brush = new PdfSolidBrush(Color.Blue);

            //Time text
            String timeString = DateTime.Now.ToString("MM/dd/yy hh:mm:ss tt ");

            //Create a template and rectangle, draw the string
            PdfTemplate template = new PdfTemplate(140, 15);
            RectangleF  rect     = new RectangleF(new PointF(page.ActualSize.Width - template.Width - 10, page.ActualSize.Height - template.Height - 10), template.Size);

            template.Graphics.DrawString(timeString, font, brush, new PointF(0, 0));

            //Create stamp annoation
            PdfRubberStampAnnotation stamp       = new PdfRubberStampAnnotation(rect);
            PdfAppearance            apprearance = new PdfAppearance(stamp);

            apprearance.Normal = template;
            stamp.Appearance   = apprearance;
            page.AnnotationsWidget.Add(stamp);

            //Sabe the document
            string output = "AddDateTimeStamp_result.pdf";

            document.SaveToFile(output, FileFormat.PDF);

            PDFDocumentViewer(output);
        }
示例#9
0
        private void button1_Click(object sender, EventArgs e)
        {
            PdfDocument doc = new PdfDocument();

            doc.LoadFromFile(@"D:\DQ\Spire.Pdf.DEMO\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\FromIMG.pdf");

            PdfRubberStampAnnotation loStamp       = new PdfRubberStampAnnotation(new RectangleF(new PointF(0, 0), new SizeF(160, 160)));
            PdfAppearance            loApprearance = new PdfAppearance(loStamp);
            PdfImage image = PdfImage.FromFile(@"D:\\1.png");

            PdfTemplate template = new PdfTemplate(160, 160);

            template.Graphics.DrawImage(image, 0, 0);
            loApprearance.Normal = template;
            loStamp.Appearance   = loApprearance;
            foreach (PdfPageBase page in doc.Pages)
            {
                page.AnnotationsWidget.Add(loStamp);
            }
            string output = "ImageStamp.pdf";

            doc.SaveToFile(output);
        }
示例#10
0
        // This sample shows how to create annotations.
        protected override void DoWork()
        {
            // Create a new PDF document
            PdfDocument document = new PdfDocument();

            // Create a font
            XFont font = new XFont("Verdana", 14);

            // Create a page
            PdfPage   page = document.AddPage();
            XGraphics gfx  = XGraphics.FromPdfPage(page);

            // Create a PDF text annotation
            PdfTextAnnotation textAnnot = new PdfTextAnnotation();

            textAnnot.Title    = "This is the title";
            textAnnot.Subject  = "This is the subject";
            textAnnot.Contents = "This is the contents of the annotation.\rThis is the 2nd line.";
            textAnnot.Icon     = PdfTextAnnotationIcon.Note;

            gfx.DrawString("The first text annotation", font, XBrushes.Black, 30, 50, XStringFormats.Default);

            // Convert rectangle form world space to page space. This is necessary because the annotation is
            // placed relative to the bottom left corner of the page with units measured in point.
            XRect rect = gfx.Transformer.WorldToDefaultPage(new XRect(new XPoint(30, 60), new XSize(30, 30)));

            textAnnot.Rectangle = new PdfRectangle(rect);

            // Add the annotation to the page
            page.Annotations.Add(textAnnot);

            // Create another PDF text annotation which is open and transparent
            textAnnot          = new PdfTextAnnotation();
            textAnnot.Title    = "Annotation 2 (title)";
            textAnnot.Subject  = "Annotation 2 (subject)";
            textAnnot.Contents = "This is the contents of the 2nd annotation.";
            textAnnot.Icon     = PdfTextAnnotationIcon.Help;
            textAnnot.Color    = XColors.LimeGreen;
            textAnnot.Opacity  = 0.5;
            textAnnot.Open     = true;

            gfx.DrawString("The second text annotation (opened)", font, XBrushes.Black, 30, 140, XStringFormats.Default);

            rect = gfx.Transformer.WorldToDefaultPage(new XRect(new XPoint(30, 150), new XSize(30, 30)));
            textAnnot.Rectangle = new PdfRectangle(rect);

            // Add the 2nd annotation to the page
            page.Annotations.Add(textAnnot);


            // Create a so called rubber stamp annotion. I'm not sure if it is useful, but at least
            // it looks impressive...
            PdfRubberStampAnnotation rsAnnot = new PdfRubberStampAnnotation();

            rsAnnot.Icon  = PdfRubberStampAnnotationIcon.TopSecret;
            rsAnnot.Flags = PdfAnnotationFlags.ReadOnly;

            rect = gfx.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 400), new XSize(350, 150)));
            rsAnnot.Rectangle = new PdfRectangle(rect);

            // Add the rubber stamp annotation to the page
            page.Annotations.Add(rsAnnot);

            // PDF supports some more pretty types of annotations like PdfLineAnnotation, PdfSquareAnnotation,
            // PdfCircleAnnotation, PdfMarkupAnnotation (with the subtypes PdfHighlightAnnotation, PdfUnderlineAnnotation,
            // PdfStrikeOutAnnotation, and PdfSquigglyAnnotation), PdfSoundAnnotation, or PdfMovieAnnotation.
            // If you need one of them, feel encouraged to implement it. It is quite easy.

            // Save the document...
            const string filename = "AltData/PDFsharp/PDFs/Annotations_tempfile.pdf";

            document.Save(filename);
            // ...and start a viewer.
            Diagnostics.ProcessHelper.Start(filename);
        }
示例#11
0
        private static void CreateRubberStampAnnotations(PdfFixedDocument document, PdfFont font)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

            string[] rubberStampAnnotationNames = new string[]
                {
                    "Approved", "AsIs", "Confidential", "Departmental", "Draft", "Experimental", "Expired", "Final",
                    "ForComment", "ForPublicRelease", "NotApproved", "NotForPublicRelease", "Sold", "TopSecret"
                };

            page.Graphics.DrawString("Rubber stamp annotations", font, blackBrush, 50, 50);
            for (int i = 0; i < rubberStampAnnotationNames.Length; i++)
            {
                PdfRubberStampAnnotation rsa = new PdfRubberStampAnnotation();
                rsa.Author = "Xfinium.Pdf";
                rsa.Contents = "I am a " + rubberStampAnnotationNames[i] + " rubber stamp annotation.";
                rsa.StampName = rubberStampAnnotationNames[i];
                page.Annotations.Add(rsa);
                rsa.VisualRectangle = new PdfVisualRectangle(50, 70 + 50 * i, 200, 40);
                page.Graphics.DrawString(rubberStampAnnotationNames[i], font, blackBrush, 270, 85 + 50 * i);
            }

            page.Graphics.DrawString("Stamp annotations with custom appearance", font, blackBrush, 350, 50);
            PdfRubberStampAnnotation customRubberStampAnnotation = new PdfRubberStampAnnotation();
            customRubberStampAnnotation.Contents = "Rubber stamp annotation with custom appearance.";
            customRubberStampAnnotation.StampName = "Custom";
            page.Annotations.Add(customRubberStampAnnotation);
            customRubberStampAnnotation.VisualRectangle = new PdfVisualRectangle(350, 70, 200, 40);

            PdfAnnotationAppearance customAppearance = new PdfAnnotationAppearance(50, 50);
            PdfPen redPen = new PdfPen(new PdfRgbColor(255, 0, 0), 10);
            PdfPen bluePen = new PdfPen(new PdfRgbColor(0, 0, 192), 10);
            customAppearance.Graphics.DrawRectangle(redPen, 5, 5, 40, 40);
            customAppearance.Graphics.DrawLine(bluePen, 0, 0, customAppearance.Width, customAppearance.Height);
            customAppearance.Graphics.DrawLine(bluePen, 0, customAppearance.Height, customAppearance.Width, 0);
            customAppearance.Graphics.CompressAndClose();
            customRubberStampAnnotation.NormalAppearance = customAppearance;
        }
示例#12
0
        public ActionResult AnnotationFlatten(string InsideBrowser, string checkboxFlatten)
        {
            //Creates a new PDF document.
            PdfDocument document = new PdfDocument();

            //Creates a new page
            PdfPage page = document.Pages.Add();

            document.PageSettings.SetMargins(0);

            RectangleF bounds = new RectangleF(350, 50, 80, 80);
            PdfFont    font   = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
            PdfBrush   brush  = new PdfSolidBrush(System.Drawing.Color.Black);

            //Creates a new Circle annotation.
            PdfCircleAnnotation circleannotation = new PdfCircleAnnotation(bounds);

            circleannotation.InnerColor      = new PdfColor(Color.Yellow);
            circleannotation.Color           = new PdfColor(Color.Red);
            circleannotation.AnnotationFlags = PdfAnnotationFlags.Default;
            circleannotation.Author          = "Syncfusion";
            circleannotation.Subject         = "CircleAnnotation";
            circleannotation.ModifiedDate    = new DateTime(2015, 1, 18);
            page.Annotations.Add(circleannotation);
            page.Graphics.DrawString("Circle Annotation", font, brush, new PointF(350, 10));

            //Creates a new Ellipse annotation.
            PdfEllipseAnnotation ellipseannotation = new PdfEllipseAnnotation(new RectangleF(30, 30, 50, 100), "Ellipse Annotation");

            ellipseannotation.Color      = new PdfColor(Color.Red);
            ellipseannotation.InnerColor = new PdfColor(Color.Yellow);
            page.Graphics.DrawString("Ellipse Annotation", font, brush, new PointF(30, 10));
            page.Annotations.Add(ellipseannotation);

            //Creates a new Square annotation.
            PdfSquareAnnotation squareannotation = new PdfSquareAnnotation(new RectangleF(30, 200, 80, 80));

            squareannotation.Text       = "SquareAnnotation";
            squareannotation.InnerColor = new PdfColor(Color.Red);
            squareannotation.Color      = new PdfColor(Color.Yellow);
            page.Graphics.DrawString("Square Annotation", font, brush, new PointF(30, 180));
            page.Annotations.Add(squareannotation);

            //Creates a new Rectangle annotation.
            RectangleF             rectannot           = new RectangleF(350, 220, 100, 50);
            PdfRectangleAnnotation rectangleannotation = new PdfRectangleAnnotation(rectannot, "RectangleAnnotation");

            rectangleannotation.InnerColor = new PdfColor(Color.Red);
            rectangleannotation.Color      = new PdfColor(Color.Yellow);
            page.Graphics.DrawString("Rectangle Annotation", font, brush, new PointF(350, 180));
            page.Annotations.Add(rectangleannotation);

            //Creates a new Line annotation.
            int[]             points         = new int[] { 400, 450, 550, 450 };
            PdfLineAnnotation lineAnnotation = new PdfLineAnnotation(points, "Line Annoation is the one of the annotation type...");

            lineAnnotation.Author       = "Syncfusion";
            lineAnnotation.Subject      = "LineAnnotation";
            lineAnnotation.ModifiedDate = new DateTime(2015, 1, 18);
            lineAnnotation.Text         = "PdfLineAnnotation";
            lineAnnotation.BackColor    = new PdfColor(Color.Red);
            page.Graphics.DrawString("Line Annotation", font, brush, new PointF(400, 320));
            page.Annotations.Add(lineAnnotation);

            //Creates a new Polygon annotation.
            int[] polypoints = new int[] { 50, 398, 100, 425, 200, 455, 300, 330, 180, 330 };
            PdfPolygonAnnotation polygonannotation = new PdfPolygonAnnotation(polypoints, "PolygonAnnotation");

            polygonannotation.Bounds = new RectangleF(30, 350, 300, 200);
            PdfPen pen = new PdfPen(Color.Red);

            polygonannotation.Text       = "polygon";
            polygonannotation.Color      = new PdfColor(Color.Red);
            polygonannotation.InnerColor = new PdfColor(Color.LightPink);
            page.Graphics.DrawString("Polygon Annotation", font, brush, new PointF(50, 320));
            page.Annotations.Add(polygonannotation);

            //Creates a new Freetext annotation.
            RectangleF            freetextrect = new RectangleF(405, 525, 80, 30);
            PdfFreeTextAnnotation freeText     = new PdfFreeTextAnnotation(freetextrect);

            freeText.MarkupText      = "Free Text with Callouts";
            freeText.TextMarkupColor = new PdfColor(Color.Green);
            freeText.Font            = new PdfStandardFont(PdfFontFamily.Helvetica, 7f);
            freeText.BorderColor     = new PdfColor(Color.Blue);
            freeText.Border          = new PdfAnnotationBorder(.5f);
            freeText.AnnotationFlags = PdfAnnotationFlags.Default;
            freeText.Text            = "Free Text";
            freeText.Color           = new PdfColor(Color.Yellow);
            PointF[] Freetextpoints = { new PointF(365, 580), new PointF(379, 534), new PointF(405, 534) };
            freeText.CalloutLines = Freetextpoints;
            page.Graphics.DrawString("FreeText Annotation", font, brush, new PointF(400, 510));
            page.Annotations.Add(freeText);

            //Creates a new TextMarkup annotation.
            string     s = "This is TextMarkup annotation!!!";
            RectangleF Textmarkuprect = new RectangleF(30, 540, 200, 20);

            page.Graphics.DrawString(s, font, brush, new PointF(30, 540));
            PdfTextMarkupAnnotation textannot = new PdfTextMarkupAnnotation("sample", "Highlight", s, new PointF(70, 580), font);

            textannot.Author                   = "Annotation";
            textannot.Opacity                  = 1.0f;
            textannot.Subject                  = "pdftextmarkupannotation";
            textannot.ModifiedDate             = new DateTime(2015, 1, 18);
            textannot.TextMarkupAnnotationType = PdfTextMarkupAnnotationType.StrikeOut;
            textannot.TextMarkupColor          = new PdfColor(Color.Yellow);
            textannot.InnerColor               = new PdfColor(Color.Red);
            textannot.Color = new PdfColor(Color.Yellow);
            page.Graphics.DrawString("TextMarkup Annotation", font, brush, new PointF(30, 510));
            page.Annotations.Add(textannot);

            //Creates a new Ink annotation.
            List <float> linePoints = new List <float> {
                72.919f, 136.376f, 72.264f, 136.376f, 62.446f, 142.922f, 61.137f, 142.922f, 55.901f, 139.649f, 55.246f, 138.34f, 54.592f, 132.449f, 54.592f, 127.867f, 55.901f, 125.904f, 59.828f, 121.976f, 63.101f, 121.322f, 65.719f, 122.631f, 68.992f, 125.249f, 70.301f, 130.485f, 71.61f, 133.104f, 72.264f, 136.376f, 72.919f, 140.304f, 74.883f, 144.885f, 76.192f, 150.776f, 76.192f, 151.431f, 76.192f, 152.085f, 76.192f, 158.631f, 76.192f, 159.94f, 75.537f, 155.358f, 74.228f, 150.122f, 74.228f, 146.195f, 73.574f, 141.613f, 73.574f, 137.685f, 74.228f, 132.449f, 74.883f, 128.522f, 75.537f, 124.594f, 76.192f, 123.285f, 76.846f, 122.631f, 80.774f, 122.631f, 82.737f, 123.285f, 85.355f, 125.249f, 88.628f, 129.831f, 89.283f, 133.104f, 89.937f, 137.031f, 90.592f, 140.958f, 89.937f, 142.267f, 86.665f, 141.613f, 85.355f, 140.304f, 84.701f, 138.34f, 84.701f, 137.685f, 85.355f, 137.031f, 87.974f, 135.722f, 90.592f, 136.376f, 92.555f, 137.031f, 96.483f, 139.649f, 98.446f, 140.958f, 101.719f, 142.922f, 103.028f, 142.922f, 100.41f, 138.34f, 99.756f, 134.413f, 99.101f, 131.14f, 99.101f, 128.522f, 99.756f, 127.213f, 101.065f, 125.904f, 102.374f, 123.94f, 103.683f, 123.94f, 107.61f, 125.904f, 110.228f, 129.831f, 114.156f, 135.067f, 117.428f, 140.304f, 119.392f, 143.576f, 121.356f, 144.231f, 122.665f, 144.231f, 123.974f, 142.267f, 126.592f, 139.649f, 127.247f, 140.304f, 126.592f, 142.922f, 124.628f, 143.576f, 122.01f, 142.922f, 118.083f, 141.613f, 114.81f, 136.376f, 114.81f, 131.14f, 113.501f, 127.213f, 114.156f, 125.904f, 118.083f, 125.904f, 120.701f, 126.558f, 123.319f, 130.485f, 125.283f, 136.376f, 125.937f, 140.304f, 125.937f, 142.922f, 126.592f, 143.576f, 125.937f, 135.722f, 125.937f, 131.794f, 125.937f, 131.14f, 127.247f, 129.176f, 129.21f, 127.213f, 131.828f, 127.213f, 134.447f, 128.522f, 136.41f, 136.376f, 139.028f, 150.122f, 141.647f, 162.558f, 140.992f, 163.213f, 138.374f, 160.595f, 135.756f, 153.395f, 135.101f, 148.158f, 134.447f, 140.304f, 134.447f, 130.485f, 133.792f, 124.594f, 133.792f, 115.431f, 133.792f, 110.194f, 133.792f, 105.612f, 134.447f, 105.612f, 137.065f, 110.194f, 137.719f, 116.74f, 139.028f, 120.013f, 139.028f, 123.94f, 137.719f, 127.213f, 135.756f, 130.485f, 134.447f, 130.485f, 133.792f, 130.485f, 137.719f, 131.794f, 141.647f, 135.722f, 146.883f, 142.922f, 152.774f, 153.395f, 153.428f, 159.286f, 150.156f, 159.94f, 147.537f, 156.667f, 146.883f, 148.813f, 146.883f, 140.958f, 146.883f, 134.413f, 146.883f, 125.904f, 145.574f, 118.703f, 145.574f, 114.776f, 145.574f, 112.158f, 146.228f, 111.503f, 147.537f, 111.503f, 148.192f, 112.158f, 150.156f, 112.812f, 150.81f, 113.467f, 152.119f, 114.776f, 154.083f, 117.394f, 155.392f, 119.358f, 156.701f, 120.667f, 157.356f, 121.976f, 156.701f, 121.322f, 156.047f, 120.013f, 155.392f, 119.358f, 154.083f, 117.394f, 154.083f, 116.74f, 152.774f, 114.776f, 152.119f, 114.121f, 150.81f, 113.467f, 149.501f, 113.467f, 147.537f, 112.158f, 146.883f, 112.158f, 145.574f, 111.503f, 144.919f, 112.158f, 144.265f, 114.121f, 144.265f, 115.431f, 144.265f, 116.74f, 144.265f, 117.394f, 144.265f, 118.049f, 144.919f, 118.703f, 145.574f, 120.667f, 146.228f, 122.631f, 147.537f, 123.285f, 147.537f, 124.594f, 148.192f, 125.904f, 147.537f, 128.522f, 147.537f, 129.176f, 147.537f, 130.485f, 147.537f, 132.449f, 147.537f, 134.413f, 147.537f, 136.376f, 147.537f, 138.34f, 147.537f, 138.994f, 145.574f, 138.994f, 142.956f, 138.252f
            };
            RectangleF       rectangle     = new RectangleF(30, 580, 300, 400);
            PdfInkAnnotation inkAnnotation = new PdfInkAnnotation(rectangle, linePoints);

            inkAnnotation.Bounds = rectangle;
            inkAnnotation.Color  = new PdfColor(Color.Red);
            page.Graphics.DrawString("Ink Annotation", font, brush, new PointF(30, 610));
            page.Annotations.Add(inkAnnotation);

            //Creates a new popup annotation.
            RectangleF         popupRect       = new RectangleF(430, 670, 30, 30);
            PdfPopupAnnotation popupAnnotation = new PdfPopupAnnotation();

            popupAnnotation.Border.Width            = 4;
            popupAnnotation.Border.HorizontalRadius = 20;
            popupAnnotation.Border.VerticalRadius   = 30;
            popupAnnotation.Opacity    = 1;
            popupAnnotation.Open       = true;
            popupAnnotation.Text       = "Popup Annotation";
            popupAnnotation.Color      = Color.Green;
            popupAnnotation.InnerColor = Color.Blue;
            popupAnnotation.Bounds     = popupRect;
            if (checkboxFlatten == "Flatten")
            {
                popupAnnotation.FlattenPopUps = true;
                popupAnnotation.Flatten       = true;
            }
            page.Graphics.DrawString("Popup Annotation", font, brush, new PointF(400, 610));
            page.Annotations.Add(popupAnnotation);

            page = document.Pages.Add();

            //Creates a new Rubberstamp measurement annotation.
            rectangle = new RectangleF(10, 40, 200, 50);
            PdfRubberStampAnnotation rubberStampAnnotation = new PdfRubberStampAnnotation(rectangle, " Approved Rubber Stamp Annotation");

            rubberStampAnnotation.Icon    = PdfRubberStampAnnotationIcon.Approved;
            rubberStampAnnotation.Author  = "Syncfusion";
            rubberStampAnnotation.Subject = "Rubber Stamp";
            rubberStampAnnotation.Color   = new PdfColor(System.Drawing.Color.Blue);
            page.Graphics.DrawString("Rubber Stamp Annotation", font, brush, new PointF(40, 10));
            if (checkboxFlatten == "Flatten")
            {
                rubberStampAnnotation.Flatten = true;
            }
            page.Annotations.Add(rubberStampAnnotation);

            //Creates a new Line measurement annotation.
            points = new int[] { 350, 750, 500, 750 };
            PdfLineMeasurementAnnotation lineMeasureAnnot = new PdfLineMeasurementAnnotation(points);

            lineMeasureAnnot.Author                 = "Syncfusion";
            lineMeasureAnnot.Subject                = "LineAnnotation";
            lineMeasureAnnot.ModifiedDate           = new DateTime(2015, 1, 18);
            lineMeasureAnnot.Unit                   = PdfMeasurementUnit.Inch;
            lineMeasureAnnot.lineBorder.BorderWidth = 2;
            lineMeasureAnnot.Font                   = new PdfStandardFont(PdfFontFamily.Helvetica, 10f, PdfFontStyle.Regular);
            lineMeasureAnnot.Color                  = new PdfColor(Color.Red);
            if (checkboxFlatten == "Flatten")
            {
                lineMeasureAnnot.Flatten = true;
            }
            page.Graphics.DrawString("Line Measurement Annotation", font, brush, new PointF(320, 10));
            page.Annotations.Add(lineMeasureAnnot);

            //Creates a new Freetext annotation.
            RectangleF            freetextrect0 = new RectangleF(80, 130, 100, 50);
            PdfFreeTextAnnotation freeText0     = new PdfFreeTextAnnotation(freetextrect0);

            freeText0.MarkupText      = "Free Text with Callouts";
            freeText0.TextMarkupColor = new PdfColor(Color.Green);
            freeText0.Font            = new PdfStandardFont(PdfFontFamily.Helvetica, 7f);
            freeText0.BorderColor     = new PdfColor(Color.Blue);
            freeText0.Border          = new PdfAnnotationBorder(.5f);
            freeText0.AnnotationFlags = PdfAnnotationFlags.Default;
            freeText0.Text            = "Free Text";
            freeText0.Rotate          = PdfAnnotationRotateAngle.RotateAngle90;
            freeText0.Color           = new PdfColor(Color.Yellow);
            PointF[] Freetextpoints0 = { new PointF(45, 190), new PointF(60, 145), new PointF(80, 145) };
            freeText0.CalloutLines = Freetextpoints0;
            page.Graphics.DrawString("Rotated FreeText Annotation", font, brush, new PointF(40, 110));
            if (checkboxFlatten == "Flatten")
            {
                freeText0.Flatten = true;
            }
            page.Annotations.Add(freeText0);

            MemoryStream SourceStream = new MemoryStream();

            document.Save(SourceStream);
            document.Close(true);

            //Creates a new Loaded document.
            PdfLoadedDocument lDoc  = new PdfLoadedDocument(SourceStream);
            PdfLoadedPage     lpage = lDoc.Pages[0] as PdfLoadedPage;

            if (checkboxFlatten == "Flatten")
            {
                lpage.Annotations.Flatten = true;
            }

            //Save to disk
            if (InsideBrowser == "Browser")
            {
                return(lDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Open));
            }
            else
            {
                return(lDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
        }