Esempio n. 1
0
        /// <summary>
        /// Generates a PDF document that is encrypted using AES method.
        /// </summary>
        /// <param name="keySize">The encryption key size.</param>
        /// <param name="aes"></param>
        /// <returns></returns>
        private static PDFFixedDocument EncryptAES(int keySize, PDFAesSecurityHandler aes)
        {
            PDFFixedDocument doc = new PDFFixedDocument();

            aes.EnableContentExtractionForAccessibility = false;
            aes.EnableDocumentAssembly         = false;
            aes.EnableDocumentChange           = false;
            aes.EnableContentExtraction        = false;
            aes.EnableFormsFill                = false;
            aes.EnableAnnotationsAndFieldsEdit = false;
            aes.EnablePrint     = false;
            aes.EncryptMetadata = true;
            aes.KeySize         = keySize;
            aes.UserPassword    = "******";
            aes.OwnerPassword   = "******";

            PDFPage         page       = doc.Pages.Add();
            PDFStandardFont helvetica  = new PDFStandardFont(PDFStandardFontFace.HelveticaBoldItalic, 16);
            PDFBrush        blackBrush = new PDFBrush();

            string text = string.Format("Encryption: AES {0} bit", keySize);

            if ((aes.KeySize == 256) && aes.UseEnhancedPasswordValidation)
            {
                text = text + " with enhanced password validation (Acrobat X or later)";
            }
            page.Canvas.DrawString(text, helvetica, blackBrush, 50, 100);

            return(doc);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="page"></param>
        private static void DrawWatermarkWithTransparency(PDFPage page)
        {
            PDFBrush        redBrush  = new PDFBrush(new PDFRgbColor(192, 0, 0));
            PDFStandardFont helvetica = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 36);

            // The page graphics is located by default on top of existing page content.
            //page.SetGraphicsPosition(PDFPageGraphicsPosition.OverExistingPageContent);

            page.Canvas.SaveGraphicsState();

            PDFStringAppearanceOptions sao = new PDFStringAppearanceOptions();

            sao.Brush = redBrush;
            sao.Font  = helvetica;
            PDFStringLayoutOptions slo = new PDFStringLayoutOptions();

            slo.X        = 130;
            slo.Y        = 670;
            slo.Rotation = 60;

            // Draw the watermark over page content but setting the transparency to a value lower than 1.
            // The page content will be partially visible through the watermark.
            PDFExtendedGraphicState gs1 = new PDFExtendedGraphicState();

            gs1.FillAlpha = 0.3;
            page.Canvas.SetExtendedGraphicState(gs1);
            page.Canvas.DrawString("Sample watermark over page content", sao, slo);

            page.Canvas.RestoreGraphicsState();
        }
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run(Stream input)
        {
            PDFDocumentFeatures df = new PDFDocumentFeatures();

            // Do not load file attachments, new file attachments cannot be added.
            df.EnableDocumentFileAttachments = false;
            // Do not load form fields, form fields cannot be filled and new form fields cannot be added.
            df.EnableDocumentFormFields = false;
            // Do not load embedded JavaScript code, new JavaScript code at document level cannot be added.
            df.EnableDocumentJavaScriptFragments = false;
            // Do not load the named destinations, new named destinations cannot be created.
            df.EnableDocumentNamedDestinations = false;
            // Do not load the document outlines, new outlines cannot be created.
            df.EnableDocumentOutline = false;
            // Do not load annotations, new annotations cannot be added to existing pages.
            df.EnablePageAnnotations = false;
            // Do not load the page graphics, new graphics cannot be added to existing pages.
            df.EnablePageGraphics = false;
            PDFFixedDocument document = new PDFFixedDocument(input, df);

            PDFStandardFont helvetica = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 24);
            PDFBrush        brush     = new PDFBrush();

            // Add a new page with some content on it.
            PDFPage page = document.Pages.Add();

            page.Canvas.DrawString("New page added to an existing document.", helvetica, brush, 20, 50);

            // When document features have been specified at load time the document is automatically saved in incremental update mode.
            document.Save(input);

            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Draws content on a page using colors created from a calibrated ICC colorspace.
        /// </summary>
        /// <param name="page">The page to draw to.</param>
        private static void DrawICCColorSpace(PDFPage page)
        {
            PDFRgbColor black      = new PDFRgbColor(0, 0, 0);
            PDFBrush    blackBrush = new PDFBrush(black);
            //PDF4NET v5: PDFFont font = new PDFFont(PDFFontFace.Helvetica, 16);
            PDFStandardFont font = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);

            //PDF4NET v5: page.Canvas.DrawText("ICC colorspace", font, null, blackBrush, 50, 50);
            page.Canvas.DrawString("ICC colorspace", font, blackBrush, 50, 50);

            // Read the ICC profile from disk.
            FileStream fs = new FileStream("..\\..\\..\\..\\..\\SupportFiles\\rgb.icc", FileMode.Open, FileAccess.Read);

            byte[] profileData = new byte[fs.Length];
            fs.Read(profileData, 0, profileData.Length);
            fs.Close();

            //PDF4NET v5: PDFICCColorSpace iccCS = new PDFICCColorSpace();
            PDFIccColorSpace iccCS = new PDFIccColorSpace();

            iccCS.IccProfile = profileData;
            //PDF4NET v5: PDFICCColor red = new PDFICCColor(iccCS);
            PDFIccColor red = new PDFIccColor(iccCS);

            red.ColorComponents = new double[] { 192, 0, 0 };
            //PDF4NET v5: PDFICCColor blue = new PDFICCColor(iccCS);
            PDFIccColor blue = new PDFIccColor(iccCS);

            blue.ColorComponents = new double[] { 0, 0, 192 };
            PDFBrush blueBrush = new PDFBrush(blue);
            PDFPen   redPen    = new PDFPen(red, 5);

            page.Canvas.DrawRoundRectangle(redPen, blueBrush, 50, 100, 400, 150, 20, 20);
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="page"></param>
        private static void DrawWatermarkOverPageContent(PDFPage page)
        {
            PDFBrush        redBrush  = new PDFBrush(new PDFRgbColor(192, 0, 0));
            PDFStandardFont helvetica = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 32);

            // The page canvas is located by default on top of existing page content.
            //page.SetCanvasPosition(PDFPageCanvasPosition.OverExistingPageContent);

            // Draw the watermark over page content.
            // Page content under the watermark will be masked.
            page.Canvas.DrawString("Sample watermark over page content", helvetica, redBrush, 20, 335);

            page.Canvas.SaveGraphicsState();

            // Draw the watermark over page content but using the Multiply blend mode.
            // The watermak will appear as if drawn under the page content, useful when watermarking scanned documents.
            // If the watermark is drawn under page content for scanned documents, it will not be visible because the scanned image will block it.
            PDFExtendedGraphicState gs1 = new PDFExtendedGraphicState();

            gs1.BlendMode = PDFBlendMode.Multiply;
            page.Canvas.SetExtendedGraphicState(gs1);
            page.Canvas.DrawString("Sample watermark over page content", helvetica, redBrush, 20, 385);

            // Draw the watermark over page content but using the Luminosity blend mode.
            // Both the page content and the watermark will be visible.
            PDFExtendedGraphicState gs2 = new PDFExtendedGraphicState();

            gs2.BlendMode = PDFBlendMode.Luminosity;
            page.Canvas.SetExtendedGraphicState(gs2);
            page.Canvas.DrawString("Sample watermark over page content", helvetica, redBrush, 20, 435);

            page.Canvas.RestoreGraphicsState();
        }
Esempio n. 6
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run()
        {
            PDFFixedDocument document    = new PDFFixedDocument();
            PDFStandardFont  titleFont   = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 16);
            PDFStandardFont  barcodeFont = new PDFStandardFont(PDFStandardFontFace.Helvetica, 12);

            PDFPage page = document.Pages.Add();

            DrawGenericBarcodes(page, titleFont, barcodeFont);

            page = document.Pages.Add();
            DrawPharmaBarcodes(page, titleFont, barcodeFont);

            page = document.Pages.Add();
            DrawEanUpcBarcodes(page, titleFont, barcodeFont);

            page = document.Pages.Add();
            DrawPostAndTransportantionBarcodes(page, titleFont, barcodeFont);

            page = document.Pages.Add();
            Draw2DBarcodes(page, titleFont, barcodeFont);

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "barcodes.pdf") };
            return(output);
        }
Esempio n. 7
0
        /// <summary>
        /// Draws content on a page using colors created from a calibrated RGB colorspace.
        /// </summary>
        /// <param name="page">The page to draw to.</param>
        private static void DrawCalRgbColorSpace(PDFPage page)
        {
            PDFRgbColor black      = new PDFRgbColor(0, 0, 0);
            PDFBrush    blackBrush = new PDFBrush(black);
            //PDF4NET v5: PDFFont font = new PDFFont(PDFFontFace.Helvetica, 16);
            PDFStandardFont font = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);

            //PDF4NET v5: page.Canvas.DrawText("CalRGB colorspace", font, null, blackBrush, 50, 50);
            page.Canvas.DrawString("CalRGB colorspace", font, blackBrush, 50, 50);

            PDFCalRgbColorSpace calRgbCS = new PDFCalRgbColorSpace();
            PDFCalRgbColor      red      = new PDFCalRgbColor(calRgbCS);

            red.Red   = 1;
            red.Green = 0;
            red.Blue  = 0;
            PDFCalRgbColor blue = new PDFCalRgbColor(calRgbCS);

            blue.Red   = 0;
            blue.Green = 0;
            blue.Blue  = 1;
            PDFBrush blueBrush = new PDFBrush(blue);
            PDFPen   redPen    = new PDFPen(red, 5);

            page.Canvas.DrawRoundRectangle(redPen, blueBrush, 50, 100, 400, 150, 20, 20);
        }
Esempio n. 8
0
        /// <summary>
        /// Draws content on a page using colors created from a calibrated Lab colorspace.
        /// </summary>
        /// <param name="page">The page to draw to.</param>
        private static void DrawLabColorSpace(PDFPage page)
        {
            PDFRgbColor black      = new PDFRgbColor(0, 0, 0);
            PDFBrush    blackBrush = new PDFBrush(black);
            //PDF4NET v5: PDFFont font = new PDFFont(PDFFontFace.Helvetica, 16);
            PDFStandardFont font = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);

            //PDF4NET v5: page.Canvas.DrawText("L*a*b* colorspace", font, null, blackBrush, 50, 50);
            page.Canvas.DrawString("L*a*b* colorspace", font, blackBrush, 50, 50);

            PDFLabColorSpace labCS   = new PDFLabColorSpace();
            PDFLabColor      labClr1 = new PDFLabColor(labCS);

            labClr1.L = 90;
            labClr1.A = 20;
            labClr1.B = -10;
            PDFLabColor labClr2 = new PDFLabColor(labCS);

            labClr2.L = 10;
            labClr2.A = 70;
            labClr2.B = -50;
            PDFBrush brush = new PDFBrush(labClr1);
            PDFPen   pen   = new PDFPen(labClr2, 5);

            page.Canvas.DrawRoundRectangle(pen, brush, 50, 100, 400, 150, 20, 20);
        }
Esempio n. 9
0
        /// <summary>
        /// Draws content on a page using colors created from an indexed colorspace.
        /// </summary>
        /// <param name="page">The page to draw to.</param>
        private static void DrawIndexedColorSpace(PDFPage page)
        {
            PDFRgbColor black      = new PDFRgbColor(0, 0, 0);
            PDFBrush    blackBrush = new PDFBrush(black);
            //PDF4NET v5: PDFFont font = new PDFFont(PDFFontFace.Helvetica, 16);
            PDFStandardFont font = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);

            //PDF4NET v5: page.Canvas.DrawText("Indexed colorspace with 2 colors", font, null, blackBrush, 50, 50);
            page.Canvas.DrawString("Indexed colorspace with 2 colors", font, blackBrush, 50, 50);

            // Create an indexed colorspace with 2 RGB colors, 24bits (3*8bytes) per color.
            PDFIndexedColorSpace ixCS = new PDFIndexedColorSpace();

            //PDF4NET v5: ixCS.MaxIndex = 1;
            ixCS.ColorCount = 2;
            ixCS.ColorTable = new byte[] { 255, 0, 0, 192, 0, 255 };
            PDFIndexedColor red = new PDFIndexedColor(ixCS);

            red.ColorIndex = 0;
            PDFIndexedColor violet = new PDFIndexedColor(ixCS);

            violet.ColorIndex = 1;
            PDFBrush redBrush  = new PDFBrush(red);
            PDFPen   violetPen = new PDFPen(violet, 5);

            page.Canvas.DrawRoundRectangle(violetPen, redBrush, 50, 100, 400, 150, 20, 20);
        }
Esempio n. 10
0
        public static void Main(string[] args)
        {
            PDFFixedDocument document  = new PDFFixedDocument();
            PDFPage          page      = document.Pages.Add();
            PDFPen           pen       = new PDFPen(PDFRgbColor.Black, 1);
            PDFStandardFont  helvetica = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);

            PDFPoint[] points = new PDFPoint[] {
                new PDFPoint(50, 150), new PDFPoint(100, 200), new PDFPoint(150, 50), new PDFPoint(200, 150), new PDFPoint(250, 50)
            };
            DrawBezierConnectedLines(page, points, pen, 0, helvetica);

            page.Canvas.TranslateTransform(0, 200);
            DrawBezierConnectedLines(page, points, pen, 0.1, helvetica);

            page.Canvas.TranslateTransform(0, 200);
            DrawBezierConnectedLines(page, points, pen, 0.3, helvetica);

            page.Canvas.TranslateTransform(0, 200);
            DrawBezierConnectedLines(page, points, pen, 0.5, helvetica);

            using (FileStream output = File.Create("BezierConnectedLines.pdf"))
            {
                document.Save(output);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Extracts text fragments from the 3rd page and highlights the glyphs in the fragment.
        /// </summary>
        /// <param name="document"></param>
        private static void ExtractImagesAndHighlight(PDFFixedDocument document)
        {
            PDFPen                     pen       = new PDFPen(new PDFRgbColor(255, 0, 192), 0.5);
            PDFBrush                   brush     = new PDFBrush(new PDFRgbColor(0, 0, 0));
            PDFStandardFont            helvetica = new PDFStandardFont(PDFStandardFontFace.Helvetica, 8);
            PDFStringAppearanceOptions sao       = new PDFStringAppearanceOptions();

            sao.Brush = brush;
            sao.Font  = helvetica;
            PDFStringLayoutOptions slo = new PDFStringLayoutOptions();

            slo.Width = 1000;

            PDFContentExtractor      ce  = new PDFContentExtractor(document.Pages[2]);
            PDFVisualImageCollection eic = ce.ExtractImages(false);

            for (int i = 0; i < eic.Count; i++)
            {
                string imageProperties = string.Format("Image ID: {0}\nPixel width: {1} pixels\nPixel height: {2} pixels\n" +
                                                       "Display width: {3} points\nDisplay height: {4} points\nHorizonal Resolution: {5} dpi\nVertical Resolution: {6} dpi",
                                                       eic[i].ImageID, eic[i].Width, eic[i].Height, eic[i].DisplayWidth, eic[i].DisplayHeight, eic[i].DpiX, eic[i].DpiY);

                PDFPath boundingPath = new PDFPath();
                boundingPath.StartSubpath(eic[i].ImageCorners[0].X, eic[i].ImageCorners[0].Y);
                boundingPath.AddLineTo(eic[i].ImageCorners[1].X, eic[i].ImageCorners[1].Y);
                boundingPath.AddLineTo(eic[i].ImageCorners[2].X, eic[i].ImageCorners[2].Y);
                boundingPath.AddLineTo(eic[i].ImageCorners[3].X, eic[i].ImageCorners[3].Y);
                boundingPath.CloseSubpath();

                document.Pages[2].Canvas.DrawPath(pen, boundingPath);
                slo.X = eic[i].ImageCorners[3].X + 1;
                slo.Y = eic[i].ImageCorners[3].Y + 1;
                document.Pages[2].Canvas.DrawString(imageProperties, sao, slo);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run(Stream s1, Stream s2)
        {
            PDFFixedDocument document = new PDFFixedDocument();

            document.DisplayMode = PDFDisplayMode.UseAttachments;

            PDFStandardFont helvetica  = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);
            PDFBrush        blackBrush = new PDFBrush();
            PDFPage         page       = document.Pages.Add();

            page.Canvas.DrawString("This document contains 2 file attachments:", helvetica, blackBrush, 50, 50);
            page.Canvas.DrawString("1. fileattachments.cs.html", helvetica, blackBrush, 50, 70);
            page.Canvas.DrawString("2. fileattachments.vb.html", helvetica, blackBrush, 50, 90);

            byte[] fileData1 = new byte[s1.Length];
            s1.Read(fileData1, 0, fileData1.Length);
            PDFDocumentFileAttachment fileAttachment1 = new PDFDocumentFileAttachment();

            fileAttachment1.Payload     = fileData1;
            fileAttachment1.FileName    = "fileattachments.cs.html";
            fileAttachment1.Description = "C# Source Code for FileAttachments sample";
            document.FileAttachments.Add(fileAttachment1);

            byte[] fileData2 = new byte[s2.Length];
            s2.Read(fileData2, 0, fileData2.Length);
            PDFDocumentFileAttachment fileAttachment2 = new PDFDocumentFileAttachment();

            fileAttachment2.Payload     = fileData1;
            fileAttachment2.FileName    = "fileattachments.vb.html";
            fileAttachment2.Description = "VB.NET Source Code for FileAttachments sample";
            document.FileAttachments.Add(fileAttachment2);

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "fileattachments.pdf") };
            return(output);
        }
Esempio n. 13
0
        private static void DrawStandardFonts(PDFPage page)
        {
            PDFStandardFont titleFont  = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 22);
            PDFBrush        blackBrush = new PDFBrush(new PDFRgbColor());

            page.Canvas.DrawString("Standard fonts", titleFont, blackBrush, 20, 50);
            page.Canvas.DrawString("(Base 14 PDF fonts supported by any PDF viewer)", titleFont, blackBrush, 20, 75);

            PDFStandardFont helvetica = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);

            page.Canvas.DrawString("Helvetica - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", helvetica, blackBrush, 20, 125);

            PDFStandardFont helveticaBold = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 16);

            page.Canvas.DrawString("Helvetica Bold - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", helveticaBold, blackBrush, 20, 150);

            PDFStandardFont helveticaItalic = new PDFStandardFont(PDFStandardFontFace.HelveticaItalic, 16);

            page.Canvas.DrawString("Helvetica Italic - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", helveticaItalic, blackBrush, 20, 175);

            PDFStandardFont helveticaBoldItalic = new PDFStandardFont(PDFStandardFontFace.HelveticaBoldItalic, 16);

            page.Canvas.DrawString("Helvetica Bold Italic - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", helveticaBoldItalic, blackBrush, 20, 200);

            PDFStandardFont timesRoman = new PDFStandardFont(PDFStandardFontFace.TimesRoman, 16);

            page.Canvas.DrawString("Times Roman - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", timesRoman, blackBrush, 20, 225);

            PDFStandardFont timesRomanBold = new PDFStandardFont(PDFStandardFontFace.TimesRomanBold, 16);

            page.Canvas.DrawString("Times Roman Bold - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", timesRomanBold, blackBrush, 20, 250);

            PDFStandardFont timesRomanItalic = new PDFStandardFont(PDFStandardFontFace.TimesRomanItalic, 16);

            page.Canvas.DrawString("Times Roman Italic - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", timesRomanItalic, blackBrush, 20, 275);

            PDFStandardFont timesRomanBoldItalic = new PDFStandardFont(PDFStandardFontFace.TimesRomanBoldItalic, 16);

            page.Canvas.DrawString("Times Roman Bold Italic - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", timesRomanBoldItalic, blackBrush, 20, 300);

            PDFStandardFont courier = new PDFStandardFont(PDFStandardFontFace.Courier, 16);

            page.Canvas.DrawString("Courier - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", courier, blackBrush, 20, 325);

            PDFStandardFont courierBold = new PDFStandardFont(PDFStandardFontFace.CourierBold, 16);

            page.Canvas.DrawString("Courier Bold - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", courierBold, blackBrush, 20, 350);

            PDFStandardFont courierItalic = new PDFStandardFont(PDFStandardFontFace.CourierItalic, 16);

            page.Canvas.DrawString("Courier Italic - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", courierItalic, blackBrush, 20, 375);

            PDFStandardFont courierBoldItalic = new PDFStandardFont(PDFStandardFontFace.CourierBoldItalic, 16);

            page.Canvas.DrawString("Courier Bold Italic - Lorem ipsum dolor sit amet, consectetur adipiscing elit.", courierBoldItalic, blackBrush, 20, 400);
        }
Esempio n. 14
0
        /// <summary>
        /// Decrypts a PDF file
        /// </summary>
        /// <param name="input">Input stream.</param>
        /// <returns></returns>
        private static PDFFixedDocument Decrypt(Stream input)
        {
            PDFFixedDocument doc = new PDFFixedDocument(input, "pdf4net");

            PDFPage         page       = doc.Pages[0];
            PDFStandardFont helvetica  = new PDFStandardFont(PDFStandardFontFace.HelveticaBoldItalic, 16);
            PDFBrush        blackBrush = new PDFBrush();

            page.Canvas.DrawString("Decrypted document", helvetica, blackBrush, 5, 5);

            return(doc);
        }
Esempio n. 15
0
        /// <summary>
        /// Creates a PDF file that contains 2 file attachments.
        /// </summary>
        private static void CreateAttachments()
        {
            // Create the pdf document
            //PDF4NET v5: PDFDocument doc = new PDFDocument();
            PDFFixedDocument doc = new PDFFixedDocument();

            // Create a blank page
            //PDF4NET v5: PDFPage page = doc.AddPage();
            PDFPage page = doc.Pages.Add();
            // Print instructions about how to view the attachments in the PDF file.
            PDFBrush brush = new PDFBrush(new PDFRgbColor(0, 0, 0));
            //PDF4NET v5: PDFFont font = new PDFFont();
            PDFStandardFont font = new PDFStandardFont();

            //PDF4NET v5: page.Canvas.DrawText("This document contains 2 file attachments.", font, null, brush, 50, 50);
            page.Canvas.DrawString("This document contains 2 file attachments.", font, brush, 50, 50);
            //PDF4NET v5: page.Canvas.DrawText("In the Acrobat/Reader menu click on View > " +
            //PDF4NET v5:     "Navigation tabs > Attachments to view them.", font, null, brush, 50, 60);
            page.Canvas.DrawString("In the Acrobat/Reader menu click on View > " +
                                   "Navigation tabs > Attachments to view them.", font, brush, 50, 60);

            // Create an attachment for 'xfasampleform.pdf' file
            //PDF4NET v5: PDFDocumentAttachment attachment = new PDFDocumentAttachment();
            PDFDocumentFileAttachment attachment = new PDFDocumentFileAttachment();

            //PDF4NET v5: attachment.FileName = "..\\SupportFiles\\xfasampleform.pdf";
            attachment.FileName    = "sample.pdf";
            attachment.Payload     = File.ReadAllBytes("..\\..\\..\\..\\..\\SupportFiles\\sample.pdf");
            attachment.MimeType    = "application/pdf";
            attachment.Description = "Sample PDF file";
            // Add the attachment to document.
            //PDF4NET v5: doc.Attachments.Add(attachment);
            doc.FileAttachments.Add(attachment);

            // Create an attachment for 'auto1.jpg' file
            //PDF4NET v5: attachment = new PDFDocumentAttachment();
            attachment = new PDFDocumentFileAttachment();
            //PDF4NET v5: attachment.FileName = "..\\SupportFiles\\auto1.jpg";
            attachment.FileName    = "auto1.jpg";
            attachment.Payload     = File.ReadAllBytes("..\\..\\..\\..\\..\\SupportFiles\\auto1.jpg");
            attachment.MimeType    = "image/jpg";
            attachment.Description = "Lexus - Minority Report";
            // Add the attachment to document.
            doc.FileAttachments.Add(attachment);

            // Save the document to disk
            doc.Save("Sample_Attachments.pdf");
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            // Create the pdf document
            //PDF4NET v5: PDFDocument pdfDoc = new PDFDocument();
            PDFFixedDocument pdfDoc = new PDFFixedDocument();

            // Create first page
            //PDF4NET v5: PDFPage pdfPage1 = pdfDoc.AddPage();
            PDFPage pdfPage1 = pdfDoc.Pages.Add();

            // Create the graphic objects
            //PDF4NET v5: PDFFont fontText = new PDFFont(PDFFontFace.Helvetica, 12);
            PDFStandardFont fontText   = new PDFStandardFont(PDFStandardFontFace.Helvetica, 12);
            PDFBrush        blackBrush = new PDFBrush(new PDFRgbColor());

            Random rnd = new Random();

            for (int i = 0; i < 50; i++)
            {
                // Create random colors for drawing the spline
                PDFColor penColor = new PDFRgbColor((byte)rnd.Next(256),
                                                    (byte)rnd.Next(256), (byte)rnd.Next(256));

                // Create the pen to draw the border
                PDFPen randomPen = new PDFPen(penColor, 1);

                // Generate random control points
                float x1 = rnd.Next((int)pdfPage1.Width);
                float y1 = rnd.Next((int)pdfPage1.Height);
                float x2 = rnd.Next((int)pdfPage1.Width);
                float y2 = rnd.Next((int)pdfPage1.Height);
                float x3 = rnd.Next((int)pdfPage1.Width);
                float y3 = rnd.Next((int)pdfPage1.Height);
                float x4 = rnd.Next((int)pdfPage1.Width);
                float y4 = rnd.Next((int)pdfPage1.Height);

                // Draw the Bezier spline
                pdfPage1.Canvas.DrawBezier(randomPen, x1, y1, x2, y2, x3, y3, x4, y4);
            }

            // Draw a label
            //PDF4NET v5: pdfPage1.Canvas.DrawText("Random Bezier splines", fontText, null, blackBrush, 20, 20, 0, PDFTextAlign.TopLeft);
            pdfPage1.Canvas.DrawString("Random Bezier splines", fontText, blackBrush, 20, 20);

            // Save the document to disk
            pdfDoc.Save("Sample_Bezier.pdf");
        }
Esempio n. 17
0
        /// <summary>
        /// Draws content on a page using colors created from a separation colorspace.
        /// </summary>
        /// <param name="page">The page to draw to.</param>
        private static void DrawSeparationColorSpace(PDFPage page)
        {
            PDFRgbColor black      = new PDFRgbColor(0, 0, 0);
            PDFBrush    blackBrush = new PDFBrush(black);
            //PDF4NET v5: PDFFont font = new PDFFont(PDFFontFace.Helvetica, 16);
            PDFStandardFont font = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);

            //PDF4NET v5: page.Canvas.DrawText("Separation colorspace", font, null, blackBrush, 50, 50);
            page.Canvas.DrawString("Separation colorspace", font, blackBrush, 50, 50);

            //PDF4NET v5: PDFType2Function tintTransform = new PDFType2Function();
            PDFExponentialFunction tintTransform = new PDFExponentialFunction();

            tintTransform.C0       = new double[] { 0, 0, 0, 0 };
            tintTransform.C1       = new double[] { 0, 0.53f, 1, 0 };
            tintTransform.Exponent = 1;
            tintTransform.Domain   = new double[] { 0, 1 };
            tintTransform.Range    = new double[] { 0, 1, 0, 1, 0, 1, 0, 1 };
            PDFSeparationColorSpace separationCS = new PDFSeparationColorSpace();

            separationCS.Colorant      = "PANTONE Orange 021 C";
            separationCS.TintTransform = tintTransform;
            PDFSeparationColor orange = new PDFSeparationColor(separationCS);

            orange.Tint = 0.9;

            //PDF4NET v5: tintTransform = new PDFType2Function();
            tintTransform              = new PDFExponentialFunction();
            tintTransform.C0           = new double[] { 0, 0, 0, 0 };
            tintTransform.C1           = new double[] { 0, 0.75f, 0.9f, 0 };
            tintTransform.Exponent     = 1;
            tintTransform.Domain       = new double[] { 0, 1 };
            tintTransform.Range        = new double[] { 0, 1, 0, 1, 0, 1, 0, 1 };
            separationCS               = new PDFSeparationColorSpace();
            separationCS.Colorant      = "PANTONE Warm Red C";
            separationCS.TintTransform = tintTransform;
            PDFSeparationColor warmRed = new PDFSeparationColor(separationCS);

            warmRed.Tint = 0.4;

            PDFBrush orangeBrush = new PDFBrush(orange);
            PDFPen   warmRedPen  = new PDFPen(warmRed, 5);

            page.Canvas.DrawRoundRectangle(warmRedPen, orangeBrush, 50, 100, 400, 150, 20, 20);
        }
Esempio n. 18
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run()
        {
            PDFFixedDocument document      = new PDFFixedDocument();
            PDFStandardFont  helveticaBold = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 16);

            PDFPage page = document.Pages.Add();

            DrawTextLines(page, helveticaBold);

            page = document.Pages.Add();
            DrawTextWrap(page, helveticaBold);

            page = document.Pages.Add();
            DrawTextRenderingModes(page, helveticaBold);

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "text.pdf") };
            return(output);
        }
Esempio n. 19
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        /// <param name="imageStream"></param>
        /// <param name="cmykImageStream"></param>
        /// <param name="softMaskStream"></param>
        /// <param name="stencilMaskStream"></param>
        public static SampleOutputInfo[] Run(Stream imageStream, Stream cmykImageStream, Stream softMaskStream, Stream stencilMaskStream)
        {
            PDFFixedDocument document           = new PDFFixedDocument();
            PDFStandardFont  helveticaBoldTitle = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 16);
            PDFStandardFont  helveticaSection   = new PDFStandardFont(PDFStandardFontFace.Helvetica, 10);

            PDFPage page = document.Pages.Add();

            DrawImages(page, imageStream, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawImageMasks(page, imageStream, softMaskStream, stencilMaskStream, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawCmykTiff(page, cmykImageStream, helveticaBoldTitle);

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "images.pdf") };
            return(output);
        }
Esempio n. 20
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        /// <param name="iccStream"></param>
        public static SampleOutputInfo[] Run(Stream iccStream)
        {
            PDFFixedDocument document           = new PDFFixedDocument();
            PDFStandardFont  helveticaBoldTitle = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 16);
            PDFStandardFont  helveticaSection   = new PDFStandardFont(PDFStandardFontFace.Helvetica, 10);

            PDFPage page = document.Pages.Add();

            DrawLines(page, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawRectangles(page, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawRoundRectangles(page, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawEllipses(page, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawArcsAndPies(page, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawBezierCurves(page, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawAffineTransformations(page, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawColorsAndColorSpaces(page, helveticaBoldTitle, helveticaSection, iccStream);

            page = document.Pages.Add();
            DrawShadings(page, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawPatterns(page, helveticaBoldTitle, helveticaSection);

            page = document.Pages.Add();
            DrawFormXObjects(page, helveticaBoldTitle, helveticaSection);

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "vectorgraphics.pdf") };
            return(output);
        }
Esempio n. 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="page"></param>
        private static void DrawWatermarkUnderPageContent(PDFPage page)
        {
            PDFBrush        redBrush  = new PDFBrush(new PDFRgbColor(192, 0, 0));
            PDFStandardFont helvetica = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 36);

            // Set the page canvas to be located under existing page content.
            page.SetCanvasPosition(PDFPageCanvasPosition.UnderExistingPageContent);

            PDFStringAppearanceOptions sao = new PDFStringAppearanceOptions();

            sao.Brush = redBrush;
            sao.Font  = helvetica;
            PDFStringLayoutOptions slo = new PDFStringLayoutOptions();

            slo.X        = 130;
            slo.Y        = 670;
            slo.Rotation = 60;
            page.Canvas.DrawString("Sample watermark under page content", sao, slo);
        }
Esempio n. 22
0
        private static void CreateRedactionAnnotations(PDFFixedDocument document, PDFFont font, Stream flashStream)
        {
            PDFBrush blackBrush = new PDFBrush();

            PDFPage page = document.Pages.Add();

            page.Canvas.DrawString("Redaction annotations", font, blackBrush, 50, 50);

            PDFStandardFont helvetica = new PDFStandardFont(PDFStandardFontFace.Helvetica, 10);

            page.Canvas.DrawString(
                "Open the file with Adobe Acrobat, right click on the annotation and select \"Apply redactions\" The text under the annotation will be redacted.",
                helvetica, blackBrush, 50, 110);

            PDFFormXObject redactionAppearance = new PDFFormXObject(250, 150);

            redactionAppearance.Canvas.DrawRectangle(new PDFBrush(PDFRgbColor.LightGreen),
                                                     0, 0, redactionAppearance.Width, redactionAppearance.Height);
            PDFStringAppearanceOptions sao = new PDFStringAppearanceOptions();

            sao.Brush = new PDFBrush(PDFRgbColor.DarkRed);
            sao.Font  = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 32);
            PDFStringLayoutOptions slo = new PDFStringLayoutOptions();

            slo.Width           = redactionAppearance.Width;
            slo.Height          = redactionAppearance.Height;
            slo.X               = 0;
            slo.Y               = 0;
            slo.HorizontalAlign = PDFStringHorizontalAlign.Center;
            slo.VerticalAlign   = PDFStringVerticalAlign.Middle;
            redactionAppearance.Canvas.DrawString("This content has been redacted", sao, slo);

            PDFRedactionAnnotation redactionAnnotation = new PDFRedactionAnnotation();

            page.Annotations.Add(redactionAnnotation);
            redactionAnnotation.Author            = "PDF4NET";
            redactionAnnotation.BorderColor       = new PDFRgbColor(192, 0, 0);
            redactionAnnotation.BorderWidth       = 1;
            redactionAnnotation.OverlayAppearance = redactionAppearance;
            redactionAnnotation.DisplayRectangle  = new PDFDisplayRectangle(50, 100, 250, 150);
        }
Esempio n. 23
0
        private static void DisableTextCopy(PDFPage page, Stream ttfStream)
        {
            PDFStandardFont titleFont  = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 22);
            PDFBrush        blackBrush = new PDFBrush(new PDFRgbColor());

            page.Canvas.DrawString("Draw text that cannot be copied and", titleFont, blackBrush, 20, 50);
            page.Canvas.DrawString("pasted in another applications", titleFont, blackBrush, 20, 75);

            ttfStream.Position = 0;
            PDFUnicodeTrueTypeFont f1 = new PDFUnicodeTrueTypeFont(ttfStream, 16, true);

            page.Canvas.DrawString("This text can be copied and pasted", f1, blackBrush, 20, 150);
            page.Canvas.DrawString("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", f1, blackBrush, 20, 175);

            ttfStream.Position = 0;
            PDFUnicodeTrueTypeFont f2 = new PDFUnicodeTrueTypeFont(ttfStream, 16, true);

            f2.EnableTextCopy = false;
            page.Canvas.DrawString("This text cannot be copied and pasted.", f2, blackBrush, 20, 225);
            page.Canvas.DrawString("Praesent sed massa a est fringilla mattis. Aenean sit amet odio ac nunc.", f2, blackBrush, 20, 250);
        }
Esempio n. 24
0
        /// <summary>
        /// Draws content on a page using colors created from a device colorspace.
        /// </summary>
        /// <param name="page">The page to draw to.</param>
        /// <remarks>RGB, CMYK and Gray are device colorspaces.
        /// The PDFRgbColor, PDFCmykColor and PDFGrayColor classes create automatically the
        /// required colorspaces.</remarks>
        private static void DrawDeviceColorSpace(PDFPage page)
        {
            PDFRgbColor black      = new PDFRgbColor(0, 0, 0);
            PDFBrush    blackBrush = new PDFBrush(black);
            //PDF4NET v5: PDFFont font = new PDFFont(PDFFontFace.Helvetica, 16);
            PDFStandardFont font = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);

            //PDF4NET v5: page.Canvas.DrawText("Device colorspaces: RGB, CMYK and Gray", font, null, blackBrush, 50, 50);
            page.Canvas.DrawString("Device colorspaces: RGB, CMYK and Gray", font, blackBrush, 50, 50);

            // Draw RGB content.
            //PDF4NET v5: page.Canvas.DrawText("RGB", font, null, blackBrush, 50, 80);
            page.Canvas.DrawString("RGB", font, blackBrush, 50, 80);
            PDFRgbColor red      = new PDFRgbColor(255, 0, 0);
            PDFRgbColor blue     = new PDFRgbColor(0, 0, 255);
            PDFBrush    redBrush = new PDFBrush(red);
            PDFPen      bluePen  = new PDFPen(blue, 5);

            page.Canvas.DrawRoundRectangle(bluePen, redBrush, 50, 100, 400, 150, 20, 20);

            // Draw CMYK content.
            //PDF4NET v5: page.Canvas.DrawText("CMYK", font, null, blackBrush, 50, 280);
            page.Canvas.DrawString("CMYK", font, blackBrush, 50, 280);
            PDFCmykColor cyan       = new PDFCmykColor(1, 0, 0, 0);
            PDFCmykColor magenta    = new PDFCmykColor(0, 1, 0, 0);
            PDFBrush     cyanBrush  = new PDFBrush(cyan);
            PDFPen       magentaPen = new PDFPen(magenta, 5);

            page.Canvas.DrawRoundRectangle(magentaPen, cyanBrush, 50, 300, 400, 150, 20, 20);

            // Draw Gray content.
            //PDF4NET v5: page.Canvas.DrawText("Gray", font, null, blackBrush, 50, 480);
            page.Canvas.DrawString("Gray", font, blackBrush, 50, 480);
            PDFGrayColor lightGray = new PDFGrayColor(0.85);
            PDFGrayColor darkGray  = new PDFGrayColor(0.1);
            PDFBrush     lgBrush   = new PDFBrush(lightGray);
            PDFPen       dgPen     = new PDFPen(darkGray, 5);

            page.Canvas.DrawRoundRectangle(dgPen, lgBrush, 50, 500, 400, 150, 20, 20);
        }
Esempio n. 25
0
        private static void DrawTrueTypeFonts(PDFPage page, Stream ttfStream)
        {
            PDFStandardFont titleFont  = new PDFStandardFont(PDFStandardFontFace.HelveticaBold, 22);
            PDFBrush        blackBrush = new PDFBrush(new PDFRgbColor());

            page.Canvas.DrawString("TrueType fonts", titleFont, blackBrush, 20, 50);
            page.Canvas.DrawString("(when embedded they should be supported", titleFont, blackBrush, 20, 75);
            page.Canvas.DrawString(" by any PDF viewer)", titleFont, blackBrush, 20, 100);

            PDFAnsiTrueTypeFont ansiVerdana = new PDFAnsiTrueTypeFont(ttfStream, 16, true);

            page.Canvas.DrawString("Verdana - Ansi TrueType font", ansiVerdana, blackBrush, 20, 150);
            page.Canvas.DrawString("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", ansiVerdana, blackBrush, 20, 175);

            ttfStream.Position = 0;
            PDFUnicodeTrueTypeFont unicodeVerdana = new PDFUnicodeTrueTypeFont(ttfStream, 16, true);

            page.Canvas.DrawString("Verdana - Unicode TrueType font", unicodeVerdana, blackBrush, 20, 225);

            page.Canvas.DrawString("Russian - Пример русский текст демо шрифт.", unicodeVerdana, blackBrush, 20, 250);
            page.Canvas.DrawString("Greek - Δείγμα ελληνικό κείμενο demo γραμματοσειράς.", unicodeVerdana, blackBrush, 20, 275);
        }
Esempio n. 26
0
        /// <summary>
        /// Draws content on a page using colors created from a calibrated gray colorspace.
        /// </summary>
        /// <param name="page">The page to draw to.</param>
        private static void DrawCalGrayColorSpace(PDFPage page)
        {
            PDFRgbColor black      = new PDFRgbColor(0, 0, 0);
            PDFBrush    blackBrush = new PDFBrush(black);
            //PDF4NET v5: PDFFont font = new PDFFont(PDFFontFace.Helvetica, 16);
            PDFStandardFont font = new PDFStandardFont(PDFStandardFontFace.Helvetica, 16);

            //PDF4NET v5: page.Canvas.DrawText("CalGray colorspace", font, null, blackBrush, 50, 50);
            page.Canvas.DrawString("CalGray colorspace", font, blackBrush, 50, 50);

            PDFCalGrayColorSpace calGrayCS = new PDFCalGrayColorSpace();
            PDFCalGrayColor      dkGray    = new PDFCalGrayColor(calGrayCS);

            dkGray.Gray = 0.1;
            PDFCalGrayColor ltGray = new PDFCalGrayColor(calGrayCS);

            ltGray.Gray = 0.8;
            PDFBrush dkBrush = new PDFBrush(dkGray);
            PDFPen   ltPen   = new PDFPen(ltGray, 5);

            page.Canvas.DrawRoundRectangle(ltPen, dkBrush, 50, 100, 400, 150, 20, 20);
        }
Esempio n. 27
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run(Stream flashStream, Stream u3dStream)
        {
            // Create a PDF document with 10 pages.
            PDFFixedDocument document  = new PDFFixedDocument();
            PDFStandardFont  helvetica = new PDFStandardFont(PDFStandardFontFace.Helvetica, 12);

            CreateTextAnnotations(document, helvetica);

            CreateSquareCircleAnnotations(document, helvetica);

            CreateFileAttachmentAnnotations(document, helvetica);

            CreateInkAnnotations(document, helvetica);

            CreateLineAnnotations(document, helvetica);

            CreatePolygonAnnotations(document, helvetica);

            CreatePolylineAnnotations(document, helvetica);

            CreateRubberStampAnnotations(document, helvetica);

            CreateTextMarkupAnnotations(document, helvetica);

            CreateRichMediaAnnotations(document, helvetica, flashStream);

            Create3DAnnotations(document, helvetica, u3dStream);

            CreateRedactionAnnotations(document, helvetica, u3dStream);

            // Compress the page graphic content.
            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Canvas.CompressAndClose();
            }

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "annotations.pdf") };
            return(output);
        }
Esempio n. 28
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run()
        {
            // Create a PDF document with 10 pages.
            PDFFixedDocument document   = new PDFFixedDocument();
            PDFStandardFont  helvetica  = new PDFStandardFont(PDFStandardFontFace.Helvetica, 216);
            PDFBrush         blackBrush = new PDFBrush();

            for (int i = 0; i < 10; i++)
            {
                PDFPage page = document.Pages.Add();
                page.Canvas.DrawString((i + 1).ToString(), helvetica, blackBrush, 5, 5);
            }

            CreateNamedActions(document, helvetica);

            CreateGoToActions(document, helvetica);

            CreateRemoteGoToActions(document, helvetica);

            CreateLaunchActions(document, helvetica);

            CreateUriActions(document, helvetica);

            CreateJavaScriptActions(document, helvetica);

            CreateDocumentActions(document);

            // Compress the page graphic content.
            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Canvas.CompressAndClose();
            }

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "actions.pdf") };
            return(output);
        }
Esempio n. 29
0
        /// <summary>
        /// Generates a PDF document that is encrypted using RC4 method.
        /// </summary>
        /// <param name="keySize">The encryption key size.</param>
        /// <param name="rc4"></param>
        /// <returns></returns>
        private static PDFFixedDocument EncryptRC4(int keySize, PDFRc4SecurityHandler rc4)
        {
            PDFFixedDocument doc = new PDFFixedDocument();

            rc4.EnableContentExtractionForAccessibility = false;
            rc4.EnableDocumentAssembly         = false;
            rc4.EnableDocumentChange           = false;
            rc4.EnableContentExtraction        = false;
            rc4.EnableFormsFill                = false;
            rc4.EnableAnnotationsAndFieldsEdit = false;
            rc4.EnablePrint     = false;
            rc4.EncryptMetadata = true;
            rc4.KeySize         = keySize;
            rc4.UserPassword    = "******";
            rc4.OwnerPassword   = "******";

            PDFPage         page       = doc.Pages.Add();
            PDFStandardFont helvetica  = new PDFStandardFont(PDFStandardFontFace.HelveticaBoldItalic, 16);
            PDFBrush        blackBrush = new PDFBrush();

            page.Canvas.DrawString(string.Format("Encryption: RC4 {0} bit", keySize), helvetica, blackBrush, 50, 100);

            return(doc);
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            // Create the pdf document
            //PDF4NET v5: PDFDocument doc = new PDFDocument();
            PDFFixedDocument doc = new PDFFixedDocument();

            // Create one page
            //PDF4NET v5: PDFPage page = doc.AddPage();
            PDFPage page = doc.Pages.Add();

            PDFBrush blackBrush = new PDFBrush(new PDFRgbColor(0, 0, 0));
            //PDF4NET v5: PDFFont fontSection = new PDFFont(PDFFontFace.Helvetica, 10);
            PDFStandardFont fontSection = new PDFStandardFont(PDFStandardFontFace.Helvetica, 10);

            fontSection.Bold = true;
            //PDF4NET v5: PDFFont fontText = new PDFFont(PDFFontFace.Helvetica, 8);
            PDFStandardFont fontText = new PDFStandardFont(PDFStandardFontFace.Helvetica, 8);

            //PDF4NET v5: page.Canvas.DrawText("Text annotations", fontSection, null, blackBrush, 20, 45, 0, PDFTextAlign.BottomLeft);
            PDFStringLayoutOptions slo = new PDFStringLayoutOptions()
            {
                X = 20, Y = 45, VerticalAlign = PDFStringVerticalAlign.Bottom
            };
            PDFStringAppearanceOptions sao = new PDFStringAppearanceOptions()
            {
                Font = fontSection, Brush = blackBrush
            };

            page.Canvas.DrawString("Text annotations", sao, slo);

            // Create all available text annotations
            //PDF4NET v5: PDFTextAnnotation ta = new PDFTextAnnotation("Comment", "Comment annotation");
            PDFTextAnnotation ta = new PDFTextAnnotation()
            {
                Author = "Comment", Contents = "Comment annotation"
            };

            page.Annotations.Add(ta);
            ta.Icon = PDFTextAnnotationIcon.Comment;
            //PDF4NET v5: ta.Rectangle = new RectangleF(20, 60, 20, 20);
            ta.Location = new PDFPoint(20, 60);
            //PDF4NET v5: page.Canvas.DrawText("Comment", fontText, null, blackBrush, 20, 80, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Comment", fontText, blackBrush, 20, 80);

            //PDF4NET v5: ta = new PDFTextAnnotation("Help", "Help annotation");
            ta = new PDFTextAnnotation()
            {
                Author = "Help", Contents = "Help annotation"
            };
            page.Annotations.Add(ta);
            ta.Icon = PDFTextAnnotationIcon.Help;
            //PDF4NET v5: ta.Rectangle = new RectangleF(100, 60, 20, 20);
            ta.Location = new PDFPoint(100, 60);
            //PDF4NET v5: page.Canvas.DrawText("Help", fontText, null, blackBrush, 100, 80, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Help", fontText, blackBrush, 100, 80);

            //PDF4NET v5: ta = new PDFTextAnnotation("Insert", "Insert annotation");
            ta = new PDFTextAnnotation()
            {
                Author = "Insert", Contents = "Insert annotation"
            };
            page.Annotations.Add(ta);
            ta.Icon = PDFTextAnnotationIcon.Insert;
            //PDF4NET v5: ta.Rectangle = new RectangleF(180, 60, 20, 20);
            ta.Location = new PDFPoint(180, 60);
            //PDF4NET v5: page.Canvas.DrawText("Insert", fontText, null, blackBrush, 180, 80, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Insert", fontText, blackBrush, 180, 80);

            //PDF4NET v5: ta = new PDFTextAnnotation("Key", "Key annotation");
            ta = new PDFTextAnnotation()
            {
                Author = "Key", Contents = "Key annotation"
            };
            page.Annotations.Add(ta);
            ta.Icon = PDFTextAnnotationIcon.Key;
            //PDF4NET v5: ta.Rectangle = new RectangleF(260, 60, 20, 20);
            ta.Location = new PDFPoint(260, 60);
            //PDF4NET v5: page.Canvas.DrawText("Key", fontText, null, blackBrush, 260, 80, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Key", fontText, blackBrush, 260, 80);

            //PDF4NET v5: ta = new PDFTextAnnotation("New paragraph", "New paragraph annotation");
            ta = new PDFTextAnnotation()
            {
                Author = "New paragraph", Contents = "New paragraph annotation"
            };
            page.Annotations.Add(ta);
            ta.Icon = PDFTextAnnotationIcon.NewParagraph;
            //PDF4NET v5: ta.Rectangle = new RectangleF(340, 60, 20, 20);
            ta.Location = new PDFPoint(340, 60);
            //PDF4NET v5: page.Canvas.DrawText("New paragraph", fontText, null, blackBrush, 340, 80, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("New paragraph", fontText, blackBrush, 340, 80);

            //PDF4NET v5: ta = new PDFTextAnnotation("Note", "Note annotation");
            ta = new PDFTextAnnotation()
            {
                Author = "Note", Contents = "Note annotation"
            };
            page.Annotations.Add(ta);
            ta.Icon = PDFTextAnnotationIcon.Note;
            //PDF4NET v5: ta.Rectangle = new RectangleF(420, 60, 20, 20);
            ta.Location = new PDFPoint(420, 60);
            //PDF4NET v5: page.Canvas.DrawText("Note", fontText, null, blackBrush, 420, 80, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Note", fontText, blackBrush, 420, 80);

            //PDF4NET v5: ta = new PDFTextAnnotation("Paragraph", "Paragraph annotation");
            ta = new PDFTextAnnotation()
            {
                Author = "Paragraph", Contents = "Paragraph annotation"
            };
            page.Annotations.Add(ta);
            ta.Icon = PDFTextAnnotationIcon.Paragraph;
            //PDF4NET v5: ta.Rectangle = new RectangleF(500, 60, 20, 20);
            ta.Location = new PDFPoint(500, 60);
            //PDF4NET v5: page.Canvas.DrawText("Paragraph", fontText, null, blackBrush, 500, 80, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Paragraph", fontText, blackBrush, 500, 80);

            // Rubber stamp annotations

            //PDF4NET v5: page.Canvas.DrawText("Rubber stamp annotations", fontSection, null, blackBrush, 20, 120, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Rubber stamp annotations", fontSection, blackBrush, 20, 120);

            // Create all available rubber stamp annotations
            //PDF4NET v5: PDFRubberStampAnnotation rsa = new PDFRubberStampAnnotation("Approved", "Approved annotation");
            PDFRubberStampAnnotation rsa = new PDFRubberStampAnnotation()
            {
                Author = "Approved", Contents = "Approved annotation"
            };

            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.Approved;
            rsa.StampName = PDFRubberStampAnnotationName.Approved;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(20, 140, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(20, 140, 100, 30);
            rsa.Opacity          = 50;
            //PDF4NET v5: page.Canvas.DrawText("Approved", fontText, null, blackBrush, 20, 180, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Approved", fontText, blackBrush, 20, 180);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("As Is", "As Is annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "As Is", Contents = "As Is annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.AsIs;
            rsa.StampName = PDFRubberStampAnnotationName.AsIs;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(120, 140, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(120, 140, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("As Is", fontText, null, blackBrush, 120, 180, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("As Is", fontText, blackBrush, 120, 180);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("Confidential", "Confidential annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "Confidential", Contents = "Confidential annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.Confidential;
            rsa.StampName = PDFRubberStampAnnotationName.Confidential;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(220, 140, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(220, 140, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("Confidential", fontText, null, blackBrush, 220, 180, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Confidential", fontText, blackBrush, 220, 180);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("Departmental", "Departmental annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "Departmental", Contents = "Departmental annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.Departmental;
            rsa.StampName = PDFRubberStampAnnotationName.Departmental;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(320, 140, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(320, 140, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("Departmental", fontText, null, blackBrush, 320, 180, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Departmental", fontText, blackBrush, 320, 180);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("Draft", "Draft annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "Draft", Contents = "Draft annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.Draft;
            rsa.StampName = PDFRubberStampAnnotationName.Draft;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(420, 140, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(420, 140, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("Draft", fontText, null, blackBrush, 420, 180, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Draft", fontText, blackBrush, 420, 180);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("Experimental", "Experimental annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "Experimental", Contents = "Experimental annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.Experimental;
            rsa.StampName = PDFRubberStampAnnotationName.Experimental;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(520, 140, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(520, 140, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("Experimental", fontText, null, blackBrush, 520, 180, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Experimental", fontText, blackBrush, 520, 180);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("Expired", "Expired annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "Expired", Contents = "Expired annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.Expired;
            rsa.StampName = PDFRubberStampAnnotationName.Expired;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(20, 200, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(20, 200, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("Expired", fontText, null, blackBrush, 20, 240, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Expired", fontText, blackBrush, 20, 240);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("Final", "Final annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "Final", Contents = "Final annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.Final;
            rsa.StampName = PDFRubberStampAnnotationName.Final;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(120, 200, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(120, 200, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("Final", fontText, null, blackBrush, 120, 240, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Final", fontText, blackBrush, 120, 240);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("ForComment", "ForComment annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "ForComment", Contents = "ForComment annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.ForComment;
            rsa.StampName = PDFRubberStampAnnotationName.ForComment;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(220, 200, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(220, 200, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("ForComment", fontText, null, blackBrush, 220, 240, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("ForComment", fontText, blackBrush, 220, 240);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("ForPublicRelease", "ForPublicRelease annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "ForPublicRelease", Contents = "ForPublicRelease annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.ForPublicRelease;
            rsa.StampName = PDFRubberStampAnnotationName.ForPublicRelease;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(320, 200, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(320, 200, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("ForPublicRelease", fontText, null, blackBrush, 320, 240, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("ForPublicRelease", fontText, blackBrush, 320, 240);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("NotApproved", "NotApproved annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "NotApproved", Contents = "NotApproved annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.NotApproved;
            rsa.StampName = PDFRubberStampAnnotationName.NotApproved;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(420, 200, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(420, 200, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("NotApproved", fontText, null, blackBrush, 420, 240, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("NotApproved", fontText, blackBrush, 420, 240);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("NotForPublicRelease", "NotForPublicRelease annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "NotForPublicRelease", Contents = "NotForPublicRelease annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.NotForPublicRelease;
            rsa.StampName = PDFRubberStampAnnotationName.NotForPublicRelease;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(520, 200, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(520, 200, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("NotForPublicRelease", fontText, null, blackBrush, 520, 240, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("NotForPublicRelease", fontText, blackBrush, 520, 240);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("Sold", "Sold annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "Sold", Contents = "Sold annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.Sold;
            rsa.StampName = PDFRubberStampAnnotationName.Sold;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(20, 260, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(20, 260, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("Sold", fontText, null, blackBrush, 20, 300, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Sold", fontText, blackBrush, 20, 300);

            //PDF4NET v5: rsa = new PDFRubberStampAnnotation("TopSecret", "TopSecret annotation");
            rsa = new PDFRubberStampAnnotation()
            {
                Author = "TopSecret", Contents = "TopSecret annotation"
            };
            page.Annotations.Add(rsa);
            //PDF4NET v5: rsa.Icon = PDFRubberStampAnnotationIcon.TopSecret;
            rsa.StampName = PDFRubberStampAnnotationName.TopSecret;
            //PDF4NET v5: rsa.Rectangle = new RectangleF(120, 260, 100, 30);
            rsa.DisplayRectangle = new PDFDisplayRectangle(120, 260, 100, 30);
            //PDF4NET v5: page.Canvas.DrawText("TopSecret", fontText, null, blackBrush, 120, 300, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("TopSecret", fontText, blackBrush, 120, 300);

            // Line annotations

            //PDF4NET v5: page.Canvas.DrawText("Line annotations", fontSection, null, blackBrush, 20, 350, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Line annotations", fontSection, blackBrush, 20, 350);
            //PDF4NET v5: PDFLineAnnotation la = new PDFLineAnnotation("Line", "Line annotation");
            PDFLineAnnotation la = new PDFLineAnnotation()
            {
                Author = "Line", Contents = "Line annotation"
            };

            page.Annotations.Add(la);
            //PDF4NET v5: la.BeginLineStyle = PDFLineEndingStyle.Circle;
            la.StartLineSymbol = PDFLineEndingStyle.Circle;
            //PDF4NET v5: la.EndLineStyle = PDFLineEndingStyle.OpenArrow;
            la.EndLineSymbol = PDFLineEndingStyle.OpenArrow;
            //PDF4NET v5: la.LineDirection = PDFLineDirection.TopLeftToBottomRight;

            //PDF4NET v5: la.Rectangle = new RectangleF(20, 370, 150, 30);
            la.StartPoint = new PDFPoint(20, 370);
            la.EndPoint   = new PDFPoint(170, 400);
            //PDF4NET v5: la.Border = new PDFAnnotationBorder(1, PDFBorderStyle.Solid);
            la.LineWidth = 1;
            //PDF4NET v5: la.Color = new PDFRgbColor(Color.Red);
            la.LineColor = PDFRgbColor.Red;
            //PDF4NET v5: la.InteriorColor = new PDFRgbColor(Color.CornflowerBlue);
            la.InteriorColor = PDFRgbColor.CornflowerBlue;
            //PDF4NET v5: page.Canvas.DrawText("Line annotation with a circle and open arrow", fontText, null, blackBrush, 20, 420, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Line annotation with a circle and open arrow", fontText, blackBrush, 20, 420);

            // File attachment annotations

            //PDF4NET v5: page.Canvas.DrawText("File attachment annotations", fontSection, null, blackBrush, 20, 450, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("File attachment annotations", fontSection, blackBrush, 20, 450);
            // Create all available file attachment annotations
            //PDF4NET v5: PDFFileAttachmentAnnotation faa = new PDFFileAttachmentAnnotation("Graph", "Graph icon");
            PDFFileAttachmentAnnotation faa = new PDFFileAttachmentAnnotation()
            {
                Author = "Graph", Contents = "Graph icon"
            };

            page.Annotations.Add(faa);
            faa.Icon = PDFFileAttachmentAnnotationIcon.Graph;
            //PDF4NET v5: faa.Rectangle = new RectangleF(20, 470, 20, 20);
            faa.Location = new PDFPoint(20, 470);
            faa.FileName = "sample.pdf";
            faa.Payload  = File.ReadAllBytes("..\\..\\..\\..\\..\\SupportFiles\\sample.pdf");
            //PDF4NET v5: page.Canvas.DrawText("Graph", fontText, null, blackBrush, 20, 500, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Graph", fontText, blackBrush, 20, 500);

            //PDF4NET v5: faa = new PDFFileAttachmentAnnotation("Paperclip", "Paperclip icon");
            faa = new PDFFileAttachmentAnnotation()
            {
                Author = "Paperclip", Contents = "Paperclip icon"
            };
            page.Annotations.Add(faa);
            faa.Icon = PDFFileAttachmentAnnotationIcon.Paperclip;
            //PDF4NET v5: faa.Rectangle = new RectangleF(100, 470, 20, 20);
            faa.Location = new PDFPoint(100, 470);
            faa.FileName = "sample.pdf";
            faa.Payload  = File.ReadAllBytes("..\\..\\..\\..\\..\\SupportFiles\\sample.pdf");
            //PDF4NET v5: page.Canvas.DrawText("Paperclip", fontText, null, blackBrush, 100, 500, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Paperclip", fontText, blackBrush, 100, 500);

            //PDF4NET v5: faa = new PDFFileAttachmentAnnotation("PushPin", "PushPin icon");
            faa = new PDFFileAttachmentAnnotation()
            {
                Author = "PushPin", Contents = "PushPin icon"
            };
            page.Annotations.Add(faa);
            faa.Icon = PDFFileAttachmentAnnotationIcon.PushPin;
            //PDF4NET v5: faa.Rectangle = new RectangleF(180, 470, 20, 20);
            faa.Location = new PDFPoint(180, 470);
            faa.FileName = "sample.pdf";
            faa.Payload  = File.ReadAllBytes("..\\..\\..\\..\\..\\SupportFiles\\sample.pdf");
            //PDF4NET v5: page.Canvas.DrawText("PushPin", fontText, null, blackBrush, 180, 500, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("PushPin", fontText, blackBrush, 180, 500);

            //PDF4NET v5: faa = new PDFFileAttachmentAnnotation("Tag", "Tag icon");
            faa = new PDFFileAttachmentAnnotation()
            {
                Author = "Tag", Contents = "Tag icon"
            };
            page.Annotations.Add(faa);
            faa.Icon = PDFFileAttachmentAnnotationIcon.Tag;
            //PDF4NET v5: faa.Rectangle = new RectangleF(260, 470, 20, 20);
            faa.Location = new PDFPoint(260, 470);
            faa.FileName = "sample.pdf";
            faa.Payload  = File.ReadAllBytes("..\\..\\..\\..\\..\\SupportFiles\\sample.pdf");
            //PDF4NET v5: page.Canvas.DrawText("Graph", fontText, null, blackBrush, 260, 500, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Graph", fontText, blackBrush, 260, 500);

            // Highlight annotation

            //PDF4NET v5: page.Canvas.DrawText("Markup annotation - this text will be highlighted", fontSection, null, blackBrush, 20, 610);
            page.Canvas.DrawString("Markup annotation - this text will be highlighted", fontSection, blackBrush, 20, 610);
            //PDF4NET v5: PDFHighlightAnnotation ha = new PDFHighlightAnnotation("Markup annotation", "Markup annotation with highlight style");
            PDFTextMarkupAnnotation tma = new PDFTextMarkupAnnotation()
            {
                Author = "Markup annotation", Contents = "Markup annotation with highlight style"
            };

            tma.TextMarkupType = PDFTextMarkupAnnotationType.Highlight;
            page.Annotations.Add(tma);
            //PDF4NET v5: ha.Rectangle = new RectangleF(100, 610, 100, 10);
            tma.DisplayRectangle = new PDFDisplayRectangle(100, 610, 100, 10);
            tma.TextMarkupColor  = new PDFRgbColor(255, 255, 0);

            // Square and circle annotations

            //PDF4NET v5: page.Canvas.DrawText("Square and circle annotations", fontSection, null, blackBrush, 20, 650);
            page.Canvas.DrawString("Square and circle annotations", fontSection, blackBrush, 20, 650);
            //PDF4NET v5: PDFEllipseAnnotation ea = new PDFEllipseAnnotation("Ellipse annotation", "An ellipse annotation");
            PDFCircleAnnotation ca = new PDFCircleAnnotation()
            {
                Author = "Ellipse annotation", Contents = "An ellipse annotation"
            };

            page.Annotations.Add(ca);
            //PDF4NET v5: ea.Rectangle = new RectangleF(20, 670, 150, 75);
            ca.DisplayRectangle = new PDFDisplayRectangle(20, 670, 150, 75);
            //PDF4NET v5: ea.Color = new PDFRgbColor(255, 255, 0);
            ca.BorderColor   = new PDFRgbColor(255, 255, 0);
            ca.InteriorColor = new PDFRgbColor(0, 255, 0);

            //PDF4NET v5: PDFRectangleAnnotation ra = new PDFRectangleAnnotation("Rectangle annotation", "A rectangle annotation");
            PDFSquareAnnotation sa = new PDFSquareAnnotation()
            {
                Author = "Rectangle annotation", Contents = "A rectangle annotation"
            };

            page.Annotations.Add(sa);
            //PDF4NET v5: ra.Rectangle = new RectangleF(200, 670, 150, 75);
            sa.DisplayRectangle = new PDFDisplayRectangle(200, 670, 150, 75);
            //PDF4NET v5: ra.Color = new PDFRgbColor(255, 64, 0);
            sa.BorderColor   = new PDFRgbColor(255, 64, 0);
            sa.InteriorColor = new PDFRgbColor(64, 0, 255);

            // Create 2nd page
            //PDF4NET v5: page = doc.AddPage();
            page = doc.Pages.Add();

            //PDF4NET v5: page.Canvas.DrawText("Annotations with custom appearance", fontSection, null, blackBrush, 20, 45, 0, PDFTextAlign.BottomLeft);
            slo.Y = 45;
            page.Canvas.DrawString("Annotations with custom appearance", sao, slo);

            //PDF4NET v5: page.Canvas.DrawText("a. Annotations with image appearance", fontSection, null, blackBrush, 20, 60, 0, PDFTextAlign.BottomLeft);
            slo.Y = 60;
            page.Canvas.DrawString("a. Annotations with image appearance", sao, slo);

            //PDF4NET v5: PDFRubberStampAnnotation isa = new PDFRubberStampAnnotation("ImageAppearance", "Annotation with image appearance.");
            PDFRubberStampAnnotation isa = new PDFRubberStampAnnotation()
            {
                Author = "ImageAppearance", Contents = "Annotation with image appearance."
            };

            page.Annotations.Add(isa);
            //PDF4NET v5: isa.Rectangle = new RectangleF(20, 70, 200, 100);
            isa.DisplayRectangle = new PDFDisplayRectangle(20, 70, 200, 100);
            //PDF4NET v5: Bitmap img = new Bitmap("..\\SupportFiles\\auto1.jpg");
            //PDF4NET v5: isa.Appearance = new PDFImageAppearance(img);
            //PDF4NET v5: img.Dispose();

            FileStream   imgStream = File.OpenRead("..\\..\\..\\..\\..\\SupportFiles\\auto1.jpg");
            PDFJpegImage img       = new PDFJpegImage(imgStream);

            imgStream.Dispose();
            PDFAnnotationAppearance ia = new PDFAnnotationAppearance(isa.DisplayRectangle.Width, isa.DisplayRectangle.Height);

            ia.Canvas.DrawImage(img, 0, 0, ia.Width, ia.Height);
            isa.NormalAppearance = ia;

            //PDF4NET v5: page.Canvas.DrawText("Image appearance", fontText, null, blackBrush, 20, 175, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Image appearance", fontText, blackBrush, 20, 175);

            //PDF4NET v5: page.Canvas.DrawText("b. Annotations with owner draw appearance", fontSection, null, blackBrush, 20, 200, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("b. Annotations with owner draw appearance", fontSection, blackBrush, 20, 200);
            //PDF4NET v5: PDFRubberStampAnnotation odsa = new PDFRubberStampAnnotation("OwnerDrawAppearance", "Annotation with owner draw appearance.");
            PDFRubberStampAnnotation odsa = new PDFRubberStampAnnotation()
            {
                Author = "OwnerDrawAppearance", Contents = "Annotation with owner draw appearance."
            };

            page.Annotations.Add(odsa);
            //PDF4NET v5: odsa.Rectangle = new RectangleF(20, 220, 200, 100);
            odsa.DisplayRectangle = new PDFDisplayRectangle(20, 220, 200, 100);
            //PDF4NET v5: odsa.Appearance = new PDFAnnotationAppearance();
            //PDF4NET v5: odsa.Appearance.Width = odsa.Rectangle.Width;
            //PDF4NET v5: odsa.Appearance.Height = odsa.Rectangle.Height;
            odsa.NormalAppearance = new PDFAnnotationAppearance(odsa.DisplayRectangle.Width, odsa.DisplayRectangle.Height);
            PDFBrush redBrush = new PDFBrush(new PDFRgbColor(192, 0, 0));

            //PDF4NET v5: odsa.Appearance.Canvas.DrawRoundRectangle(redBrush, 0, 0, odsa.Rectangle.Width, odsa.Rectangle.Height, 40, 40);
            odsa.NormalAppearance.Canvas.DrawRoundRectangle(redBrush, 0, 0, odsa.DisplayRectangle.Width, odsa.DisplayRectangle.Height, 40, 40);
            PDFBrush blueBrush = new PDFBrush(new PDFRgbColor(0, 0, 128));

            //PDF4NET v5: odsa.Appearance.Canvas.DrawEllipse(blueBrush, (odsa.Rectangle.Width - odsa.Rectangle.Height) / 2, 0, odsa.Rectangle.Height, odsa.Rectangle.Height);
            odsa.NormalAppearance.Canvas.DrawEllipse(blueBrush,
                                                     (odsa.DisplayRectangle.Width - odsa.DisplayRectangle.Height) / 2, 0, odsa.DisplayRectangle.Height, odsa.DisplayRectangle.Height);
            //PDF4NET v5: page.Canvas.DrawText("Owner draw appearance", fontText, null, blackBrush, 20, 325, 0, PDFTextAlign.TopLeft);
            page.Canvas.DrawString("Owner draw appearance", fontText, blackBrush, 20, 325);

            // Save the document to disk
            doc.Save("Sample_Annotations.pdf");
        }