private void button1_Click(object sender, EventArgs e)
        {
            //Create a new PDF document.
            PdfDocument doc = new PdfDocument();

            //Load the file from disk.
            doc.LoadFromFile(@"..\..\..\..\..\..\Data\Template_Pdf_4.pdf");

            //Get the first page of PDF file.
            PdfPageBase page = doc.Pages[0];

            //Add a free text annotation to the page and set it invisible.
            RectangleF            rect = new RectangleF(100, 120, 150, 30);
            PdfFreeTextAnnotation FreetextAnnotation = new PdfFreeTextAnnotation(rect);

            FreetextAnnotation.Text = "Invisible Free Text Annotation";
            PdfFont             font   = new PdfFont(PdfFontFamily.TimesRoman, 10);
            PdfAnnotationBorder border = new PdfAnnotationBorder(1f);

            FreetextAnnotation.Font            = font;
            FreetextAnnotation.Border          = border;
            FreetextAnnotation.BorderColor     = Color.Purple;
            FreetextAnnotation.LineEndingStyle = PdfLineEndingStyle.Circle;
            FreetextAnnotation.Color           = Color.Green;
            FreetextAnnotation.Opacity         = 0.8f;
            //Invisible free text annotation.
            FreetextAnnotation.Flags = PdfAnnotationFlags.Print | PdfAnnotationFlags.NoView;
            page.AnnotationsWidget.Add(FreetextAnnotation);

            //Add a free text annotation show it on the page.
            rect = new RectangleF(100, 180, 150, 30);
            FreetextAnnotation                 = new PdfFreeTextAnnotation(rect);
            FreetextAnnotation.Text            = "Show Free Text Annotation";
            FreetextAnnotation.Font            = font;
            FreetextAnnotation.Border          = border;
            FreetextAnnotation.BorderColor     = Color.LightPink;
            FreetextAnnotation.LineEndingStyle = PdfLineEndingStyle.Circle;
            FreetextAnnotation.Color           = Color.LightGreen;
            FreetextAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(FreetextAnnotation);

            String result = "InvisibleFreeTextAnnotation_out.pdf";

            //Save the document
            doc.SaveToFile(result);
            //Launch the Pdf file
            PDFDocumentViewer(result);
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //create a pdf document
            PdfDocument doc = new PdfDocument();

            //add a new page
            PdfPageBase page = doc.Pages.Add();

            RectangleF rect = new RectangleF(0, 40, 100, 50);

            //add free text annotations
            PdfFreeTextAnnotation textAnnotation = new PdfFreeTextAnnotation(rect);

            textAnnotation.Text = "Spire.PDF";
            PdfAnnotationBorder border = new PdfAnnotationBorder(1f);
            PdfFont             font   = new PdfFont(PdfFontFamily.TimesRoman, 10);

            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.LightGreen;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.Circle;
            textAnnotation.Color           = Color.LightPink;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            rect                           = new RectangleF(50, 100, 150, 50);
            textAnnotation                 = new PdfFreeTextAnnotation(rect);
            textAnnotation.Text            = "Spire.Office";
            border                         = new PdfAnnotationBorder(1f);
            font                           = new PdfFont(PdfFontFamily.Courier, 10);
            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.Pink;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.RClosedArrow;
            textAnnotation.Color           = Color.LightGreen;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            string output = "AddFreeTextAnnotation.pdf";

            //Save pdf file.
            doc.SaveToFile(output);
            doc.Close();

            //Launching the Pdf file.
            PDFDocumentViewer(output);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a pdf document
            PdfDocument doc = new PdfDocument();

            doc.LoadFromFile(@"..\..\..\..\..\..\Data\AddFreeTextAnnotation.pdf");

            PdfPageBase page = doc.Pages[0];

            RectangleF rect = new RectangleF(0, 300, 100, 80);
            //Add free text annotation
            PdfFreeTextAnnotation textAnnotation = new PdfFreeTextAnnotation(rect);

            textAnnotation.Text = "\n  Spire.PDF";
            PdfAnnotationBorder border = new PdfAnnotationBorder(1f);
            PdfFont             font   = new PdfFont(PdfFontFamily.TimesRoman, 20);

            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.Gray;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.Slash;
            textAnnotation.Color           = Color.LightBlue;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            rect                           = new RectangleF(150, 200, 150, 40);
            textAnnotation                 = new PdfFreeTextAnnotation(rect);
            textAnnotation.Text            = "\nHigh Fidelity Pdf file Conversion";
            border                         = new PdfAnnotationBorder(1f);
            font                           = new PdfFont(PdfFontFamily.Helvetica, 10);
            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.LightGoldenrodYellow;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.RClosedArrow;
            textAnnotation.Color           = Color.LightPink;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            rect                           = new RectangleF(150, 280, 280, 40);
            textAnnotation                 = new PdfFreeTextAnnotation(rect);
            textAnnotation.Text            = "\nEasily Manipulate document and Form fields";
            border                         = new PdfAnnotationBorder(1f);
            font                           = new PdfFont(PdfFontFamily.Helvetica, 10);
            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.Gray;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.Circle;
            textAnnotation.Color           = Color.LightSkyBlue;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            rect                           = new RectangleF(150, 360, 200, 40);
            textAnnotation                 = new PdfFreeTextAnnotation(rect);
            textAnnotation.Text            = "\nSecurity features";
            border                         = new PdfAnnotationBorder(1f);
            font                           = new PdfFont(PdfFontFamily.Helvetica, 10);
            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.Pink;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.RClosedArrow;
            textAnnotation.Color           = Color.LightGreen;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            rect                           = new RectangleF(150, 440, 200, 40);
            textAnnotation                 = new PdfFreeTextAnnotation(rect);
            textAnnotation.Text            = "\nExtract data from Pdf documents";
            border                         = new PdfAnnotationBorder(1f);
            font                           = new PdfFont(PdfFontFamily.Helvetica, 10);
            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.OrangeRed;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.RClosedArrow;
            textAnnotation.Color           = Color.LightGoldenrodYellow;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            string output = "AddFreeTextAnnotation.pdf";

            //Save pdf file
            doc.SaveToFile(output);
            doc.Close();

            //Launch the Pdf file
            PDFDocumentViewer(output);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a new PDF document.
            PdfDocument doc = new PdfDocument();

            //Load the file from disk.
            doc.LoadFromFile(@"..\..\..\..\..\..\Data\Template_Pdf_4.pdf");

            //Get the first page of PDF file.
            PdfPageBase page = doc.Pages[0];

            //Initialize a PdfFreeTextAnnotation.
            RectangleF            rect           = new RectangleF(150, 120, 150, 30);
            PdfFreeTextAnnotation textAnnotation = new PdfFreeTextAnnotation(rect);

            //Specify content.
            textAnnotation.Text = "\nFree Text Annotation Formatting";
            //Set free text annotation formatting and add it to page.
            PdfFont             font   = new PdfFont(PdfFontFamily.TimesRoman, 10);
            PdfAnnotationBorder border = new PdfAnnotationBorder(1f);

            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.Purple;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.Circle;
            textAnnotation.Color           = Color.Green;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            rect                           = new RectangleF(150, 200, 150, 40);
            textAnnotation                 = new PdfFreeTextAnnotation(rect);
            textAnnotation.Text            = "\nFree Text Annotation Formatting";
            border                         = new PdfAnnotationBorder(1f);
            font                           = new PdfFont(PdfFontFamily.Helvetica, 10);
            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.LightGoldenrodYellow;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.RClosedArrow;
            textAnnotation.Color           = Color.LightPink;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            rect                           = new RectangleF(150, 280, 280, 40);
            textAnnotation                 = new PdfFreeTextAnnotation(rect);
            textAnnotation.Text            = "\noHow to Set Free Text Annotation Formatting in Pdf file";
            border                         = new PdfAnnotationBorder(1f);
            font                           = new PdfFont(PdfFontFamily.Helvetica, 10);
            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.Gray;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.Circle;
            textAnnotation.Color           = Color.LightSkyBlue;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            rect                           = new RectangleF(150, 360, 200, 40);
            textAnnotation                 = new PdfFreeTextAnnotation(rect);
            textAnnotation.Text            = "\nFree Text Annotation Formatting";
            border                         = new PdfAnnotationBorder(1f);
            font                           = new PdfFont(PdfFontFamily.Helvetica, 10);
            textAnnotation.Font            = font;
            textAnnotation.Border          = border;
            textAnnotation.BorderColor     = Color.Pink;
            textAnnotation.LineEndingStyle = PdfLineEndingStyle.RClosedArrow;
            textAnnotation.Color           = Color.LightGreen;
            textAnnotation.Opacity         = 0.8f;
            page.AnnotationsWidget.Add(textAnnotation);

            String result = "SetFreeTextAnnotationFormatting_out.pdf";

            //Save the document
            doc.SaveToFile(result);
            //Launch the Pdf file
            PDFDocumentViewer(result);
        }