예제 #1
0
        private static void CreateLaunchActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen   blackPen   = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Brush = blackBrush;
            sao.Font  = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("Launch actions:", font, blackBrush, 400, 360);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 380, 200, 20);
                slo.X = 500;
                slo.Y = 390;
                document.Pages[i].Graphics.DrawString("Launch samples explorer", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 380, 200, 20);

                // Create a launch action and attach it to the link.
                PdfLaunchAction launchAction = new PdfLaunchAction();
                launchAction.FileName = "Xfinium.Pdf.SamplesExplorer.Win.exe";
                link.Action           = launchAction;
            }
        }
예제 #2
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].Graphics.DrawPath(pen, boundingPath);
                slo.X = eic[i].ImageCorners[3].X + 1;
                slo.Y = eic[i].ImageCorners[3].Y + 1;
                document.Pages[2].Graphics.DrawString(imageProperties, sao, slo);
            }
        }
예제 #3
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.Graphics.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.Graphics.SetExtendedGraphicState(gs1);
            page.Graphics.DrawString("Sample watermark over page content", sao, slo);

            page.Graphics.RestoreGraphicsState();
        }
예제 #4
0
        void CreateNewPage(PdfFixedDocument document, PdfFont font, PdfBrush brush)
        {
            var page = document.Pages.Add();

            page.Height = 1024;
            page.Width  = 840;

            font.Size = FONTSIZE_PAGE_TITLE;

            PdfStringAppearanceOptions appearance = new PdfStringAppearanceOptions
            {
                Brush = brush,
                Font  = font,
            };

            PdfStringLayoutOptions layout = new PdfStringLayoutOptions()
            {
                HorizontalAlign = PdfStringHorizontalAlign.Right,
                VerticalAlign   = PdfStringVerticalAlign.Bottom,
                X = page.Width - PagePadding.Right,
                Y = page.Height - PagePadding.Bottom
            };

            font.Size = FONTSIZE_DEFAULT;
            page.Graphics.DrawString(document.Pages.Count.ToString(), appearance, layout);

            CurrentPage   = page;
            AvailableSize = new Size(
                page.Width - PagePadding.Left - PagePadding.Right,
                page.Height - PagePadding.Top - PagePadding.Bottom);
        }
예제 #5
0
        private static void CreateJavaScriptActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen   blackPen   = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Brush = blackBrush;
            sao.Font  = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("JavaScript actions:", font, blackBrush, 400, 480);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 500, 200, 20);
                slo.X = 500;
                slo.Y = 510;
                document.Pages[i].Graphics.DrawString("Click me", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 500, 200, 20);

                // Create a Javascript action and attach it to the link.
                PdfJavaScriptAction jsAction = new PdfJavaScriptAction();
                jsAction.Script = "app.alert({cMsg: \"JavaScript action: you are now on page " + (i + 1) + "\", cTitle: \"Xfinium.Pdf Actions Sample\"});";
                link.Action     = jsAction;
            }
        }
예제 #6
0
        private static void CreateUriActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen   blackPen   = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Brush = blackBrush;
            sao.Font  = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("Uri actions:", font, blackBrush, 400, 420);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 440, 200, 20);
                slo.X = 500;
                slo.Y = 450;
                document.Pages[i].Graphics.DrawString("Go to xfiniumpdf.com", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 440, 200, 20);

                // Create an uri action and attach it to the link.
                PdfUriAction uriAction = new PdfUriAction();
                uriAction.URI = "http://www.xfiniumpdf.com";
                link.Action   = uriAction;
            }
        }
예제 #7
0
        private static void CreateTextMarkupAnnotations(PdfFixedDocument document, PdfFont font)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

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

            PdfTextMarkupAnnotationType[] tmat = new PdfTextMarkupAnnotationType[]
            {
                PdfTextMarkupAnnotationType.Highlight, PdfTextMarkupAnnotationType.Squiggly, PdfTextMarkupAnnotationType.StrikeOut, PdfTextMarkupAnnotationType.Underline
            };

            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Brush = blackBrush;
            sao.Font  = font;

            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Bottom;
            for (int i = 0; i < tmat.Length; i++)
            {
                PdfTextMarkupAnnotation tma = new PdfTextMarkupAnnotation();
                page.Annotations.Add(tma);
                tma.VisualRectangle = new PdfVisualRectangle(50, 100 + 50 * i, 200, font.Size + 2);
                tma.TextMarkupType  = tmat[i];

                slo.X = 150;
                slo.Y = 100 + 50 * i + font.Size;

                page.Graphics.DrawString(tmat[i].ToString() + " annotation.", sao, slo);
            }
        }
        /// <summary>
        /// Utility method that will create a new string appearance options.
        /// </summary>
        /// <returns>The appearence options.</returns>
        /// <param name="font">Font.</param>
        /// <param name="color">Color.</param>
        private static PdfStringAppearanceOptions NewAppearance(PdfStandardFont font, PdfColor color)
        {
            var ret = new PdfStringAppearanceOptions();

            ret.Font  = font;
            ret.Brush = new PdfBrush(color);

            return(ret);
        }
예제 #9
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run(Stream iccInput, Stream ttfInput)
        {
            PdfFixedDocument document = new PdfFixedDocument();

            // Setup the document by creating a PDF/A output intent, based on a RGB ICC profile,
            // and document information and metadata
            PdfIccColorSpace icc = new PdfIccColorSpace();

            byte[] profilePayload = new byte[iccInput.Length];
            iccInput.Read(profilePayload, 0, profilePayload.Length);
            icc.IccProfile = profilePayload;
            PdfOutputIntent oi = new PdfOutputIntent();

            oi.Type = PdfOutputIntentType.PdfA1;
            oi.Info = "sRGB IEC61966-2.1";
            oi.OutputConditionIdentifier = "Custom";
            oi.DestinationOutputProfile  = icc;
            document.OutputIntents       = new PdfOutputIntentCollection();
            document.OutputIntents.Add(oi);

            document.DocumentInformation          = new PdfDocumentInformation();
            document.DocumentInformation.Author   = "XFINIUM Software";
            document.DocumentInformation.Title    = "XFINIUM.PDF PDF/A-1B Demo";
            document.DocumentInformation.Creator  = "XFINIUM.PDF PDF/A-1B Demo";
            document.DocumentInformation.Producer = "XFINIUM.PDF";
            document.DocumentInformation.Keywords = "pdf/a";
            document.DocumentInformation.Subject  = "PDF/A-1B Sample produced by XFINIUM.PDF";
            document.XmpMetadata = new PdfXmpMetadata();

            PdfPage page = document.Pages.Add();

            page.Rotation = 90;

            // All fonts must be embedded in a PDF/A document.
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Font  = new PdfAnsiTrueTypeFont(ttfInput, 24, true);
            sao.Brush = new PdfBrush(new PdfRgbColor(0, 0, 128));

            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Bottom;
            slo.X = page.Width / 2;
            slo.Y = page.Height / 2 - 10;
            page.Graphics.DrawString("XFINIUM.PDF", sao, slo);
            slo.Y             = page.Height / 2 + 10;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;
            sao.Font.Size     = 16;
            page.Graphics.DrawString("This is a sample PDF/A document that shows the PDF/A capabilities in XFINIUM.PDF library", sao, slo);

            // The document is formatted as PDF/A using the PdfAFormatter class:
            // PdfAFormatter.Save(document, outputStream, PdfAFormat.PdfA1b);
            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.pdfa.pdf") };
            return(output);
        }
예제 #10
0
        private PdfFixedDocument GenerateCertificatePdf(string userFullName, string title, DateTime quizTime)
        {
            PdfFixedDocument       document   = new PdfFixedDocument();
            PdfStandardFont        helvetica  = new PdfStandardFont(PdfStandardFontFace.Helvetica, 16);
            PdfBrush               blackBrush = new PdfBrush();
            PdfStringLayoutOptions slo        = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;

            helvetica.Size = 30;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Brush = blackBrush;
            sao.Font  = helvetica;

            PdfPage page = document.Pages.Add();

            page.Rotation = 90;

            // Add border
            PdfPen blackPen = new PdfPen(new PdfRgbColor(0, 0, 0), 48);

            page.Graphics.DrawRectangle(blackPen, 0, 0, page.Width, page.Height);

            var verticalSpacing = 45;

            // Add Text
            slo.X = 395;
            slo.Y = 70;
            page.Graphics.DrawString("This document certifies that", sao, slo);

            slo.Y += verticalSpacing;
            page.Graphics.DrawString(userFullName, sao, slo);

            slo.Y += verticalSpacing;
            page.Graphics.DrawString("has completed requirements for", sao, slo);

            slo.Y += verticalSpacing;
            page.Graphics.DrawString(title, sao, slo);

            slo.Y += verticalSpacing;
            page.Graphics.DrawString("on", sao, slo);

            slo.Y += verticalSpacing;
            page.Graphics.DrawString(quizTime.ToShortDateString(), sao, slo);

            DrawImages(page);

            return(document);
        }
예제 #11
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run(Stream iccInput, Stream ttfInput)
        {
            PdfFixedDocument document = new PdfFixedDocument();

            // Setup the document by creating a PDF/A output intent, based on a RGB ICC profile,
            // and document information and metadata
            PdfIccColorSpace icc = new PdfIccColorSpace();
            byte[] profilePayload = new byte[iccInput.Length];
            iccInput.Read(profilePayload, 0, profilePayload.Length);
            icc.IccProfile = profilePayload;
            PdfOutputIntent oi = new PdfOutputIntent();
            oi.Type = PdfOutputIntentType.PdfA1;
            oi.Info = "sRGB IEC61966-2.1";
            oi.OutputConditionIdentifier = "Custom";
            oi.DestinationOutputProfile = icc;
            document.OutputIntents = new PdfOutputIntentCollection();
            document.OutputIntents.Add(oi);

            document.DocumentInformation = new PdfDocumentInformation();
            document.DocumentInformation.Author = "XFINIUM Software";
            document.DocumentInformation.Title = "XFINIUM.PDF PDF/A-1B Demo";
            document.DocumentInformation.Creator = "XFINIUM.PDF PDF/A-1B Demo";
            document.DocumentInformation.Producer = "XFINIUM.PDF";
            document.DocumentInformation.Keywords = "pdf/a";
            document.DocumentInformation.Subject = "PDF/A-1B Sample produced by XFINIUM.PDF";
            document.XmpMetadata = new PdfXmpMetadata();

            PdfPage page = document.Pages.Add();
            page.Rotation = 90;

            // All fonts must be embedded in a PDF/A document.
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Font = new PdfAnsiTrueTypeFont(ttfInput, 24, true);
            sao.Brush = new PdfBrush(new PdfRgbColor(0, 0, 128));

            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Bottom;
            slo.X = page.Width / 2;
            slo.Y = page.Height / 2 - 10;
            page.Graphics.DrawString("XFINIUM.PDF", sao, slo);
            slo.Y = page.Height / 2 + 10;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;
            sao.Font.Size = 16;
            page.Graphics.DrawString("This is a sample PDF/A document that shows the PDF/A capabilities in XFINIUM.PDF library", sao, slo);

            // The document is formatted as PDF/A using the PdfAFormatter class:
            // PdfAFormatter.Save(document, outputStream, PdfAFormat.PdfA1b);
            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "xfinium.pdf.sample.pdfa.pdf") };
            return output;
        }
예제 #12
0
        private static void CreateRemoteGoToActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen   blackPen   = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Brush = blackBrush;
            sao.Font  = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;

            Random rnd = new Random();

            for (int i = 0; i < document.Pages.Count; i++)
            {
                int destinationPage = rnd.Next(document.Pages.Count);

                document.Pages[i].Graphics.DrawString("Go To Remote actions:", font, blackBrush, 400, 300);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 320, 200, 20);
                slo.X = 500;
                slo.Y = 330;
                document.Pages[i].Graphics.DrawString("Go To page " + (destinationPage + 1).ToString() + " in sample.pdf", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 320, 200, 20);

                // Create a GoToR action and attach it to the link.
                PdfPageNumberDestination pageDestination = new PdfPageNumberDestination();
                pageDestination.PageNumber = destinationPage;
                pageDestination.Left       = 0;
                pageDestination.Top        = 792;
                pageDestination.Zoom       = 0; // Keep current zoom
                PdfRemoteGoToAction remoteGoToAction = new PdfRemoteGoToAction();
                remoteGoToAction.FileName    = "sample.pdf";
                remoteGoToAction.Destination = pageDestination;
                link.Action = remoteGoToAction;
            }
        }
예제 #13
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 graphics to be located under existing page content.
            page.SetGraphicsPosition(PdfPageGraphicsPosition.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.Graphics.DrawString("Sample watermark under page content", sao, slo);
        }
        public TextColumn(string[] data, PdfStringAppearanceOptions appearance)
        {
            this.data       = data;
            this.appearance = appearance;

            for (int i = 0; i < data.Length; i++)
            {
                var size = PdfTextEngine.MeasureString(data[i], appearance.Font);
                if (size.Height > rowHeight)
                {
                    rowHeight = size.Height;
                }

                if (size.Width > columnWidth)
                {
                    columnWidth = size.Width;
                }
            }
        }
예제 #15
0
        private static void CreateRedactionAnnotations(PdfFixedDocument document, PdfFont font, Stream flashStream)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

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

            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 10);

            page.Graphics.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.Graphics.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.Graphics.DrawString("This content has been redacted", sao, slo);

            PdfRedactionAnnotation redactionAnnotation = new PdfRedactionAnnotation();

            page.Annotations.Add(redactionAnnotation);
            redactionAnnotation.Author            = "XFINIUM.PDF";
            redactionAnnotation.BorderColor       = new PdfRgbColor(192, 0, 0);
            redactionAnnotation.BorderWidth       = 1;
            redactionAnnotation.OverlayAppearance = redactionAppearance;
            redactionAnnotation.VisualRectangle   = new PdfVisualRectangle(50, 100, 250, 150);
        }
예제 #16
0
        private static void DrawTextRenderingModes(PdfPage page, PdfStandardFont titleFont)
        {
            PdfBrush        brush         = new PdfBrush();
            PdfPen          redPen        = new PdfPen(PdfRgbColor.Red, 0.5);
            PdfStandardFont helvetica     = new PdfStandardFont(PdfStandardFontFace.Helvetica, 12);
            PdfStandardFont helveticaBold = new PdfStandardFont(PdfStandardFontFace.Helvetica, 80);

            page.Graphics.DrawString("Text rendering modes", titleFont, brush, 20, 50);

            page.Graphics.DrawString("Fill text", helvetica, brush, 20, 90);
            page.Graphics.DrawString("Stroke text", helvetica, brush, 20, 160);
            page.Graphics.DrawString("Fill and stroke text", helvetica, brush, 20, 230);
            page.Graphics.DrawString("Invisible text", helvetica, brush, 20, 300);
            page.Graphics.DrawString("Fill and clip text", helvetica, brush, 20, 370);
            page.Graphics.DrawString("Stroke and clip text", helvetica, brush, 20, 440);
            page.Graphics.DrawString("Fill, stroke and clip text", helvetica, brush, 20, 510);
            page.Graphics.DrawString("Clip text", helvetica, brush, 20, 580);

            // Fill text - text interior is filled because only the brush is available for drawing.
            page.Graphics.DrawString("A B C", helveticaBold, brush, 300, 90);

            // Stroke text - text outline is stroked becuase only the pen is available for drawing.
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.X = 300;
            slo.Y = 160;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Font  = helveticaBold;
            sao.Pen   = redPen;
            sao.Brush = null;
            page.Graphics.DrawString("A B C", sao, slo);

            // Fill and stroke text - text interior is filled and text outline is stroked
            // because both pen and brush are available.
            slo.Y     = 230;
            sao.Pen   = redPen;
            sao.Brush = brush;
            page.Graphics.DrawString("A B C", sao, slo);

            // Invisible text - text is not displayed because both pen and brush are not available.
            slo.Y     = 300;
            sao.Pen   = null;
            sao.Brush = null;
            page.Graphics.DrawString("A B C", sao, slo);

            // Fill and clip text - text interior is filled and then text outline is added to current clipping path.
            page.Graphics.SaveGraphicsState();
            helveticaBold.TextRenderingMode = PdfTextRenderingMode.FillAndClipText;
            slo.Y     = 370;
            sao.Pen   = null;
            sao.Brush = brush;
            page.Graphics.DrawString("A B C", sao, slo);
            DrawHorizontalLines(page.Graphics, redPen, slo.X, slo.Y, 250, 70);
            page.Graphics.RestoreGraphicsState();

            // Stroke and clip text - text outline is stroked and then text outline is added to current clipping path.
            page.Graphics.SaveGraphicsState();
            helveticaBold.TextRenderingMode = PdfTextRenderingMode.StrokeAndClipText;
            slo.Y     = 440;
            sao.Pen   = redPen;
            sao.Brush = null;
            page.Graphics.DrawString("A B C", sao, slo);
            DrawHorizontalLines(page.Graphics, redPen, slo.X, slo.Y, 250, 70);
            page.Graphics.RestoreGraphicsState();

            // Fill, Stroke and clip text - text interior is filled, text outline is stroked and then text outline is added to current clipping path.
            page.Graphics.SaveGraphicsState();
            helveticaBold.TextRenderingMode = PdfTextRenderingMode.FillStrokeAndClipText;
            slo.Y     = 510;
            sao.Pen   = redPen;
            sao.Brush = brush;
            page.Graphics.DrawString("A B C", sao, slo);
            DrawHorizontalLines(page.Graphics, redPen, slo.X, slo.Y, 250, 70);
            page.Graphics.RestoreGraphicsState();

            // Clip text - text outline is added to current clipping path.
            page.Graphics.SaveGraphicsState();
            helveticaBold.TextRenderingMode = PdfTextRenderingMode.ClipText;
            slo.Y     = 580;
            sao.Pen   = redPen;
            sao.Brush = brush;
            page.Graphics.DrawString("A B C", sao, slo);
            DrawHorizontalLines(page.Graphics, redPen, slo.X, slo.Y, 250, 70);
            page.Graphics.RestoreGraphicsState();
        }
예제 #17
0
        public void DrawPdf(BATModel model)
        {
            try
            {
                PdfFixedDocument document = Load(HttpContext.Current.Server.MapPath(@"~\UserPDF\PdfTemplateLong.pdf"));
                PdfPage          page1    = document.Pages[0];
                PdfPage          page2    = document.Pages[1];
                DrawFirmFinancialsPage(page2, model);

                //VMI pages
                PdfPage page3 = document.Pages[2];
                DrawVMIPage(page3, 1, 0, model.Vmi_Man_Written_Plan, model.Vmi_Man_Track, model.Vmi_Man_Phase, model.Vmi_Man_Revenue, model.Vmi_Man_Practice, null);

                double width = page3.Width;

                PdfPage page4 = document.Pages[3];
                DrawVMIPage(page4, 4, 63, model.Vmi_Mar_Value_Proposition, model.Vmi_Mar_Materials, model.Vmi_Mar_Plan, model.Vmi_Mar_Prospects, model.Vmi_Mar_New_Business, null);

                PdfPage page5 = document.Pages[4];
                //DrawVMIPage(page5, 5, 63, model.Vmi_Opt_Automate, model.Vmi_Opt_Model, model.Vmi_Opt_Procedures, model.Vmi_Opt_Schedule, model.Vmi_Opt_Segment, null);
                DrawVMIPage(page5, 5, 63, model.Vmi_Opt_Automate, model.Vmi_Opt_Procedures, model.Vmi_Opt_Segment, model.Vmi_Opt_Model, model.Vmi_Opt_Schedule, null);

                PdfPage page6 = document.Pages[5];
                DrawVMIPage(page6, 6, 63, model.Vmi_Emp_Human, model.Vmi_Emp_Compensation, model.Vmi_Emp_Responsibilities, model.Vmi_Emp_Staff, model.Vmi_Emp_Emp_Retention, model);


                string timeRange = "Previous Year";

                if (!model.Year.ToLower().Contains("previous"))
                {
                    timeRange = "YTD " + DateTime.Now.Year;
                }

                page1.Graphics.DrawString(model.firstName + " " + model.lastName, new PdfStandardFont(PdfStandardFontFace.HelveticaBold, 16), textBlueBrush, 21, 20);
                page1.Graphics.DrawString(timeRange + ", " + "Created on " + DateTime.Now.ToString("d"), new PdfStandardFont(PdfStandardFontFace.HelveticaBold, 12.5), textBlueBrush, 370, 70);


                model.BenchmarksValuationModel = new BenchmarksValuationModel();
                BenchmarkGroup peerGroup = model.BenchmarksValuationModel.PeerGroups.FirstOrDefault(p => _Helpers.ConvertToDouble(model.Ff_TotalRevenueAnnualized) > p.GroupRangeMin && _Helpers.ConvertToDouble(model.Ff_TotalRevenueAnnualized) < p.GroupRangeMax);

                if (peerGroup == null && _Helpers.ConvertToDouble(model.Ff_TotalRevenueAnnualized) > 0)
                {
                    peerGroup = model.BenchmarksValuationModel.PeerGroups.Last();
                }
                else if (peerGroup == null && _Helpers.ConvertToDouble(model.Ff_TotalRevenueAnnualized) == 0)
                {
                    peerGroup = model.BenchmarksValuationModel.PeerGroups.First();
                }

                if (peerGroup == null)
                {
                    peerGroup = model.BenchmarksValuationModel.PeerGroups.Last();
                }

                int    groupNumber = model.BenchmarksValuationModel.PeerGroups.IndexOf(peerGroup);
                string group       = "$0 - $250K";

                if (groupNumber == 1)
                {
                    group = "$250K - $499K";
                }
                else if (groupNumber == 2)
                {
                    group = "$500K - $749K";
                }
                else if (groupNumber == 3)
                {
                    group = "$750K - $999K";
                }
                else if (groupNumber == 4)
                {
                    group = "$1M - $3M";
                }

                page1.Graphics.DrawString(group, helvetica, blackBrush, 500, 94);

                //============================================================== Firm Financials Table =============================================================
                page1.Graphics.DrawString(!string.IsNullOrEmpty(model.Ff_TotalFirmAsset) ? (_Helpers.ConvertToDouble(model.Ff_TotalFirmAsset)).ToString("C0") : "N/A", helvetica, blackBrush, 170, 128);
                page1.Graphics.DrawString(!string.IsNullOrEmpty(model.Ff_ClientRelationships) ? model.Ff_ClientRelationships : "N/A", helvetica, blackBrush, 170, 147);
                page1.Graphics.DrawString(!string.IsNullOrEmpty(model.Ff_RecurringRevenue) ? (Convert.ToInt32(_Helpers.ConvertToDouble(model.Ff_RecurringRevenueAnnualized))).ToString("C0") : "N/A", helvetica, blackBrush, 170, 165);
                page1.Graphics.DrawString(!string.IsNullOrEmpty(model.Ff_TotalRevenue) ? (Convert.ToInt32(_Helpers.ConvertToDouble(model.Ff_TotalRevenueAnnualized))).ToString("C0") : "N/A", helvetica, textBrush, 170, 183);

                if (!string.IsNullOrEmpty(model.Ff_DirectExpensesAnnualized) && !string.IsNullOrEmpty(model.Ff_IndirecteExpensesAnnualized))
                {
                    page1.Graphics.DrawString(Convert.ToInt32((_Helpers.ConvertToDouble(model.Ff_DirectExpensesAnnualized) + _Helpers.ConvertToDouble(model.Ff_IndirecteExpensesAnnualized))).ToString("C0"), helvetica, blackBrush, 170, 201);
                }
                else if (string.IsNullOrEmpty(model.Ff_DirectExpensesAnnualized))
                {
                    page1.Graphics.DrawString((Convert.ToInt32(_Helpers.ConvertToDouble(model.Ff_IndirecteExpensesAnnualized)).ToString("C0")), helvetica, blackBrush, 170, 201);
                }
                else
                {
                    page1.Graphics.DrawString((Convert.ToInt32(_Helpers.ConvertToDouble(model.Ff_DirectExpensesAnnualized)).ToString("C0")), helvetica, blackBrush, 170, 201);
                }

                page1.Graphics.DrawString(!string.IsNullOrEmpty(model.Ff_OperatingProfitAnnualized) ? Convert.ToInt32(_Helpers.ConvertToDouble(model.Ff_OperatingProfitAnnualized)).ToString("C0") : "N/A", helvetica, blackBrush, 170, 218);
                page1.Graphics.DrawString(!string.IsNullOrEmpty(model.Ff_ProjectedGrowthRate) ? model.Ff_ProjectedGrowthRate + "%" : "N/A", helvetica, blackBrush, 170, 236);

                page1.Graphics.DrawString(peerGroup.AUM.ToString("C0"), helvetica, blackBrush, 290, 128);
                page1.Graphics.DrawString(peerGroup.ClientRelationships.ToString(), helvetica, blackBrush, 290, 147);
                page1.Graphics.DrawString(peerGroup.RecurringRevenue.ToString("C0"), helvetica, blackBrush, 290, 165);
                page1.Graphics.DrawString(peerGroup.TotalRevenue.ToString("C0"), helvetica, blackBrush, 290, 183);
                page1.Graphics.DrawString(peerGroup.TotalExpenses.ToString("C0"), helvetica, blackBrush, 290, 201);
                page1.Graphics.DrawString(peerGroup.OperatingProfit.ToString("C0"), helvetica, blackBrush, 290, 218);
                page1.Graphics.DrawString(peerGroup.ProjectedAnnualGrowthRate.ToString("0") + "%", helvetica, blackBrush, 290, 236);


                //============================================================== KPI's Table =============================================================

                page1.Graphics.DrawString(GetTimeRange(model), helveticaBold, blackBrush, 165, 539);

                page1.Graphics.DrawString(_Helpers.ConvertToDouble(model.ClientValuationModel.RecurringRevenuePerClient).ToString("c0"), helvetica, blackBrush, 170, 557);
                page1.Graphics.DrawString(_Helpers.ConvertToDouble(model.ClientValuationModel.RecurringRevenuePerAdvisor).ToString("C0"), helvetica, blackBrush, 170, 576);
                page1.Graphics.DrawString(_Helpers.ConvertToDouble(model.ClientValuationModel.TotalRevenuePerClient).ToString("C0"), helvetica, blackBrush, 170, 595);
                page1.Graphics.DrawString(_Helpers.ConvertToDouble(model.ClientValuationModel.TotalAUMperClient).ToString("C0"), helvetica, blackBrush, 170, 611);
                page1.Graphics.DrawString(_Helpers.ConvertToDouble(model.ClientValuationModel.TotalAUMperAdvisor).ToString("C0"), helvetica, blackBrush, 170, 627);
                page1.Graphics.DrawString(_Helpers.ConvertToDouble(model.ClientValuationModel.ProfitPerClient).ToString("C0"), helvetica, blackBrush, 170, 644);
                page1.Graphics.DrawString(_Helpers.ConvertToDouble(model.ClientValuationModel.ProfitAsPercentOfRevenue).ToString("0") + " %", helvetica, blackBrush, 170, 661);
                page1.Graphics.DrawString(((int)_Helpers.ConvertToDouble(model.ClientValuationModel.ClientsPerAdvisor)).ToString(), helvetica, blackBrush, 170, 680);
                page1.Graphics.DrawString(((int)_Helpers.ConvertToDouble(model.ClientValuationModel.RevenueAsBPSOnAssets)).ToString(), helvetica, blackBrush, 170, 699);

                page1.Graphics.DrawString(Math.Ceiling(peerGroup.RecRevPerClient).ToString("C0"), helvetica, blackBrush, 290, 557);
                page1.Graphics.DrawString(Math.Ceiling(peerGroup.RecRevPerAdvisor).ToString("C0"), helvetica, blackBrush, 290, 576);
                page1.Graphics.DrawString(Math.Ceiling(peerGroup.TotalRevPerClient).ToString("C0"), helvetica, blackBrush, 290, 595);
                page1.Graphics.DrawString(Math.Ceiling(peerGroup.TotalAUMPerClient).ToString("C0"), helvetica, blackBrush, 290, 611);
                page1.Graphics.DrawString(Math.Ceiling(peerGroup.TotalAUMPerAdvisor).ToString("C0"), helvetica, blackBrush, 290, 627);
                page1.Graphics.DrawString(peerGroup.ProfitPerClient.ToString("C0"), helvetica, blackBrush, 290, 644);
                page1.Graphics.DrawString(peerGroup.ProfitAsPercentOfRevenue.ToString("0") + " %", helvetica, blackBrush, 290, 661);
                page1.Graphics.DrawString(peerGroup.ClientsPerAdvisor.ToString(), helvetica, blackBrush, 290, 680);
                page1.Graphics.DrawString(peerGroup.RevenueAsPBSOnAssets.ToString(), helvetica, blackBrush, 290, 699);



                //Graph brushes
                PdfBrush graphBrush1 = new PdfBrush((new PdfRgbColor(0, 74, 129)));    //#004b81 Darkest
                PdfBrush graphBrush2 = new PdfBrush((new PdfRgbColor(0, 126, 187)));   // #007ebb
                PdfBrush graphBrush3 = new PdfBrush((new PdfRgbColor(109, 198, 233))); //#6dc6e7;
                PdfBrush graphBrush4 = new PdfBrush((new PdfRgbColor(176, 216, 235))); //#b0d8eb;

                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////////////                                                      VMI GRAPH                                                           /////////////////////
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(35, 300), new PdfPoint(35, 415)); //vertical
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(35, 300), new PdfPoint(255, 300));
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(35, 327), new PdfPoint(255, 327));
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(35, 349), new PdfPoint(255, 349));
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(35, 371), new PdfPoint(255, 371));
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(35, 393), new PdfPoint(255, 393));
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.Black, 1), new PdfPoint(35, 415), new PdfPoint(255, 415)); //horizontal

                page1.Graphics.DrawString("1000", helvetica, textBrush, 15, 298);
                page1.Graphics.DrawString("800", helvetica, textBrush, 19, 321);
                page1.Graphics.DrawString("600", helvetica, textBrush, 19, 343);
                page1.Graphics.DrawString("400", helvetica, textBrush, 19, 365);
                page1.Graphics.DrawString("200", helvetica, textBrush, 19, 387);
                page1.Graphics.DrawString("0", helvetica, textBrush, 27, 409);
                page1.Graphics.DrawString("Your Firm", helvetica, textBlueBrush, 70, 419);
                page1.Graphics.DrawString("Benchmark Index", helvetica, textBlueBrush, 160, 419);

                //Calculate blocks height for Your Firm
                model.ClientValuationModel.ManagingYourPracticeScore     = (Convert.ToInt32(model.Vmi_Man_Written_Plan) + Convert.ToInt32(model.Vmi_Man_Track) + Convert.ToInt32(model.Vmi_Man_Phase) + Convert.ToInt32(model.Vmi_Man_Revenue) + Convert.ToInt32(model.Vmi_Man_Practice)) * 5;
                model.ClientValuationModel.MarketingYourBusinessScore    = (Convert.ToInt32(model.Vmi_Mar_Value_Proposition) + Convert.ToInt32(model.Vmi_Mar_Materials) + Convert.ToInt32(model.Vmi_Mar_Plan) + Convert.ToInt32(model.Vmi_Mar_Prospects) + Convert.ToInt32(model.Vmi_Mar_New_Business)) * 5;
                model.ClientValuationModel.EmpoweringYourTeamScore       = (Convert.ToInt32(model.Vmi_Emp_Human) + Convert.ToInt32(model.Vmi_Emp_Compensation) + Convert.ToInt32(model.Vmi_Emp_Responsibilities) + Convert.ToInt32(model.Vmi_Emp_Staff) + Convert.ToInt32(model.Vmi_Emp_Emp_Retention)) * 5;
                model.ClientValuationModel.OptimizingYourOperationsScore = (Convert.ToInt32(model.Vmi_Opt_Automate) + Convert.ToInt32(model.Vmi_Opt_Procedures) + Convert.ToInt32(model.Vmi_Opt_Segment) + Convert.ToInt32(model.Vmi_Opt_Model) + Convert.ToInt32(model.Vmi_Opt_Schedule)) * 5;

                double pixel       = 0.115;
                double firstBlock  = model.ClientValuationModel.EmpoweringYourTeamScore * pixel;
                double secondBlock = model.ClientValuationModel.OptimizingYourOperationsScore * pixel;
                double thirdBlock  = model.ClientValuationModel.MarketingYourBusinessScore * pixel;
                double fourthBlock = model.ClientValuationModel.ManagingYourPracticeScore * pixel;

                double x = 70;
                double y = 415 - (firstBlock + secondBlock + thirdBlock + fourthBlock);

                page1.Graphics.DrawString(model.Vmi_Index, helvetica, grayBrush, x + 20, y - 15);  //VMI Index

                page1.Graphics.DrawRectangle(graphBrush4, x, y, 55, fourthBlock);
                page1.Graphics.DrawString(model.ClientValuationModel.ManagingYourPracticeScore.ToString(), helvetica, whiteBrush, x + 20, y + ((fourthBlock / 2) - 2)); //score

                y = y + fourthBlock;
                page1.Graphics.DrawRectangle(graphBrush3, x, y, 55, thirdBlock);
                page1.Graphics.DrawString(model.ClientValuationModel.MarketingYourBusinessScore.ToString(), helvetica, whiteBrush, x + 20, y + ((thirdBlock / 2) - 2)); //score

                y = y + thirdBlock;
                page1.Graphics.DrawRectangle(graphBrush2, x, y, 55, secondBlock);
                page1.Graphics.DrawString(model.ClientValuationModel.OptimizingYourOperationsScore.ToString(), helvetica, whiteBrush, x + 20, y + ((secondBlock / 2) - 2)); //score

                y = y + secondBlock;
                page1.Graphics.DrawRectangle(graphBrush1, x, y, 55, firstBlock);
                page1.Graphics.DrawString(model.ClientValuationModel.EmpoweringYourTeamScore.ToString(), helvetica, whiteBrush, x + 20, y + ((firstBlock / 2) - 2)); //score



                //Calculate blocks height for Benchmarks
                firstBlock  = peerGroup.EYT * pixel;
                secondBlock = peerGroup.OYO * pixel;
                thirdBlock  = peerGroup.MYB * pixel;
                fourthBlock = peerGroup.MYP * pixel;

                x = 160;
                y = 415 - (firstBlock + secondBlock + thirdBlock + fourthBlock);

                page1.Graphics.DrawString((peerGroup.MYB + peerGroup.MYP + peerGroup.EYT + peerGroup.OYO).ToString(), helvetica, grayBrush, x + 20, y - 15); //VMI Index

                page1.Graphics.DrawRectangle(graphBrush4, x, y, 55, fourthBlock);
                page1.Graphics.DrawString(peerGroup.MYP.ToString(), helvetica, whiteBrush, x + 20, y + ((fourthBlock / 2) - 2)); //score

                y = y + fourthBlock;
                page1.Graphics.DrawRectangle(graphBrush3, x, y, 55, thirdBlock);
                page1.Graphics.DrawString(peerGroup.MYB.ToString(), helvetica, whiteBrush, x + 20, y + ((thirdBlock / 2) - 2)); //score

                y = y + thirdBlock;
                page1.Graphics.DrawRectangle(graphBrush2, x, y, 55, secondBlock);
                page1.Graphics.DrawString(peerGroup.OYO.ToString(), helvetica, whiteBrush, x + 20, y + ((secondBlock / 2) - 2)); //score

                y = y + secondBlock;
                page1.Graphics.DrawRectangle(graphBrush1, x, y, 55, firstBlock);
                page1.Graphics.DrawString(peerGroup.EYT.ToString(), helvetica, whiteBrush, x + 20, y + ((firstBlock / 2) - 2)); //score



                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///////////////                                                  VALUATION RANGE GRAPH                                                           /////////////////////
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                double axisMax = peerGroup.ValuationMax + (peerGroup.ValuationMax / 4);
                pixel = axisMax / 135;

                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(353, 300), new PdfPoint(353, 435)); //vertical
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.Black, 1), new PdfPoint(353, 435), new PdfPoint(550, 435));       //horizontal

                //Gray lines
                y = 300;
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(353, y), new PdfPoint(550, y)); //horizontal
                y = y + 34;
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(353, y), new PdfPoint(550, y)); //horizontal
                y = y + 34;
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(353, y), new PdfPoint(550, y)); //horizontal
                y = y + 34;
                page1.Graphics.DrawLine(new PdfPen(PdfRgbColor.LightGray, 0.5), new PdfPoint(353, y), new PdfPoint(550, y)); //horizontal


                page1.Graphics.DrawString("Your Firm", helvetica, textBlueBrush, 390, 440);
                page1.Graphics.DrawString("Benchmark Index", helvetica, textBlueBrush, 470, 440);


                //Client Valuation Range
                if (model.ClientValuationModel.ValuationMax != 0 && model.ClientValuationModel.ValuationMin != 0)
                {
                    if (model.ClientValuationModel.ValuationMax > peerGroup.ValuationMax)
                    {
                        axisMax = model.ClientValuationModel.ValuationMax + (model.ClientValuationModel.ValuationMax / 4);
                        pixel   = axisMax / 135;
                    }

                    firstBlock = (model.ClientValuationModel.ValuationMax - model.ClientValuationModel.ValuationMin) / pixel;


                    x = 390;
                    y = 435 - (model.ClientValuationModel.ValuationMax / pixel);
                    page1.Graphics.DrawRectangle(graphBrush2, x, y, 55, firstBlock);
                    page1.Graphics.DrawString(((int)Math.Round(model.ClientValuationModel.ValuationMax / 1000) * 1000).ToString("C0"), helvetica, textBrush, x, (y - 9));
                    page1.Graphics.DrawString(((int)Math.Round(model.ClientValuationModel.ValuationMin / 1000) * 1000).ToString("C0"), helvetica, textBrush, x, (y + firstBlock + 3));
                }
                else
                {
                    x = 400;
                    page1.Graphics.DrawString("No Data", helvetica, textBrush, x, 350);
                }



                //Benchmark Valuation Range
                double dollarsInPixel = axisMax / 135;
                double range          = peerGroup.ValuationMax - peerGroup.ValuationMin;
                double height         = range / dollarsInPixel; //height in pixels

                x = 470;
                y = peerGroup.ValuationMax / dollarsInPixel;
                y = 435 - y; //bottom of range

                page1.Graphics.DrawString(peerGroup.ValuationMax.ToString("C0"), helvetica, textBrush, x, (y - 9));
                page1.Graphics.DrawRectangle(graphBrush3, x, y, 55, height);
                page1.Graphics.DrawString(peerGroup.ValuationMin.ToString("C0"), helvetica, textBrush, x, (y + height + 3));

                //Axis values
                PdfStringLayoutOptions layout = new PdfStringLayoutOptions()
                {
                    HorizontalAlign = PdfStringHorizontalAlign.Right, X = 351, Y = 300
                };
                PdfPen pen = new PdfPen(PdfRgbColor.Black, 0.007);
                PdfStringAppearanceOptions appearance = new PdfStringAppearanceOptions(helvetica, pen, textBrush);

                page1.Graphics.DrawString("$0", helvetica, textBrush, 342, 430);
                page1.Graphics.DrawString(((int)Math.Round(axisMax / 1000) * 1000).ToString("C0"), appearance, layout);

                double incrementHeight = 135 / 4;
                double incrementValue  = axisMax / 4;

                layout.Y = layout.Y + incrementHeight;
                page1.Graphics.DrawString(((int)Math.Round((axisMax - incrementValue) / 1000) * 1000).ToString("C0"), appearance, layout);

                layout.Y = layout.Y + incrementHeight;
                page1.Graphics.DrawString(((int)Math.Round((axisMax / 2) / 1000) * 1000).ToString("C0"), appearance, layout);

                layout.Y = layout.Y + incrementHeight;
                page1.Graphics.DrawString(((int)Math.Round((axisMax - (incrementValue * 3)) / 1000) * 1000).ToString("C0"), appearance, layout);

                page1.Width = 612;

                //Upload the PDF to Azure storage
                MemoryStream stream = new MemoryStream();
                document.Save(stream);

                //document.Save("C:\\Olga\\PdfCustom.pdf");



                byte[] docBytes = stream.ToArray();
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]); //connection string is copied from Azure storage account's Settings
                CloudBlobClient     client         = storageAccount.CreateCloudBlobClient();
                CloudBlobContainer  myContainer    = client.GetContainerReference("assetmarkbat");
                var permissions = myContainer.GetPermissions();
                permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
                myContainer.SetPermissions(permissions);
                CloudBlockBlob blockBlob = myContainer.GetBlockBlobReference(model.UserId + ".pdf");
                blockBlob.Properties.ContentType = "application/pdf";
                blockBlob.UploadFromByteArray(docBytes, 0, docBytes.Count());
            }
            catch (Exception e)
            {
                Console.WriteLine("Error creating a PDF document", e.Message);
            }
        }
예제 #18
0
        private static void DrawTextWrap(PdfPage page, PdfStandardFont titleFont)
        {
            PdfBrush        brush     = new PdfBrush();
            PdfPen          redPen    = new PdfPen(PdfRgbColor.Red, 0.5);
            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 12);

            page.Graphics.DrawString("Text wrapping", titleFont, brush, 20, 50);

            page.Graphics.DrawLine(redPen, 20, 70, 20, 150);
            page.Graphics.DrawLine(redPen, 300, 70, 300, 150);
            page.Graphics.DrawLine(redPen, 20, 70, 300, 70);

            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Brush = brush;
            sao.Font  = helvetica;

            // Height is not set, text has no vertical limit.
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Justified;
            slo.VerticalAlign   = PdfStringVerticalAlign.Top;
            slo.X     = 20;
            slo.Y     = 70;
            slo.Width = 280;
            string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
                          "Sed vel euismod risus. Fusce viverra, nisi auctor ullamcorper porttitor, " +
                          "ipsum lacus lobortis metus, sit amet dictum lacus velit nec diam. " +
                          "Morbi arcu diam, euismod a auctor nec, aliquam in lectus." +
                          "Ut ultricies iaculis augue sit amet adipiscing. Aenean blandit tortor a nisi " +
                          "dignissim fermentum id adipiscing mauris. Aenean libero turpis, varius nec ultricies " +
                          "faucibus, pretium quis lectus. Morbi mollis lorem vel erat condimentum mattis mollis " +
                          "nulla sollicitudin. Nunc ut massa id felis laoreet feugiat eget at eros.";

            page.Graphics.DrawString(text, sao, slo);

            page.Graphics.DrawLine(redPen, 310, 70, 310, 147);
            page.Graphics.DrawLine(redPen, 590, 70, 590, 147);
            page.Graphics.DrawLine(redPen, 310, 70, 590, 70);
            page.Graphics.DrawLine(redPen, 310, 147, 590, 147);

            // Height is set, text is limited on vertical.
            slo.X      = 310;
            slo.Y      = 70;
            slo.Width  = 280;
            slo.Height = 77;
            page.Graphics.DrawString(text, sao, slo);

            PdfPath clipPath = new PdfPath();

            clipPath.AddRectangle(310, 160, 280, 77);
            page.Graphics.DrawPath(redPen, clipPath);

            page.Graphics.SaveGraphicsState();
            page.Graphics.SetClip(clipPath);

            // Height is not set but text is cliped on vertical.
            slo.X      = 310;
            slo.Y      = 160;
            slo.Width  = 280;
            slo.Height = 0;
            page.Graphics.DrawString(text, sao, slo);

            page.Graphics.RestoreGraphicsState();

            page.Graphics.DrawLine(redPen, 10, 400, 300, 400);
            page.Graphics.DrawLine(redPen, 20, 300, 20, 500);
            // Wrapped text is always rotated around top left corner, no matter the text alignment
            page.Graphics.DrawRectangle(redPen, 20, 400, 280, 80, 30);
            slo.X        = 20;
            slo.Y        = 400;
            slo.Width    = 280;
            slo.Height   = 80;
            slo.Rotation = 30;
            page.Graphics.DrawString(text, sao, slo);

            page.Graphics.DrawLine(redPen, 310, 600, 590, 600);
            page.Graphics.DrawLine(redPen, 450, 450, 450, 750);

            // Rotation around the center of the box requires some affine transformations.
            page.Graphics.SaveGraphicsState();
            page.Graphics.TranslateTransform(450, 600);
            page.Graphics.RotateTransform(30);
            page.Graphics.DrawRectangle(redPen, -140, -40, 280, 80);
            slo.X        = -140;
            slo.Y        = -40;
            slo.Width    = 280;
            slo.Height   = 80;
            slo.Rotation = 0;
            page.Graphics.DrawString(text, sao, slo);

            page.Graphics.RestoreGraphicsState();
        }
예제 #19
0
        private static void DrawTextLines(PdfPage page, PdfStandardFont titleFont)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen redPen = new PdfPen(PdfRgbColor.Red, 0.5);
            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 12);

            page.Graphics.DrawString("Text lines", titleFont, brush, 20, 50);

            page.Graphics.DrawLine(redPen, 20, 70, 150, 70);
            page.Graphics.DrawLine(redPen, 20, 70, 20, 80);
            page.Graphics.DrawString("Simple text line with default top left text alignment and no rotation", helvetica, brush, 20, 70);

            page.Graphics.DrawString("Text align", helvetica, brush, 20, 110);

            redPen.DashPattern = new double[] { 1, 1 };
            page.Graphics.DrawLine(redPen, 20, 125, 590, 125);
            page.Graphics.DrawLine(redPen, 20, 165, 590, 165);
            page.Graphics.DrawLine(redPen, 20, 205, 590, 205);
            page.Graphics.DrawLine(redPen, 20, 125, 20, 205);
            page.Graphics.DrawLine(redPen, 305, 125, 305, 205);
            page.Graphics.DrawLine(redPen, 590, 125, 590, 205);

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

            // Top left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;
            slo.X = 20;
            slo.Y = 125;
            page.Graphics.DrawString("Top Left", sao, slo);

            // Top center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;
            slo.X = 305;
            slo.Y = 125;
            page.Graphics.DrawString("Top Center", sao, slo);

            // Top right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;
            slo.X = 590;
            slo.Y = 125;
            page.Graphics.DrawString("Top Right", sao, slo);

            // Middle left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;
            slo.X = 20;
            slo.Y = 165;
            page.Graphics.DrawString("Middle Left", sao, slo);

            // Middle center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;
            slo.X = 305;
            slo.Y = 165;
            page.Graphics.DrawString("Middle Center", sao, slo);

            // Middle right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;
            slo.X = 590;
            slo.Y = 165;
            page.Graphics.DrawString("Middle Right", sao, slo);

            // Bottom left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign = PdfStringVerticalAlign.Bottom;
            slo.X = 20;
            slo.Y = 205;
            page.Graphics.DrawString("Bottom Left", sao, slo);

            // Bottom center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Bottom;
            slo.X = 305;
            slo.Y = 205;
            page.Graphics.DrawString("Bottom Center", sao, slo);

            // Bottom right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign = PdfStringVerticalAlign.Bottom;
            slo.X = 590;
            slo.Y = 205;
            page.Graphics.DrawString("Bottom Right", sao, slo);

            page.Graphics.DrawString("Text rotation", helvetica, brush, 20, 250);

            redPen.DashPattern = new double[] { 1, 1 };
            page.Graphics.DrawLine(redPen, 20, 265, 590, 265);
            page.Graphics.DrawLine(redPen, 20, 305, 590, 305);
            page.Graphics.DrawLine(redPen, 20, 345, 590, 345);
            page.Graphics.DrawLine(redPen, 20, 265, 20, 345);
            page.Graphics.DrawLine(redPen, 305, 265, 305, 345);
            page.Graphics.DrawLine(redPen, 590, 265, 590, 345);

            slo.Rotation = 30;
            // Top left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;
            slo.X = 20;
            slo.Y = 265;
            page.Graphics.DrawString("Top Left", sao, slo);

            // Top center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;
            slo.X = 305;
            slo.Y = 265;
            page.Graphics.DrawString("Top Center", sao, slo);

            // Top right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;
            slo.X = 590;
            slo.Y = 265;
            page.Graphics.DrawString("Top Right", sao, slo);

            // Middle left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;
            slo.X = 20;
            slo.Y = 305;
            page.Graphics.DrawString("Middle Left", sao, slo);

            // Middle center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;
            slo.X = 305;
            slo.Y = 305;
            page.Graphics.DrawString("Middle Center", sao, slo);

            // Middle right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;
            slo.X = 590;
            slo.Y = 305;
            page.Graphics.DrawString("Middle Right", sao, slo);

            // Bottom left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign = PdfStringVerticalAlign.Bottom;
            slo.X = 20;
            slo.Y = 345;
            page.Graphics.DrawString("Bottom Left", sao, slo);

            // Bottom center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Bottom;
            slo.X = 305;
            slo.Y = 345;
            page.Graphics.DrawString("Bottom Center", sao, slo);

            // Bottom right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign = PdfStringVerticalAlign.Bottom;
            slo.X = 590;
            slo.Y = 345;
            page.Graphics.DrawString("Bottom Right", sao, slo);

            page.Graphics.CompressAndClose();
        }
예제 #20
0
        private static void CreateNamedActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen   blackPen   = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Brush = blackBrush;
            sao.Font  = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("Named actions:", font, blackBrush, 400, 20);

                /////////////
                // First page
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 40, 200, 20);
                slo.X = 500;
                slo.Y = 50;
                document.Pages[i].Graphics.DrawString("Go To First Page", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 40, 200, 20);

                // Create a named action and attach it to the link.
                PdfNamedAction namedAction = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.FirstPage;
                link.Action             = namedAction;

                /////////////
                // Prev page
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 80, 200, 20);
                slo.Y = 90;
                document.Pages[i].Graphics.DrawString("Go To Previous Page", sao, slo);

                // Create a link annotation on top of the widget.
                link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 80, 200, 20);

                // Create a named action and attach it to the link.
                namedAction             = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.PrevPage;
                link.Action             = namedAction;

                /////////////
                // Next page
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 120, 200, 20);
                slo.Y = 130;
                document.Pages[i].Graphics.DrawString("Go To Next Page", sao, slo);

                // Create a link annotation on top of the widget.
                link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 120, 200, 20);

                // Create a named action and attach it to the link.
                namedAction             = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.NextPage;
                link.Action             = namedAction;

                /////////////
                // Last page
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 160, 200, 20);
                slo.Y = 170;
                document.Pages[i].Graphics.DrawString("Go To Last Page", sao, slo);

                // Create a link annotation on top of the widget.
                link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 160, 200, 20);

                // Create a named action and attach it to the link.
                namedAction             = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.LastPage;
                link.Action             = namedAction;

                /////////////
                // Print document
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 200, 200, 20);
                slo.Y = 210;
                document.Pages[i].Graphics.DrawString("Print Document", sao, slo);

                // Create a link annotation on top of the widget.
                link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 200, 200, 20);

                // Create a named action and attach it to the link.
                namedAction             = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.Print;
                link.Action             = namedAction;
            }
        }
예제 #21
0
        private static void CreateRedactionAnnotations(PdfFixedDocument document, PdfFont font, Stream flashStream)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

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

            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 10);
            page.Graphics.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.Graphics.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.Graphics.DrawString("This content has been redacted", sao, slo);

            PdfRedactionAnnotation redactionAnnotation = new PdfRedactionAnnotation();
            page.Annotations.Add(redactionAnnotation);
            redactionAnnotation.Author = "XFINIUM.PDF";
            redactionAnnotation.BorderColor = new PdfRgbColor(192, 0, 0);
            redactionAnnotation.BorderWidth = 1;
            redactionAnnotation.OverlayAppearance = redactionAppearance;
            redactionAnnotation.VisualRectangle = new PdfVisualRectangle(50, 100, 250, 150);
        }
예제 #22
0
        private static void CreateTextMarkupAnnotations(PdfFixedDocument document, PdfFont font)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

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

            PdfTextMarkupAnnotationType[] tmat = new PdfTextMarkupAnnotationType[]
                {
                    PdfTextMarkupAnnotationType.Highlight, PdfTextMarkupAnnotationType.Squiggly, PdfTextMarkupAnnotationType.StrikeOut, PdfTextMarkupAnnotationType.Underline
                };

            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = blackBrush;
            sao.Font = font;

            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Bottom;
            for (int i = 0; i < tmat.Length; i++)
            {
                PdfTextMarkupAnnotation tma = new PdfTextMarkupAnnotation();
                page.Annotations.Add(tma);
                tma.VisualRectangle = new PdfVisualRectangle(50, 100 + 50 * i, 200, font.Size + 2);
                tma.TextMarkupType = tmat[i];

                slo.X = 150;
                slo.Y = 100 + 50 * i + font.Size;

                page.Graphics.DrawString(tmat[i].ToString() + " annotation.", sao, slo);
            }
        }
예제 #23
0
        private static void CreateGoToActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen blackPen = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = blackBrush;
            sao.Font = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;

            Random rnd = new Random();
            for (int i = 0; i < document.Pages.Count; i++)
            {
                int destinationPage = rnd.Next(document.Pages.Count);

                document.Pages[i].Graphics.DrawString("Go To actions:", font, blackBrush, 400, 240);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 260, 200, 20);
                slo.X = 500;
                slo.Y = 270;
                document.Pages[i].Graphics.DrawString("Go To page: " + (destinationPage + 1).ToString(), sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 260, 200, 20);

                // Create a GoTo action and attach it to the link.
                PdfPageDirectDestination pageDestination = new PdfPageDirectDestination();
                pageDestination.Page = document.Pages[destinationPage];
                pageDestination.Left = 0;
                pageDestination.Top = 0;
                pageDestination.Zoom = 0; // Keep current zoom
                PdfGoToAction gotoPageAction = new PdfGoToAction();
                gotoPageAction.Destination = pageDestination;
                link.Action = gotoPageAction;
            }
        }
예제 #24
0
        private static void DrawPostAndTransportantionBarcodes(PdfPage page, PdfFont titleFont, PdfFont barcodeFont)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen lightGrayPen = new PdfPen(PdfRgbColor.LightGray, 0.5);

            page.Graphics.DrawString("Post and transportation barcodes", titleFont, brush, 40, 20);
            for (int i = 0; i < 7; i++)
            {
                page.Graphics.DrawLine(lightGrayPen, 40, 50 + 100 * i, 570, 50 + 100 * i);
            }
            page.Graphics.DrawLine(lightGrayPen, 306, 50, 306, 750);

            string[] barcodes = new string[] { "FedEx Ground 96", "IATA 25", "Identcode", "Leitcode", "KIX", "Planet",
                "PostNet", "RM4SCC", "SCC-14", "SingaporePost", "SSCC-18", "USPS FIM", "USPS Horizontal", "USPS PIC" };
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = brush;
            sao.Font = barcodeFont;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;

            slo.X = 173;
            int sign = 1;
            for (int i = 0; i < barcodes.Length; i++)
            {
                slo.Y = 55 + 100 * (i / 2);

                page.Graphics.DrawString(barcodes[i], sao, slo);

                slo.X = slo.X + sign * 266;
                sign = -sign;
            }

            // FedEx Ground 96
            PdfFedExGround96Barcode fedexGround96Barcode = new PdfFedExGround96Barcode();
            fedexGround96Barcode.Data = "962343237687543423123";
            fedexGround96Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(fedexGround96Barcode, 173 - fedexGround96Barcode.Width / 2, 70);

            // IATA 25
            PdfIata25Barcode iata25Barcode = new PdfIata25Barcode();
            iata25Barcode.Data = "54366436563";
            iata25Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(iata25Barcode, 173 + 266 - iata25Barcode.Width / 2, 70);

            // Identcode
            PdfIdentcodeBarcode identcodeBarcode = new PdfIdentcodeBarcode();
            identcodeBarcode.Data = "12435678214";
            identcodeBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(identcodeBarcode, 173 - identcodeBarcode.Width / 2, 170);

            // Leitcode
            PdfLeitcodeBarcode leitcodeBarcode = new PdfLeitcodeBarcode();
            leitcodeBarcode.Data = "1243657687321";
            leitcodeBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(leitcodeBarcode, 173 + 266 - leitcodeBarcode.Width / 2, 170);

            // KIX
            PdfKixBarcode kixBarcode = new PdfKixBarcode();
            kixBarcode.Data = "XFINIUMPDF";
            kixBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(kixBarcode, 173 - kixBarcode.Width / 2, 270);

            // Planet
            PdfPlanetBarcode planetBarcode = new PdfPlanetBarcode();
            planetBarcode.Data = "645316643300";
            planetBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(planetBarcode, 173 + 266 - planetBarcode.Width / 2, 270);

            // PostNet
            PdfPostNetBarcode postNetBarcode = new PdfPostNetBarcode();
            postNetBarcode.Data = "04231454322";
            postNetBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(postNetBarcode, 173 - postNetBarcode.Width / 2, 370);

            // RM4SCC
            PdfRm4sccBarcode rm4sccBarcode = new PdfRm4sccBarcode();
            rm4sccBarcode.Data = "XFINIUMPDF";
            rm4sccBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(rm4sccBarcode, 173 + 266 - rm4sccBarcode.Width / 2, 370);

            // SCC-14
            PdfScc14Barcode scc14Barcode = new PdfScc14Barcode();
            scc14Barcode.Data = "3255091205412";
            scc14Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(scc14Barcode, 173 - scc14Barcode.Width / 2, 470);

            // Singapore Post
            PdfSingaporePostBarcode singaporePostBarcode = new PdfSingaporePostBarcode();
            singaporePostBarcode.Data = "XFINIUMPDF";
            singaporePostBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(singaporePostBarcode, 173 + 266 - singaporePostBarcode.Width / 2, 470);

            // SSCC-18
            PdfSscc18Barcode sscc18Barcode = new PdfSscc18Barcode();
            sscc18Barcode.Data = "09876543219832435";
            sscc18Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(sscc18Barcode, 173 - sscc18Barcode.Width / 2, 570);

            // USPS FIM
            PdfUspsFimBarcode uspsFimBarcode = new PdfUspsFimBarcode();
            uspsFimBarcode.Data = "A";
            uspsFimBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(uspsFimBarcode, 173 + 266 - uspsFimBarcode.Width / 2, 570);

            // USPS Horizontal
            PdfUspsHorizontalBarcode uspsHorizontalBarcode = new PdfUspsHorizontalBarcode();
            uspsHorizontalBarcode.Data = "1111";
            uspsHorizontalBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.None;
            page.Graphics.DrawBarcode(uspsHorizontalBarcode, 173 - uspsHorizontalBarcode.Width / 2, 670);

            // USPS PIC
            PdfUspsPicBarcode uspsPicBarcode = new PdfUspsPicBarcode();
            uspsPicBarcode.Data = "914354657901234354019";
            uspsPicBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(uspsPicBarcode, 173 + 266 - uspsPicBarcode.Width / 2, 670);

            page.Graphics.CompressAndClose();
        }
예제 #25
0
        private static void DrawTextWrap(PdfPage page, PdfStandardFont titleFont)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen redPen = new PdfPen(PdfRgbColor.Red, 0.5);
            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 12);

            page.Graphics.DrawString("Text wrapping", titleFont, brush, 20, 50);

            page.Graphics.DrawLine(redPen, 20, 70, 20, 150);
            page.Graphics.DrawLine(redPen, 300, 70, 300, 150);
            page.Graphics.DrawLine(redPen, 20, 70, 300, 70);

            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = brush;
            sao.Font = helvetica;

            // Height is not set, text has no vertical limit.
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Justified;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;
            slo.X = 20;
            slo.Y = 70;
            slo.Width = 280;
            string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
                "Sed vel euismod risus. Fusce viverra, nisi auctor ullamcorper porttitor, " +
                "ipsum lacus lobortis metus, sit amet dictum lacus velit nec diam. " +
                "Morbi arcu diam, euismod a auctor nec, aliquam in lectus." +
                "Ut ultricies iaculis augue sit amet adipiscing. Aenean blandit tortor a nisi " +
                "dignissim fermentum id adipiscing mauris. Aenean libero turpis, varius nec ultricies " +
                "faucibus, pretium quis lectus. Morbi mollis lorem vel erat condimentum mattis mollis " +
                "nulla sollicitudin. Nunc ut massa id felis laoreet feugiat eget at eros.";
            page.Graphics.DrawString(text, sao, slo);

            page.Graphics.DrawLine(redPen, 310, 70, 310, 147);
            page.Graphics.DrawLine(redPen, 590, 70, 590, 147);
            page.Graphics.DrawLine(redPen, 310, 70, 590, 70);
            page.Graphics.DrawLine(redPen, 310, 147, 590, 147);

            // Height is set, text is limited on vertical.
            slo.X = 310;
            slo.Y = 70;
            slo.Width = 280;
            slo.Height = 77;
            page.Graphics.DrawString(text, sao, slo);

            PdfPath clipPath = new PdfPath();
            clipPath.AddRectangle(310, 160, 280, 77);
            page.Graphics.DrawPath(redPen, clipPath);

            page.Graphics.SaveGraphicsState();
            page.Graphics.SetClip(clipPath);

            // Height is not set but text is cliped on vertical.
            slo.X = 310;
            slo.Y = 160;
            slo.Width = 280;
            slo.Height = 0;
            page.Graphics.DrawString(text, sao, slo);

            page.Graphics.RestoreGraphicsState();

            page.Graphics.DrawLine(redPen, 10, 400, 300, 400);
            page.Graphics.DrawLine(redPen, 20, 300, 20, 500);
            // Wrapped text is always rotated around top left corner, no matter the text alignment
            page.Graphics.DrawRectangle(redPen, 20, 400, 280, 80, 30);
            slo.X = 20;
            slo.Y = 400;
            slo.Width = 280;
            slo.Height = 80;
            slo.Rotation = 30;
            page.Graphics.DrawString(text, sao, slo);

            page.Graphics.DrawLine(redPen, 310, 600, 590, 600);
            page.Graphics.DrawLine(redPen, 450, 450, 450, 750);

            // Rotation around the center of the box requires some affine transformations.
            page.Graphics.SaveGraphicsState();
            page.Graphics.TranslateTransform(450, 600);
            page.Graphics.RotateTransform(30);
            page.Graphics.DrawRectangle(redPen, -140, -40, 280, 80);
            slo.X = -140;
            slo.Y = -40;
            slo.Width = 280;
            slo.Height = 80;
            slo.Rotation = 0;
            page.Graphics.DrawString(text, sao, slo);

            page.Graphics.RestoreGraphicsState();
        }
예제 #26
0
        private static void CreateUriActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen blackPen = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = blackBrush;
            sao.Font = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("Uri actions:", font, blackBrush, 400, 420);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 440, 200, 20);
                slo.X = 500;
                slo.Y = 450;
                document.Pages[i].Graphics.DrawString("Go to xfiniumpdf.com", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 440, 200, 20);

                // Create an uri action and attach it to the link.
                PdfUriAction uriAction = new PdfUriAction();
                uriAction.URI = "http://www.xfiniumpdf.com";
                link.Action = uriAction;
            }
        }
예제 #27
0
        private static void Create3DAnnotations(PdfFixedDocument document, PdfFont font, Stream u3dStream)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

            page.Rotation = 90;

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

            byte[] u3dContent = new byte[u3dStream.Length];
            u3dStream.Read(u3dContent, 0, u3dContent.Length);

            Pdf3DView view0 = new Pdf3DView();

            view0.CameraToWorldMatrix    = new double[] { 1, 0, 0, 0, 0, -1, 0, 1, 0, -0.417542, -0.881257, -0.125705 };
            view0.CenterOfOrbit          = 0.123106;
            view0.ExternalName           = "Default";
            view0.InternalName           = "Default";
            view0.Projection             = new Pdf3DProjection();
            view0.Projection.FieldOfView = 30;

            Pdf3DView view1 = new Pdf3DView();

            view1.CameraToWorldMatrix    = new double[] { -0.999888, 0.014949, 0, 0.014949, 0.999887, 0.00157084, 0.0000234825, 0.00157066, -0.999999, -0.416654, -0.761122, -0.00184508 };
            view1.CenterOfOrbit          = 0.123106;
            view1.ExternalName           = "Top";
            view1.InternalName           = "Top";
            view1.Projection             = new Pdf3DProjection();
            view1.Projection.FieldOfView = 14.8096;

            Pdf3DView view2 = new Pdf3DView();

            view2.CameraToWorldMatrix    = new double[] { -1.0, -0.0000411671, 0.0000000000509201, -0.00000101387, 0.0246288, 0.999697, -0.0000411546, 0.999697, -0.0246288, -0.417072, -0.881787, -0.121915 };
            view2.CenterOfOrbit          = 0.123106;
            view2.ExternalName           = "Side";
            view2.InternalName           = "Side";
            view2.Projection             = new Pdf3DProjection();
            view2.Projection.FieldOfView = 12.3794;

            Pdf3DView view3 = new Pdf3DView();

            view3.CameraToWorldMatrix    = new double[] { -0.797002, -0.603977, -0.0000000438577, -0.294384, 0.388467, 0.873173, -0.527376, 0.695921, -0.48741, -0.3518, -0.844506, -0.0675629 };
            view3.CenterOfOrbit          = 0.123106;
            view3.ExternalName           = "Isometric";
            view3.InternalName           = "Isometric";
            view3.Projection             = new Pdf3DProjection();
            view3.Projection.FieldOfView = 15.1226;

            Pdf3DView view4 = new Pdf3DView();

            view4.CameraToWorldMatrix    = new double[] { 0.00737633, -0.999973, -0.0000000000147744, -0.0656414, -0.000484206, 0.997843, -0.997816, -0.00736042, -0.0656432, -0.293887, -0.757928, -0.119485 };
            view4.CenterOfOrbit          = 0.123106;
            view4.ExternalName           = "Front";
            view4.InternalName           = "Front";
            view4.Projection             = new Pdf3DProjection();
            view4.Projection.FieldOfView = 15.1226;

            Pdf3DView view5 = new Pdf3DView();

            view5.CameraToWorldMatrix    = new double[] { 0.0151008, 0.999886, 0.0000000000261366, 0.0492408, -0.000743662, 0.998787, 0.998673, -0.0150825, -0.0492464, -0.540019, -0.756862, -0.118884 };
            view5.CenterOfOrbit          = 0.123106;
            view5.ExternalName           = "Back";
            view5.InternalName           = "Back";
            view5.Projection             = new Pdf3DProjection();
            view5.Projection.FieldOfView = 12.3794;

            Pdf3DStream _3dStream = new Pdf3DStream();

            _3dStream.Views.Add(view0);
            _3dStream.Views.Add(view1);
            _3dStream.Views.Add(view2);
            _3dStream.Views.Add(view3);
            _3dStream.Views.Add(view4);
            _3dStream.Views.Add(view5);
            _3dStream.Content          = u3dContent;
            _3dStream.DefaultViewIndex = 0;
            Pdf3DAnnotation _3da = new Pdf3DAnnotation();

            _3da.Stream = _3dStream;

            PdfAnnotationAppearance appearance = new PdfAnnotationAppearance(200, 200);

            appearance.Graphics.DrawString("Click to activate", font, blackBrush, 50, 50);
            _3da.NormalAppearance = appearance;

            page.Annotations.Add(_3da);
            _3da.VisualRectangle = new PdfVisualRectangle(36, 36, 720, 540);

            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Font  = font;
            sao.Brush = blackBrush;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.Y = 585 + 18 / 2;
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;

            PdfPen blackPen = new PdfPen(new PdfRgbColor(0, 0, 0), 1);

            page.Graphics.DrawRectangle(blackPen, 50, 585, 120, 18);
            slo.X = 50 + 120 / 2;
            page.Graphics.DrawString("Top", sao, slo);

            PdfGoTo3DViewAction gotoTopView = new PdfGoTo3DViewAction();

            gotoTopView.ViewIndex        = 1;
            gotoTopView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoTopView = new PdfLinkAnnotation();

            page.Annotations.Add(linkGotoTopView);
            linkGotoTopView.VisualRectangle = new PdfVisualRectangle(50, 585, 120, 18);
            linkGotoTopView.Action          = gotoTopView;

            page.Graphics.DrawRectangle(blackPen, 190, 585, 120, 18);
            slo.X = 190 + 120 / 2;
            page.Graphics.DrawString("Side", sao, slo);

            PdfGoTo3DViewAction gotoSideView = new PdfGoTo3DViewAction();

            gotoSideView.ViewIndex        = 2;
            gotoSideView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoSideView = new PdfLinkAnnotation();

            page.Annotations.Add(linkGotoSideView);
            linkGotoSideView.VisualRectangle = new PdfVisualRectangle(190, 585, 120, 18);
            linkGotoSideView.Action          = gotoSideView;

            page.Graphics.DrawRectangle(blackPen, 330, 585, 120, 18);
            slo.X = 330 + 120 / 2;
            page.Graphics.DrawString("Isometric", sao, slo);

            PdfGoTo3DViewAction gotoIsometricView = new PdfGoTo3DViewAction();

            gotoIsometricView.ViewIndex        = 3;
            gotoIsometricView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoIsometricView = new PdfLinkAnnotation();

            page.Annotations.Add(linkGotoIsometricView);
            linkGotoIsometricView.VisualRectangle = new PdfVisualRectangle(330, 585, 120, 18);
            linkGotoIsometricView.Action          = gotoIsometricView;

            page.Graphics.DrawRectangle(blackPen, 470, 585, 120, 18);
            slo.X = 470 + 120 / 2;
            page.Graphics.DrawString("Front", sao, slo);

            PdfGoTo3DViewAction gotoFrontView = new PdfGoTo3DViewAction();

            gotoFrontView.ViewIndex        = 4;
            gotoFrontView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoFrontView = new PdfLinkAnnotation();

            page.Annotations.Add(linkGotoFrontView);
            linkGotoFrontView.VisualRectangle = new PdfVisualRectangle(470, 585, 120, 18);
            linkGotoFrontView.Action          = gotoFrontView;

            page.Graphics.DrawRectangle(blackPen, 610, 585, 120, 18);
            slo.X = 610 + 120 / 2;
            page.Graphics.DrawString("Back", sao, slo);

            PdfGoTo3DViewAction gotoBackView = new PdfGoTo3DViewAction();

            gotoBackView.ViewIndex        = 5;
            gotoBackView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoBackView = new PdfLinkAnnotation();

            page.Annotations.Add(linkGotoBackView);
            linkGotoBackView.VisualRectangle = new PdfVisualRectangle(610, 585, 120, 18);
            linkGotoBackView.Action          = gotoBackView;
        }
예제 #28
0
        private static void CreateJavaScriptActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen blackPen = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = blackBrush;
            sao.Font = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("JavaScript actions:", font, blackBrush, 400, 480);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 500, 200, 20);
                slo.X = 500;
                slo.Y = 510;
                document.Pages[i].Graphics.DrawString("Click me", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 500, 200, 20);

                // Create a Javascript action and attach it to the link.
                PdfJavaScriptAction jsAction = new PdfJavaScriptAction();
                jsAction.Script = "app.alert({cMsg: \"JavaScript action: you are now on page " + (i + 1) + "\", cTitle: \"Xfinium.Pdf Actions Sample\"});";
                link.Action = jsAction;
            }
        }
예제 #29
0
        public MemoryStream CreatePdfMemoryStream(CalculationInput input, CalculationOutput output)
        {
            //PdfFlowDocument document = new PdfFlowDocument();

            //PdfFlowContent attendantsSection = BuildAttendantsList();
            //document.AddContent(attendantsSection);

            // Create a font and a brush
            PdfStandardFont headerFont     = new PdfStandardFont(PdfStandardFontFace.HelveticaBold, 24);
            PdfStandardFont subHeaderFont  = new PdfStandardFont(PdfStandardFontFace.HelveticaBold, 16);
            PdfStandardFont labelFont      = new PdfStandardFont(PdfStandardFontFace.HelveticaBold, 12);
            PdfStandardFont valueFont      = new PdfStandardFont(PdfStandardFontFace.Helvetica, 12);
            PdfStandardFont tableLabelFont = new PdfStandardFont(PdfStandardFontFace.HelveticaBold, 10);
            PdfStandardFont boxFont        = new PdfStandardFont(PdfStandardFontFace.HelveticaBold, 8);
            PdfBrush        brush          = new PdfBrush();
            PdfBrush        greyBrush      = new PdfBrush();

            greyBrush.Color = PdfRgbColor.Gray;

            // Create a fixed document
            PdfFixedDocument document = new PdfFixedDocument();

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

            //draw line
            PdfPen blackPen = new PdfPen(PdfRgbColor.Black, 2);

            page.Graphics.DrawLine(blackPen, 0, 65, 600, 65);

            //rectangles
            page.Graphics.DrawRectangle(blackPen, 2, 182, 192, 180);
            page.Graphics.DrawRectangle(blackPen, 202, 182, 192, 180);
            page.Graphics.DrawRectangle(blackPen, 402, 182, 192, 180);

            page.Graphics.DrawRectangle(blackPen, 2, 370, 392, 400);

            int rowCount = 4; //for dc

            if (input.IsAlternatingCurrent.Value)
            {
                if (!input.HasTransformer.Value && !input.HasCable.Value)
                {
                    rowCount = 10;
                }
                if (!input.HasTransformer.Value && input.HasCable.Value)
                {
                    rowCount = 13;
                }
                if (input.HasTransformer.Value && !input.HasCable.Value)
                {
                    rowCount = 13;
                }
                if (input.HasTransformer.Value && input.HasCable.Value)
                {
                    rowCount = 16;
                }
                if (input.HasTransformer.Value && input.IsArcDurationCalculated)
                {
                    rowCount += 8;
                }
            }
            //table
            int twenty = 0;

            for (int i = 0; i < rowCount; i++)
            {
                page.Graphics.DrawRectangle(blackPen, 2, 370 + twenty, 197, 20);
                page.Graphics.DrawRectangle(blackPen, 200, 370 + twenty, 194, 20);
                twenty += 20;

                switch (i)
                {
                case 0://row number
                    if (input.IsAlternatingCurrent.Value)
                    {
                        page.Graphics.DrawString(AppResources.Nominal_Working_Voltage, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.NominalVoltage.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    else
                    {
                        page.Graphics.DrawString(AppResources.Voltage_Type, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString("DC", tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 1://row number
                    if (input.IsAlternatingCurrent.Value)
                    {
                        page.Graphics.DrawString(AppResources.Arc_Flash_Boundary_Feet, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(Math.Round((double)output.FPB, 2).ToString(), tableLabelFont, brush, 204,
                                                 356 + twenty);
                    }
                    else
                    {
                        page.Graphics.DrawString(AppResources.Maximum_Available_Short_Circuit, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.MaximumShortCircuitAvailable.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 2://row number
                    if (input.IsAlternatingCurrent.Value)
                    {
                        page.Graphics.DrawString(AppResources.Bolted_Fault_Current_amps, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(Math.Round((double)output.BoltedFaultCurrent.Value * 1000, 2).ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    else
                    {
                        page.Graphics.DrawString(AppResources.Battery_Enclosure, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.InCabinet.HasValue && input.InCabinet.Value ? AppResources.In_Box : AppResources.Open_Air, tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 3://row number
                    if (input.IsAlternatingCurrent.Value)
                    {
                        page.Graphics.DrawString(AppResources.Estimated_Arc_Fault_Current_amps, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(Math.Round((double)output.EstimatedArcFaultCurrent.Value * 1000, 2).ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    else
                    {
                        page.Graphics.DrawString(AppResources.Battery_String_Voltage, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.VoltageOfBattery.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 4://row number
                    page.Graphics.DrawString(AppResources.Incident_Energy_18, tableLabelFont, brush, 5, 356 + twenty);
                    page.Graphics.DrawString(Math.Round((double)output.IE18, 2).ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    break;

                case 5://row number
                    page.Graphics.DrawString(AppResources.Incident_Energy_24, tableLabelFont, brush, 5, 356 + twenty);
                    page.Graphics.DrawString(Math.Round((double)output.IE24, 2).ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    break;

                case 6://row number
                    page.Graphics.DrawString(AppResources.Incident_Energy_36, tableLabelFont, brush, 5, 356 + twenty);
                    page.Graphics.DrawString(Math.Round((double)output.IE36, 2).ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    break;

                case 7://row number
                    page.Graphics.DrawString(AppResources.Arc_Duration_seconds, tableLabelFont, brush, 5, 356 + twenty);
                    page.Graphics.DrawString(input.ArcDurationValue.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    break;

                case 8://row number
                    page.Graphics.DrawString(AppResources.Source_Fault_Current_amps, tableLabelFont, brush, 5, 356 + twenty);
                    page.Graphics.DrawString(input.SourceFaultCurrent.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    break;

                case 9://row number
                    string groundingString = AppResources.Solidly_Grounded;
                    page.Graphics.DrawString(AppResources.Grounding, tableLabelFont, brush, 5, 356 + twenty);
                    if (!input.IsSolidGround.Value)
                    {
                        groundingString = AppResources.Ungrounded;
                    }
                    page.Graphics.DrawString(groundingString, tableLabelFont, brush, 204, 356 + twenty);
                    break;

                case 10://row number
                    page.Graphics.DrawString(AppResources.Potential_Arc_Location, tableLabelFont, brush, 5, 356 + twenty);
                    string arcLocation = AppResources.Open_Air;
                    if (!input.IsOpenAir.Value)
                    {
                        arcLocation = AppResources.In_Box;
                    }
                    page.Graphics.DrawString(arcLocation, tableLabelFont, brush, 204, 356 + twenty);
                    break;

                case 11://row number
                    page.Graphics.DrawString(AppResources.Conductor, tableLabelFont, brush, 5, 356 + twenty);
                    page.Graphics.DrawString(input.HasCable.HasValue && input.HasCable.Value ? AppResources.Cable : AppResources.No_Cable, tableLabelFont, brush, 204, 356 + twenty);
                    break;

                case 12://row number
                    if (input.HasCable.Value)
                    {
                        page.Graphics.DrawString(AppResources.Conductor_Size, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.ConductorSize.Size, tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 13://row number
                    if (input.HasCable.Value)
                    {
                        page.Graphics.DrawString(AppResources.Conductors_per_Phase, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.ConductorPerPhase.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 14://row number
                    if (input.HasCable.Value)
                    {
                        page.Graphics.DrawString(AppResources.Conductor_Length, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.ConductorLength.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 15://row number
                    page.Graphics.DrawString(AppResources.Upstream_Transformer, tableLabelFont, brush, 5, 356 + twenty);
                    page.Graphics.DrawString(input.HasTransformer.HasValue && input.HasTransformer.Value ? AppResources.Upstream_XFR : AppResources.No_Transformer, tableLabelFont, brush, 204, 356 + twenty);
                    break;

                case 16://row number
                    if (input.HasTransformer.Value)
                    {
                        page.Graphics.DrawString(AppResources.Primary_Voltage, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.PrimaryVoltage.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 17://row number
                    if (input.HasTransformer.Value)
                    {
                        page.Graphics.DrawString(AppResources.Transformer_Impedence, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.XfmrImpedance.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 18://row number
                    if (input.HasTransformer.Value)
                    {
                        page.Graphics.DrawString(AppResources.Transformer_KVA, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.XfmrKVA.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 19://row number
                    if (input.IsAlternatingCurrent.Value)
                    {
                        page.Graphics.DrawString(AppResources.Sensor_Rating, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.SensorRating.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 20://row number
                    if (input.IsAlternatingCurrent.Value)
                    {
                        page.Graphics.DrawString(AppResources.Multiple_Of_Sensor_Rating, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(output.MultipleOfSensorRating.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;

                case 21://row number
                    if (input.IsArcDurationCalculated)
                    {
                        page.Graphics.DrawString(AppResources.Manufacturer, tableLabelFont, brush, 5, 356 + twenty);
                        page.Graphics.DrawString(input.ArcDuration.Manufacturer.Name.ToString(), tableLabelFont, brush, 204, 356 + twenty);
                    }
                    break;
                }
            }

            //diagram box
            page.Graphics.DrawRectangle(blackPen, 402, 370, 192, 400);
            page.Graphics.DrawString("CIRCUIT DIAGRAM PREVIEW", labelFont, greyBrush, 410, 375);

            // Title
            page.Graphics.DrawString(AppResources.ARC_FLASH_ESTIMATE_REPORT, headerFont, brush, 50, 40);

            //job details
            page.Graphics.DrawString("Job Details", subHeaderFont, brush, 5, 75);
            page.Graphics.DrawString("Location:", labelFont, brush, 5, 100);
            if (input.Location != null)
            {
                page.Graphics.DrawString(input.Location, valueFont, brush, 69, 100);
            }

            page.Graphics.DrawString("Action:", labelFont, brush, 18, 120);
            if (input.Action != null)
            {
                page.Graphics.DrawString(input.Action, valueFont, brush, 68, 120);
            }

            if (input.IsAlternatingCurrent.Value)
            {
                page.Graphics.DrawString("Eqipment Type:", labelFont, brush, 5, 140);
                page.Graphics.DrawString(input.EquipmentType.Name, valueFont, brush, 98, 140);
            }

            page.Graphics.DrawString("Date:", labelFont, brush, 330, 100);
            page.Graphics.DrawString(input.CalculationDate.ToString("D"), valueFont, brush, 373, 100);

            page.Graphics.DrawString("Personnel:", labelFont, brush, 300, 120);
            if (input.Personnel != null)
            {
                page.Graphics.DrawString(input.Personnel, valueFont, brush, 375, 120);
            }

            //Arc Flash Estimate
            page.Graphics.DrawString("Arc Flash Estimate", subHeaderFont, brush, 10, 165);

            //incident energy
            page.Graphics.DrawString("INCIDENT ENERGY", labelFont, greyBrush, 35, 190);
            page.Graphics.DrawString(output.IncidentEnergy.ToString(), headerFont, brush, 70, 220);
            page.Graphics.DrawString("cal/cm²", labelFont, brush, 72, 250);

            //at working distance
            page.Graphics.DrawString("AT WORKING DISTANCE:", labelFont, greyBrush, 15, 280);
            page.Graphics.DrawString(Math.Round(input.WorkingDistance.Value, 2, MidpointRounding.ToEven).ToString(), headerFont, brush, 70, 310);
            page.Graphics.DrawString("inches", labelFont, brush, 100, 316);

            //PPE Level
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            PdfStringLayoutOptions     slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Justified;
            slo.VerticalAlign   = PdfStringVerticalAlign.Top;
            sao.Brush           = brush;
            sao.Font            = valueFont;

            page.Graphics.DrawString("PPE LEVEL REQUIRED", labelFont, greyBrush, 230, 190);
            page.Graphics.DrawString(output.HazardCat, headerFont, brush, 290, 220);
            slo.X     = 210;
            slo.Width = 170;
            page.Graphics.DrawString("CLOTHING DESCRIPTION:", labelFont, greyBrush, 230, 280);
            if (output.IncidentEnergy <= 1.2m)
            {
                slo.Y = 250;
                page.Graphics.DrawString(String.Format(AppResources.Required_Minimum_Arc_Rating_Pdf, 1.2m), sao, slo);
                slo.Y = 300;
                page.Graphics.DrawString(AppResources.ClothingDescriptionDetailsOnePointTwo, sao, slo);
            }

            if (output.IncidentEnergy > 1.2m && output.IncidentEnergy <= 8)
            {
                slo.Y = 250;
                page.Graphics.DrawString(String.Format(AppResources.Required_Minimum_Arc_Rating_Pdf, 8), sao, slo);
                slo.Y = 300;
                page.Graphics.DrawString(AppResources.ClothingDescriptionDetails8PartB, sao, slo);
            }

            if (output.IncidentEnergy > 8 && output.IncidentEnergy <= 40)
            {
                slo.Y = 250;
                page.Graphics.DrawString(String.Format(AppResources.Required_Minimum_Arc_Rating_Pdf, 40), sao, slo);
                slo.Y = 300;
                page.Graphics.DrawString(AppResources.ClothingDescriptionDetails40PartB, sao, slo);
            }

            //glove class
            page.Graphics.DrawString("INSULATING GLOVE CLASS", labelFont, greyBrush, 410, 190);
            page.Graphics.DrawString(output.InsulatingGloveClass.ToString(), headerFont, brush, 490, 220);

            //shock hazard
            slo.X     = 420;
            slo.Y     = 280;
            slo.Width = 170;
            if (input.IsAlternatingCurrent.Value)
            {
                page.Graphics.DrawString(String.Format(AppResources.Voltage_Shock_Hazard_AC, input.NominalVoltage), sao, slo);
            }
            else
            {
                page.Graphics.DrawString(String.Format(AppResources.Voltage_Shock_Hazard_DC, input.VoltageOfBattery), sao, slo);
            }

            Stream explosionIconStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.pdf_explosion.png");
            Stream logoStream          = GetImageStreamByName("ArcFlashCalculator.Core.Images.pdf_logo.png");
            Stream warningStream       = GetImageStreamByName("ArcFlashCalculator.Core.Images.warning.png");

            PdfPngImage explosion = new PdfPngImage(explosionIconStream);

            page.Graphics.DrawImage(explosion, 10, 30, 32, 32);

            PdfPngImage logo = new PdfPngImage(logoStream);

            page.Graphics.DrawImage(logo, 525, 30, 75, 30);

            PdfPngImage warning = new PdfPngImage(warningStream);

            page.Graphics.DrawImage(warning, 472, 235, 50, 50);

            //dc
            if (!input.IsAlternatingCurrent.Value)
            {
                Stream      dcStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.dc_source.png");
                PdfPngImage dc       = new PdfPngImage(dcStream);
                page.Graphics.DrawImage(dc, 410, 400, 75, 75);

                //Max Available box
                page.Graphics.DrawRectangle(blackPen, 490, 400, 100, 50);
                page.Graphics.DrawString(AppResources.Maximum_Available, boxFont, brush, 505, 405);
                page.Graphics.DrawString(AppResources.Short_Circuit_Amps, boxFont, brush, 505, 420);
                page.Graphics.DrawString(input.MaximumShortCircuitAvailable.Value + "A", tableLabelFont, brush, 525, 437);

                //Point of work
                page.Graphics.DrawRectangle(blackPen, 490, 460, 100, 16);
                page.Graphics.DrawString(AppResources.Point_Of_Work, tableLabelFont, brush, 505, 464);
            }
            else
            {
                Stream      acSourceStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.ac_source.png");
                PdfPngImage acSource       = new PdfPngImage(acSourceStream);
                page.Graphics.DrawImage(acSource, 430, 400, 25, 25);
                //source fault current box
                page.Graphics.DrawRectangle(blackPen, 460, 400, 130, 35);
                page.Graphics.DrawString(AppResources.Source_Fault_Current, tableLabelFont, brush, 480, 405);
                page.Graphics.DrawString(String.Format(AppResources.SourceFaultCurrent, input.SourceFaultCurrent), tableLabelFont, brush, 510, 420);

                //has xfmr and no cable
                if (input.HasTransformer.Value && !input.HasCable.Value)
                {
                    Stream      xfmrStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.xfmr.png");
                    PdfPngImage xfmr       = new PdfPngImage(xfmrStream);
                    page.Graphics.DrawImage(xfmr, 430, 426, 25, 73);

                    Stream      breakerStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.breaker.png");
                    PdfPngImage breaker       = new PdfPngImage(breakerStream);
                    page.Graphics.DrawImage(breaker, 438, 499, 16, 97);

                    Stream      workPointStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.work_point.png");
                    PdfPngImage workPoint       = new PdfPngImage(workPointStream);
                    page.Graphics.DrawImage(workPoint, 434, 595, 16, 38);

                    //transformer box
                    page.Graphics.DrawRectangle(blackPen, 460, 460, 130, 65);
                    page.Graphics.DrawString(String.Format(AppResources.TransformerKVA, input.XfmrKVA), tableLabelFont, brush, 485, 465);
                    page.Graphics.DrawString(String.Format(AppResources.PrimaryVoltage, input.PrimaryVoltage), tableLabelFont, brush, 480, 480);
                    page.Graphics.DrawString(String.Format(AppResources.SecondaryVoltage, input.NominalVoltage), tableLabelFont, brush, 480, 495);
                    page.Graphics.DrawString(String.Format(AppResources.TransformerImpedence, input.XfmrImpedance), tableLabelFont, brush, 490, 510);

                    //arc duration box
                    page.Graphics.DrawRectangle(blackPen, 460, 560, 130, 40);
                    page.Graphics.DrawString(AppResources.Arc_Duration, tableLabelFont, brush, 495, 565);
                    page.Graphics.DrawString(String.Format(AppResources.Arc_Duration_With_Unit, input.ArcDurationValue), tableLabelFont, brush, 510, 580);

                    //point of work box
                    page.Graphics.DrawRectangle(blackPen, 460, 620, 130, 16);
                    page.Graphics.DrawString(AppResources.Point_Of_Work, tableLabelFont, brush, 500, 625);
                }

                //no xfmr and has cable
                if (!input.HasTransformer.Value && input.HasCable.Value)
                {
                    Stream      cableStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.cable.png");
                    PdfPngImage cable       = new PdfPngImage(cableStream);
                    page.Graphics.DrawImage(cable, 437, 425, 10, 94);

                    Stream      breakerStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.breaker.png");
                    PdfPngImage breaker       = new PdfPngImage(breakerStream);
                    page.Graphics.DrawImage(breaker, 438, 515, 16, 97);

                    Stream      workPointStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.work_point.png");
                    PdfPngImage workPoint       = new PdfPngImage(workPointStream);
                    page.Graphics.DrawImage(workPoint, 434, 612, 16, 38);

                    //Cable box
                    page.Graphics.DrawRectangle(blackPen, 460, 480, 130, 50);
                    page.Graphics.DrawString(input.ConductorLength.Value + "ft.", tableLabelFont, brush, 505, 485);
                    page.Graphics.DrawString(String.Format(AppResources.ConductorsPerPhase, input.ConductorPerPhase), tableLabelFont, brush, 465, 500);
                    page.Graphics.DrawString(String.Format(AppResources.ConductorSize, input.ConductorSize.Size), tableLabelFont, brush, 470, 515);

                    //arc duration box
                    page.Graphics.DrawRectangle(blackPen, 460, 570, 130, 40);
                    page.Graphics.DrawString(AppResources.Arc_Duration, tableLabelFont, brush, 495, 575);
                    page.Graphics.DrawString(String.Format(AppResources.Arc_Duration_With_Unit, input.ArcDurationValue), tableLabelFont, brush, 510, 595);

                    //point of work box
                    page.Graphics.DrawRectangle(blackPen, 460, 635, 130, 16);
                    page.Graphics.DrawString(AppResources.Point_Of_Work, tableLabelFont, brush, 500, 640);
                }

                //has xfmr and cable
                if (input.HasTransformer.Value && input.HasCable.Value)
                {
                    Stream      xfmrStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.xfmr.png");
                    PdfPngImage xfmr       = new PdfPngImage(xfmrStream);
                    page.Graphics.DrawImage(xfmr, 430, 426, 25, 73);

                    Stream      cableStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.cable.png");
                    PdfPngImage cable       = new PdfPngImage(cableStream);
                    page.Graphics.DrawImage(cable, 437, 499, 10, 94);

                    Stream      breakerStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.breaker.png");
                    PdfPngImage breaker       = new PdfPngImage(breakerStream);
                    page.Graphics.DrawImage(breaker, 438, 593, 16, 97);

                    Stream      workPointStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.work_point.png");
                    PdfPngImage workPoint       = new PdfPngImage(workPointStream);
                    page.Graphics.DrawImage(workPoint, 434, 690, 16, 38);

                    //transformer box
                    page.Graphics.DrawRectangle(blackPen, 460, 460, 130, 65);
                    page.Graphics.DrawString(String.Format(AppResources.TransformerKVA, input.XfmrKVA), tableLabelFont, brush, 485, 465);
                    page.Graphics.DrawString(String.Format(AppResources.PrimaryVoltage, input.PrimaryVoltage), tableLabelFont, brush, 480, 480);
                    page.Graphics.DrawString(String.Format(AppResources.SecondaryVoltage, input.NominalVoltage), tableLabelFont, brush, 480, 495);
                    page.Graphics.DrawString(String.Format(AppResources.TransformerImpedence, input.XfmrImpedance), tableLabelFont, brush, 490, 510);

                    //Cable box
                    page.Graphics.DrawRectangle(blackPen, 460, 550, 130, 50);
                    page.Graphics.DrawString(input.ConductorLength.Value + "ft.", tableLabelFont, brush, 505, 555);
                    page.Graphics.DrawString(String.Format(AppResources.ConductorsPerPhase, input.ConductorPerPhase), tableLabelFont, brush, 465, 570);
                    page.Graphics.DrawString(String.Format(AppResources.ConductorSize, input.ConductorSize.Size), tableLabelFont, brush, 470, 585);

                    //arc duration box
                    page.Graphics.DrawRectangle(blackPen, 460, 640, 130, 50);
                    page.Graphics.DrawString(AppResources.Arc_Duration, tableLabelFont, brush, 495, 645);
                    page.Graphics.DrawString(String.Format(AppResources.Arc_Duration_With_Unit, input.ArcDurationValue), tableLabelFont, brush, 510, 665);

                    //point of work box
                    page.Graphics.DrawRectangle(blackPen, 460, 720, 130, 16);
                    page.Graphics.DrawString(AppResources.Point_Of_Work, tableLabelFont, brush, 500, 725);
                }

                //no xfmr and no cable
                if (!input.HasTransformer.Value && !input.HasCable.Value)
                {
                    Stream      breakerStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.breaker.png");
                    PdfPngImage breaker       = new PdfPngImage(breakerStream);
                    page.Graphics.DrawImage(breaker, 437, 425, 20, 121);

                    Stream      workPointStream = GetImageStreamByName("ArcFlashCalculator.Core.Images.work_point.png");
                    PdfPngImage workPoint       = new PdfPngImage(workPointStream);
                    page.Graphics.DrawImage(workPoint, 432, 545, 20, 48);

                    //arc duration box
                    page.Graphics.DrawRectangle(blackPen, 460, 500, 130, 50);
                    page.Graphics.DrawString(AppResources.Arc_Duration, tableLabelFont, brush, 495, 505);
                    page.Graphics.DrawString(String.Format(AppResources.Arc_Duration_With_Unit, input.ArcDurationValue), tableLabelFont, brush, 510, 525);

                    //point of work box
                    page.Graphics.DrawRectangle(blackPen, 460, 580, 130, 16);
                    page.Graphics.DrawString(AppResources.Point_Of_Work, tableLabelFont, brush, 500, 585);
                }
            }

            //compress
            page.Graphics.CompressAndClose();

            //Creates a new Memory stream
            MemoryStream memoryStream = new MemoryStream();

            // Saves the document as stream
            document.Save(memoryStream);

            return(memoryStream);
        }
예제 #30
0
        private static void DrawTextLines(PdfPage page, PdfStandardFont titleFont)
        {
            PdfBrush        brush     = new PdfBrush();
            PdfPen          redPen    = new PdfPen(PdfRgbColor.Red, 0.5);
            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 12);

            page.Graphics.DrawString("Text lines", titleFont, brush, 20, 50);

            page.Graphics.DrawLine(redPen, 20, 70, 150, 70);
            page.Graphics.DrawLine(redPen, 20, 70, 20, 80);
            page.Graphics.DrawString("Simple text line with default top left text alignment and no rotation", helvetica, brush, 20, 70);

            page.Graphics.DrawString("Text align", helvetica, brush, 20, 110);

            redPen.DashPattern = new double[] { 1, 1 };
            page.Graphics.DrawLine(redPen, 20, 125, 590, 125);
            page.Graphics.DrawLine(redPen, 20, 165, 590, 165);
            page.Graphics.DrawLine(redPen, 20, 205, 590, 205);
            page.Graphics.DrawLine(redPen, 20, 125, 20, 205);
            page.Graphics.DrawLine(redPen, 305, 125, 305, 205);
            page.Graphics.DrawLine(redPen, 590, 125, 590, 205);

            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

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

            // Top left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign   = PdfStringVerticalAlign.Top;
            slo.X = 20;
            slo.Y = 125;
            page.Graphics.DrawString("Top Left", sao, slo);

            // Top center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Top;
            slo.X = 305;
            slo.Y = 125;
            page.Graphics.DrawString("Top Center", sao, slo);

            // Top right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign   = PdfStringVerticalAlign.Top;
            slo.X = 590;
            slo.Y = 125;
            page.Graphics.DrawString("Top Right", sao, slo);

            // Middle left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;
            slo.X = 20;
            slo.Y = 165;
            page.Graphics.DrawString("Middle Left", sao, slo);

            // Middle center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;
            slo.X = 305;
            slo.Y = 165;
            page.Graphics.DrawString("Middle Center", sao, slo);

            // Middle right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;
            slo.X = 590;
            slo.Y = 165;
            page.Graphics.DrawString("Middle Right", sao, slo);

            // Bottom left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign   = PdfStringVerticalAlign.Bottom;
            slo.X = 20;
            slo.Y = 205;
            page.Graphics.DrawString("Bottom Left", sao, slo);

            // Bottom center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Bottom;
            slo.X = 305;
            slo.Y = 205;
            page.Graphics.DrawString("Bottom Center", sao, slo);

            // Bottom right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign   = PdfStringVerticalAlign.Bottom;
            slo.X = 590;
            slo.Y = 205;
            page.Graphics.DrawString("Bottom Right", sao, slo);

            page.Graphics.DrawString("Text rotation", helvetica, brush, 20, 250);

            redPen.DashPattern = new double[] { 1, 1 };
            page.Graphics.DrawLine(redPen, 20, 265, 590, 265);
            page.Graphics.DrawLine(redPen, 20, 305, 590, 305);
            page.Graphics.DrawLine(redPen, 20, 345, 590, 345);
            page.Graphics.DrawLine(redPen, 20, 265, 20, 345);
            page.Graphics.DrawLine(redPen, 305, 265, 305, 345);
            page.Graphics.DrawLine(redPen, 590, 265, 590, 345);

            slo.Rotation = 30;
            // Top left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign   = PdfStringVerticalAlign.Top;
            slo.X = 20;
            slo.Y = 265;
            page.Graphics.DrawString("Top Left", sao, slo);

            // Top center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Top;
            slo.X = 305;
            slo.Y = 265;
            page.Graphics.DrawString("Top Center", sao, slo);

            // Top right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign   = PdfStringVerticalAlign.Top;
            slo.X = 590;
            slo.Y = 265;
            page.Graphics.DrawString("Top Right", sao, slo);

            // Middle left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;
            slo.X = 20;
            slo.Y = 305;
            page.Graphics.DrawString("Middle Left", sao, slo);

            // Middle center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;
            slo.X = 305;
            slo.Y = 305;
            page.Graphics.DrawString("Middle Center", sao, slo);

            // Middle right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;
            slo.X = 590;
            slo.Y = 305;
            page.Graphics.DrawString("Middle Right", sao, slo);

            // Bottom left aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Left;
            slo.VerticalAlign   = PdfStringVerticalAlign.Bottom;
            slo.X = 20;
            slo.Y = 345;
            page.Graphics.DrawString("Bottom Left", sao, slo);

            // Bottom center aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Bottom;
            slo.X = 305;
            slo.Y = 345;
            page.Graphics.DrawString("Bottom Center", sao, slo);

            // Bottom right aligned text
            slo.HorizontalAlign = PdfStringHorizontalAlign.Right;
            slo.VerticalAlign   = PdfStringVerticalAlign.Bottom;
            slo.X = 590;
            slo.Y = 345;
            page.Graphics.DrawString("Bottom Right", sao, slo);

            page.Graphics.CompressAndClose();
        }
예제 #31
0
        public async Task <PdfFixedDocument> GenerateGamePDF(Game game, IEnumerable <Team> teams, IEnumerable <Player> players)
        {
            CultureInfo currentCulture = CultureInfo.CurrentUICulture;

            PdfUnicodeTrueTypeFont verdanaBold = await CreateFontFromFile("verdanab.ttf", FONTSIZE_PAGE_TITLE);

            PdfUnicodeTrueTypeFont verdana = await CreateFontFromFile("verdana.ttf", FONTSIZE_DEFAULT);

            PdfBrush brush = new PdfBrush();

            PdfFixedDocument pdf = new PdfFixedDocument();

            CreateNewPage(pdf, verdanaBold, brush);

            /// Заголовок документа
            verdanaBold.Size = FONTSIZE_PAGE_TITLE;
            CurrentPage.Graphics.DrawString($"{game.Name.ToUpper()} {game.Date}", verdanaBold, brush, PagePadding.Left, PagePadding.Top);

            MeasureAvailableSpace(offsetY: FONTSIZE_PAGE_TITLE + OFFSET_Y_FROM_TITLE);

            /// Заголовки таблицы
            verdanaBold.Size = FONTSIZE_DEFAULT;
            double columnSize      = AvailableSize.Width * 0.25;
            double tableHeaderYPos = GetAvailableTop();

            CurrentPage.Graphics.DrawString("Игрок", verdanaBold, brush, PagePadding.Left + columnSize * 0, tableHeaderYPos);
            CurrentPage.Graphics.DrawString("Рейтинг", verdanaBold, brush, PagePadding.Left + columnSize * 1, tableHeaderYPos);
            CurrentPage.Graphics.DrawString("Точность", verdanaBold, brush, PagePadding.Left + columnSize * 2, tableHeaderYPos);
            CurrentPage.Graphics.DrawString("Выстрелы", verdanaBold, brush, PagePadding.Left + columnSize * 3, tableHeaderYPos);

            MeasureAvailableSpace(offsetY: FONTSIZE_DEFAULT + OFFSET_Y_FROM_TABLE_HEADER);

            /// Заполнение данных групп
            PdfPen linePen = new PdfPen(new PdfRgbColor(213, 214, 216), 0.5);
            Dictionary <Team, IEnumerable <Player> > playersTeams = new Dictionary <Team, IEnumerable <Player> >();
            int    counter = 0;
            double teamHeaderDesiredHeight = FONTSIZE_GROUP_HEADER + OFFSET_Y_FROM_GROUP_HEADER_OR_ITEM;

            foreach (var team in teams)
            {
                if (counter != 0)
                {
                    MeasureAvailableSpace(offsetY: OFFSET_Y_FROM_GROUP);
                }

                if (AvailableSize.Height < teamHeaderDesiredHeight)
                {
                    CreateNewPage(pdf, verdanaBold, brush);
                }

                verdanaBold.Size = FONTSIZE_GROUP_HEADER;
                CurrentPage.Graphics.DrawString(team.Name, verdanaBold, brush, PagePadding.Left, GetAvailableTop());

                MeasureAvailableSpace(offsetY: teamHeaderDesiredHeight);

                var playersInTeam = playersTeams[team] = players.Where(x => x.TeamID == team.ID);

                double playerDesiredSize = FONTSIZE_DEFAULT + 5 + OFFSET_Y_FROM_GROUP_HEADER_OR_ITEM;
                foreach (var player in playersInTeam)
                {
                    if (AvailableSize.Height < teamHeaderDesiredHeight)
                    {
                        CreateNewPage(pdf, verdanaBold, brush);
                    }

                    double rowYPos  = GetAvailableTop();
                    double lineYpos = rowYPos + FONTSIZE_DEFAULT + 5;

                    CurrentPage.Graphics.DrawString(player.Name, verdana, brush, PagePadding.Left + columnSize * 0, rowYPos);
                    CurrentPage.Graphics.DrawString($"{player.Rating}", verdana, brush, PagePadding.Left + columnSize * 1, rowYPos);
                    CurrentPage.Graphics.DrawString($"{player.AccuracyPercentage}%", verdana, brush, PagePadding.Left + columnSize * 2, rowYPos);
                    CurrentPage.Graphics.DrawString($"{player.Shots}", verdana, brush, PagePadding.Left + columnSize * 3, rowYPos);

                    CurrentPage.Graphics.DrawLine(linePen, PagePadding.Left, lineYpos, CurrentPage.Width - PagePadding.Right, lineYpos);
                    MeasureAvailableSpace(offsetY: playerDesiredSize);
                }

                counter++;
            }

            /// Блок сравнения команд по показателям
            PdfPen   rectanglePen   = new PdfPen(new PdfRgbColor(1, 90, 255), 0.5);
            PdfBrush rectangleBrush = new PdfBrush(new PdfRgbColor(1, 90, 255));

            double teamMarkWidth         = (AvailableSize.Width - OFFSET_Y_FROM_TABLE) * 0.5;
            double teamMarkDesiredHeight =
                FONTSIZE_GROUP_HEADER +
                OFFSET_Y_FROM_GROUP_HEADER_OR_ITEM +
                FONTSIZE_DEFAULT +
                5 +
                20 +
                OFFSET_Y_FROM_GROUP_HEADER_OR_ITEM +
                5 +
                20;

            counter = 0;
            MeasureAvailableSpace(offsetY: OFFSET_Y_FROM_TABLE);

            double maxRating = players.Max(x => x.Rating);

            foreach (var playersTeam in playersTeams)
            {
                int markXPosIndex = counter % 2;
                if (counter > 0 && markXPosIndex == 0)
                {
                    MeasureAvailableSpace(offsetY: teamMarkDesiredHeight + OFFSET_Y_FROM_TABLE);
                }

                if (markXPosIndex == 0 && AvailableSize.Height < teamMarkDesiredHeight)
                {
                    CreateNewPage(pdf, verdanaBold, brush);
                }

                double xPos = PagePadding.Left + (teamMarkWidth + OFFSET_Y_FROM_TABLE) * markXPosIndex;
                double yPos = GetAvailableTop();

                Team team = playersTeam.Key;
                IEnumerable <Player> playersInTeam = playersTeam.Value;

                verdanaBold.Size = FONTSIZE_GROUP_HEADER;
                CurrentPage.Graphics.DrawString(team.Name, verdanaBold, brush, xPos, yPos);

                /// Рейтинг
                yPos += FONTSIZE_GROUP_HEADER + OFFSET_Y_FROM_GROUP_HEADER_OR_ITEM;
                double avgRating = playersInTeam.Average(x => x.Rating);

                PdfStringAppearanceOptions ratingValueAppearance = new PdfStringAppearanceOptions
                {
                    Brush = brush,
                    Font  = verdanaBold,
                };

                PdfStringLayoutOptions ratingValueLayout = new PdfStringLayoutOptions()
                {
                    HorizontalAlign = PdfStringHorizontalAlign.Right,
                    VerticalAlign   = PdfStringVerticalAlign.Bottom,
                    X = xPos + teamMarkWidth,
                    Y = yPos
                };

                verdanaBold.Size = FONTSIZE_DEFAULT;
                CurrentPage.Graphics.DrawString("Рейтинг", verdanaBold, brush, xPos, yPos);
                CurrentPage.Graphics.DrawString(avgRating.ToString("0.00", currentCulture), ratingValueAppearance, ratingValueLayout);

                yPos += FONTSIZE_DEFAULT + 5;
                CurrentPage.Graphics.DrawRectangle(rectanglePen, xPos, yPos, teamMarkWidth, 10);
                CurrentPage.Graphics.DrawRectangle(rectanglePen, rectangleBrush, xPos, yPos, avgRating * teamMarkWidth / maxRating, 10);

                /// Точность
                yPos += 10 + OFFSET_Y_FROM_GROUP_HEADER_OR_ITEM;
                double avgAccuracy = playersInTeam.Average(x => x.AccuracyPercentage);

                PdfStringAppearanceOptions accuracyValueAppearance = new PdfStringAppearanceOptions
                {
                    Brush = brush,
                    Font  = verdanaBold,
                };

                PdfStringLayoutOptions accuracyValueLayout = new PdfStringLayoutOptions()
                {
                    HorizontalAlign = PdfStringHorizontalAlign.Right,
                    VerticalAlign   = PdfStringVerticalAlign.Bottom,
                    X = xPos + teamMarkWidth,
                    Y = yPos
                };

                verdanaBold.Size = FONTSIZE_DEFAULT;
                CurrentPage.Graphics.DrawString("Точность", verdanaBold, brush, xPos, yPos);
                CurrentPage.Graphics.DrawString(avgAccuracy.ToString("0.0", currentCulture) + "%", accuracyValueAppearance, accuracyValueLayout);

                yPos += FONTSIZE_DEFAULT + 5;
                CurrentPage.Graphics.DrawRectangle(rectanglePen, xPos, yPos, teamMarkWidth, 10);
                CurrentPage.Graphics.DrawRectangle(rectanglePen, rectangleBrush, xPos, yPos, avgAccuracy * teamMarkWidth / 100, 10);

                counter++;
            }



            foreach (var page in pdf.Pages)
            {
                page.Graphics.CompressAndClose();
            }

            return(pdf);
        }
예제 #32
0
        private static void DrawGenericBarcodes(PdfPage page, PdfFont titleFont, PdfFont barcodeFont)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen lightGrayPen = new PdfPen(PdfRgbColor.LightGray, 0.5);

            page.Graphics.DrawString("Generic barcodes", titleFont, brush, 40, 20);
            for (int i = 0; i < 7; i++)
            {
                page.Graphics.DrawLine(lightGrayPen, 40, 50 + 100 * i, 570, 50 + 100 * i);
            }
            page.Graphics.DrawLine(lightGrayPen, 306, 50, 306, 750);

            string[] barcodes = new string[] { "Codabar", "Code 11", "Code 25", "Code 25 Interleaved", "Code 39", "Code 39 Extended",
                "Code 93", "Code 93 Extended", "Code 128 A", "Code 128 B", "Code 128 C", "COOP 25", "Matrix 25", "MSI/Plessey" };
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = brush;
            sao.Font = barcodeFont;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;

            slo.X = 173;
            int sign = 1;
            for (int i = 0; i < barcodes.Length; i++)
            {
                slo.Y = 55 + 100 * (i / 2);

                page.Graphics.DrawString(barcodes[i], sao, slo);

                slo.X = slo.X + sign * 266;
                sign = -sign;
            }

            // Codabar
            PdfCodabarBarcode codabarBarcode = new PdfCodabarBarcode();
            codabarBarcode.Data = "523408943724";
            codabarBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(codabarBarcode, 173 - codabarBarcode.Width / 2, 70);

            // Code 11
            PdfCode11Barcode code11Barcode = new PdfCode11Barcode();
            code11Barcode.Data = "42376524534";
            code11Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code11Barcode, 173 + 266 - code11Barcode.Width / 2, 70);

            // Code 25
            PdfCode25Barcode code25Barcode = new PdfCode25Barcode();
            code25Barcode.Data = "857621354312";
            code25Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code25Barcode, 173 - code25Barcode.Width / 2, 170);

            // Code 25 Interleaved
            PdfCode25InterleavedBarcode code25InterleavedBarcode = new PdfCode25InterleavedBarcode();
            code25InterleavedBarcode.Data = "42376524534";
            code25InterleavedBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code25InterleavedBarcode, 173 + 266 - code25InterleavedBarcode.Width / 2, 170);

            // Code 39
            PdfCode39Barcode code39Barcode = new PdfCode39Barcode();
            code39Barcode.Data = "6430784327";
            code39Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code39Barcode, 173 - code39Barcode.Width / 2, 270);

            // Code 39 Extended
            PdfCode39ExtendedBarcode code39ExtendedBarcode = new PdfCode39ExtendedBarcode();
            code39ExtendedBarcode.Data = "8990436322";
            code39ExtendedBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code39ExtendedBarcode, 173 + 266 - code39ExtendedBarcode.Width / 2, 270);

            // Code 93
            PdfCode93Barcode code93Barcode = new PdfCode93Barcode();
            code93Barcode.Data = "6345212344";
            code93Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code93Barcode, 173 - code93Barcode.Width / 2, 370);

            // Code 39 Extended
            PdfCode93ExtendedBarcode code93ExtendedBarcode = new PdfCode93ExtendedBarcode();
            code93ExtendedBarcode.Data = "125436732";
            code93ExtendedBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code93ExtendedBarcode, 173 + 266 - code93ExtendedBarcode.Width / 2, 370);

            // Code 128 A
            PdfCode128ABarcode code128ABarcode = new PdfCode128ABarcode();
            code128ABarcode.Data = "XFINIUM.PDF";
            code128ABarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code128ABarcode, 173 - code128ABarcode.Width / 2, 470);

            // Code 128 B
            PdfCode128BBarcode code128BBarcode = new PdfCode128BBarcode();
            code128BBarcode.Data = "xfinium.pdf";
            code128BBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code128BBarcode, 173 + 266 - code128BBarcode.Width / 2, 470);

            // Code 128 C
            PdfCode128CBarcode code128CBarcode = new PdfCode128CBarcode();
            code128CBarcode.Data = "423409865432";
            code128CBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code128CBarcode, 173 - code128CBarcode.Width / 2, 570);

            // COOP 25
            PdfCoop25Barcode coop25Barcode = new PdfCoop25Barcode();
            coop25Barcode.Data = "43256565543";
            coop25Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(coop25Barcode, 173 + 266 - coop25Barcode.Width / 2, 570);

            // Matrix 25
            PdfMatrix25Barcode matrix25Barcode = new PdfMatrix25Barcode();
            matrix25Barcode.Data = "500540024300";
            matrix25Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(matrix25Barcode, 173 - matrix25Barcode.Width / 2, 670);

            // MSI/Plessey
            PdfMsiPlesseyBarcode msiPlesseyBarcode = new PdfMsiPlesseyBarcode();
            msiPlesseyBarcode.Data = "1124332556";
            msiPlesseyBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(msiPlesseyBarcode, 173 + 266 - msiPlesseyBarcode.Width / 2, 670);

            page.Graphics.CompressAndClose();
        }
예제 #33
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.Graphics.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.Graphics.SetExtendedGraphicState(gs1);
            page.Graphics.DrawString("Sample watermark over page content", sao, slo);

            page.Graphics.RestoreGraphicsState();
        }
예제 #34
0
        private static void Create3DAnnotations(PdfFixedDocument document, PdfFont font, Stream u3dStream)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();
            page.Rotation = 90;

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

            byte[] u3dContent = new byte[u3dStream.Length];
            u3dStream.Read(u3dContent, 0, u3dContent.Length);

            Pdf3DView view0 = new Pdf3DView();
            view0.CameraToWorldMatrix = new double[] { 1, 0, 0, 0, 0, -1, 0, 1, 0, -0.417542, -0.881257, -0.125705 };
            view0.CenterOfOrbit = 0.123106;
            view0.ExternalName = "Default";
            view0.InternalName = "Default";
            view0.Projection = new Pdf3DProjection();
            view0.Projection.FieldOfView = 30;

            Pdf3DView view1 = new Pdf3DView();
            view1.CameraToWorldMatrix = new double[] { -0.999888, 0.014949, 0, 0.014949, 0.999887, 0.00157084, 0.0000234825, 0.00157066, -0.999999, -0.416654, -0.761122, -0.00184508 };
            view1.CenterOfOrbit = 0.123106;
            view1.ExternalName = "Top";
            view1.InternalName = "Top";
            view1.Projection = new Pdf3DProjection();
            view1.Projection.FieldOfView = 14.8096;

            Pdf3DView view2 = new Pdf3DView();
            view2.CameraToWorldMatrix = new double[] { -1.0, -0.0000411671, 0.0000000000509201, -0.00000101387, 0.0246288, 0.999697, -0.0000411546, 0.999697, -0.0246288, -0.417072, -0.881787, -0.121915 };
            view2.CenterOfOrbit = 0.123106;
            view2.ExternalName = "Side";
            view2.InternalName = "Side";
            view2.Projection = new Pdf3DProjection();
            view2.Projection.FieldOfView = 12.3794;

            Pdf3DView view3 = new Pdf3DView();
            view3.CameraToWorldMatrix = new double[] { -0.797002, -0.603977, -0.0000000438577, -0.294384, 0.388467, 0.873173, -0.527376, 0.695921, -0.48741, -0.3518, -0.844506, -0.0675629 };
            view3.CenterOfOrbit = 0.123106;
            view3.ExternalName = "Isometric";
            view3.InternalName = "Isometric";
            view3.Projection = new Pdf3DProjection();
            view3.Projection.FieldOfView = 15.1226;

            Pdf3DView view4 = new Pdf3DView();
            view4.CameraToWorldMatrix = new double[] { 0.00737633, -0.999973, -0.0000000000147744, -0.0656414, -0.000484206, 0.997843, -0.997816, -0.00736042, -0.0656432, -0.293887, -0.757928, -0.119485 };
            view4.CenterOfOrbit = 0.123106;
            view4.ExternalName = "Front";
            view4.InternalName = "Front";
            view4.Projection = new Pdf3DProjection();
            view4.Projection.FieldOfView = 15.1226;

            Pdf3DView view5 = new Pdf3DView();
            view5.CameraToWorldMatrix = new double[] { 0.0151008, 0.999886, 0.0000000000261366, 0.0492408, -0.000743662, 0.998787, 0.998673, -0.0150825, -0.0492464, -0.540019, -0.756862, -0.118884 };
            view5.CenterOfOrbit = 0.123106;
            view5.ExternalName = "Back";
            view5.InternalName = "Back";
            view5.Projection = new Pdf3DProjection();
            view5.Projection.FieldOfView = 12.3794;

            Pdf3DStream _3dStream = new Pdf3DStream();
            _3dStream.Views.Add(view0);
            _3dStream.Views.Add(view1);
            _3dStream.Views.Add(view2);
            _3dStream.Views.Add(view3);
            _3dStream.Views.Add(view4);
            _3dStream.Views.Add(view5);
            _3dStream.Content = u3dContent;
            _3dStream.DefaultViewIndex = 0;
            Pdf3DAnnotation _3da = new Pdf3DAnnotation();
            _3da.Stream = _3dStream;

            PdfAnnotationAppearance appearance = new PdfAnnotationAppearance(200, 200);
            appearance.Graphics.DrawString("Click to activate", font, blackBrush, 50, 50);
            _3da.NormalAppearance = appearance;

            page.Annotations.Add(_3da);
            _3da.VisualRectangle = new PdfVisualRectangle(36, 36, 720, 540);

            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Font = font;
            sao.Brush = blackBrush;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.Y = 585 + 18 / 2;
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;

            PdfPen blackPen = new PdfPen(new PdfRgbColor(0, 0, 0), 1);

            page.Graphics.DrawRectangle(blackPen, 50, 585, 120, 18);
            slo.X = 50 + 120 / 2;
            page.Graphics.DrawString("Top", sao, slo);

            PdfGoTo3DViewAction gotoTopView = new PdfGoTo3DViewAction();
            gotoTopView.ViewIndex = 1;
            gotoTopView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoTopView = new PdfLinkAnnotation();
            page.Annotations.Add(linkGotoTopView);
            linkGotoTopView.VisualRectangle = new PdfVisualRectangle(50, 585, 120, 18);
            linkGotoTopView.Action = gotoTopView;

            page.Graphics.DrawRectangle(blackPen, 190, 585, 120, 18);
            slo.X = 190 + 120 / 2;
            page.Graphics.DrawString("Side", sao, slo);

            PdfGoTo3DViewAction gotoSideView = new PdfGoTo3DViewAction();
            gotoSideView.ViewIndex = 2;
            gotoSideView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoSideView = new PdfLinkAnnotation();
            page.Annotations.Add(linkGotoSideView);
            linkGotoSideView.VisualRectangle = new PdfVisualRectangle(190, 585, 120, 18);
            linkGotoSideView.Action = gotoSideView;

            page.Graphics.DrawRectangle(blackPen, 330, 585, 120, 18);
            slo.X = 330 + 120 / 2;
            page.Graphics.DrawString("Isometric", sao, slo);

            PdfGoTo3DViewAction gotoIsometricView = new PdfGoTo3DViewAction();
            gotoIsometricView.ViewIndex = 3;
            gotoIsometricView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoIsometricView = new PdfLinkAnnotation();
            page.Annotations.Add(linkGotoIsometricView);
            linkGotoIsometricView.VisualRectangle = new PdfVisualRectangle(330, 585, 120, 18);
            linkGotoIsometricView.Action = gotoIsometricView;

            page.Graphics.DrawRectangle(blackPen, 470, 585, 120, 18);
            slo.X = 470 + 120 / 2;
            page.Graphics.DrawString("Front", sao, slo);

            PdfGoTo3DViewAction gotoFrontView = new PdfGoTo3DViewAction();
            gotoFrontView.ViewIndex = 4;
            gotoFrontView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoFrontView = new PdfLinkAnnotation();
            page.Annotations.Add(linkGotoFrontView);
            linkGotoFrontView.VisualRectangle = new PdfVisualRectangle(470, 585, 120, 18);
            linkGotoFrontView.Action = gotoFrontView;

            page.Graphics.DrawRectangle(blackPen, 610, 585, 120, 18);
            slo.X = 610 + 120 / 2;
            page.Graphics.DrawString("Back", sao, slo);

            PdfGoTo3DViewAction gotoBackView = new PdfGoTo3DViewAction();
            gotoBackView.ViewIndex = 5;
            gotoBackView.TargetAnnotation = _3da;
            PdfLinkAnnotation linkGotoBackView = new PdfLinkAnnotation();
            page.Annotations.Add(linkGotoBackView);
            linkGotoBackView.VisualRectangle = new PdfVisualRectangle(610, 585, 120, 18);
            linkGotoBackView.Action = gotoBackView;
        }
예제 #35
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 graphics to be located under existing page content.
            page.SetGraphicsPosition(PdfPageGraphicsPosition.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.Graphics.DrawString("Sample watermark under page content", sao, slo);
        }
예제 #36
0
        private static void DrawEanUpcBarcodes(PdfPage page, PdfFont titleFont, PdfFont barcodeFont)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen lightGrayPen = new PdfPen(PdfRgbColor.LightGray, 0.5);

            page.Graphics.DrawString("EAN/UPC barcodes", titleFont, brush, 40, 20);
            for (int i = 0; i < 7; i++)
            {
                page.Graphics.DrawLine(lightGrayPen, 40, 50 + 100 * i, 570, 50 + 100 * i);
            }
            page.Graphics.DrawLine(lightGrayPen, 306, 50, 306, 750);

            string[] barcodes = new string[] { "EAN 128", "EAN-13", "EAN-8", "ISBN", "ISMN", "ISSN", "JAN-13", "UPC-A", "UPC-E" };
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = brush;
            sao.Font = barcodeFont;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;

            slo.X = 173;
            int sign = 1;
            for (int i = 0; i < barcodes.Length; i++)
            {
                slo.Y = 55 + 100 * (i / 2);

                page.Graphics.DrawString(barcodes[i], sao, slo);

                slo.X = slo.X + sign * 266;
                sign = -sign;
            }

            // EAN 128
            PdfEan128Barcode ean128Barcode = new PdfEan128Barcode();
            ean128Barcode.Data = "WWW.XFINIUMSOFT.COM";
            ean128Barcode.QuietZones.Left = 0;
            ean128Barcode.QuietZones.Right = 0;
            ean128Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            ean128Barcode.ApplicationIdentifier = "URL";
            page.Graphics.DrawBarcode(ean128Barcode, 173 - ean128Barcode.Width / 2, 70);

            // EAN-13
            PdfEan13Barcode ean13Barcode = new PdfEan13Barcode();
            ean13Barcode.Data = "437612735617";
            ean13Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(ean13Barcode, 173 + 266 - ean13Barcode.Width / 2, 70);

            // EAN-8
            PdfEan8Barcode ean8Barcode = new PdfEan8Barcode();
            ean8Barcode.Data = "5423731";
            ean8Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(ean8Barcode, 173 - ean8Barcode.Width / 2, 170);

            // ISBN
            PdfIsbnBarcode isbnBarcode = new PdfIsbnBarcode();
            isbnBarcode.Data = "436314378";
            isbnBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(isbnBarcode, 173 + 266 - isbnBarcode.Width / 2, 170);

            // ISMN
            PdfIsmnBarcode ismnBarcode = new PdfIsmnBarcode();
            ismnBarcode.Data = "437612489";
            ismnBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(ismnBarcode, 173 - ismnBarcode.Width / 2, 270);

            // ISSN
            PdfIssnBarcode issnBarcode = new PdfIssnBarcode();
            issnBarcode.Data = "546712341";
            issnBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(issnBarcode, 173 + 266 - issnBarcode.Width / 2, 270);

            // JAN-13
            PdfJan13Barcode jan13Barcode = new PdfJan13Barcode();
            jan13Barcode.Data = "1256127634";
            jan13Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(jan13Barcode, 173 - jan13Barcode.Width / 2, 370);

            // UPC-A
            PdfUpcaBarcode upcaBarcode = new PdfUpcaBarcode();
            upcaBarcode.Data = "12543267841";
            upcaBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(upcaBarcode, 173 + 266 - upcaBarcode.Width / 2, 370);

            // UPC-E
            PdfUpceBarcode upceBarcode = new PdfUpceBarcode();
            upceBarcode.Data = "1234532";
            upceBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(upceBarcode, 173 - upceBarcode.Width / 2, 470);

            page.Graphics.CompressAndClose();
        }
예제 #37
0
        private static void DrawPharmaBarcodes(PdfPage page, PdfFont titleFont, PdfFont barcodeFont)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen lightGrayPen = new PdfPen(PdfRgbColor.LightGray, 0.5);

            page.Graphics.DrawString("Pharma barcodes (barcodes used in the pharmaceutical industry)", titleFont, brush, 40, 20);
            for (int i = 0; i < 2; i++)
            {
                page.Graphics.DrawLine(lightGrayPen, 40, 50 + 100 * i, 570, 50 + 100 * i);
            }
            page.Graphics.DrawLine(lightGrayPen, 306, 50, 306, 250);

            string[] barcodes = new string[] { "Code 32", "Pharmacode", "PZN (Pharma-Zentral-Nummer)" };
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = brush;
            sao.Font = barcodeFont;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;

            slo.X = 173;
            int sign = 1;
            for (int i = 0; i < barcodes.Length; i++)
            {
                slo.Y = 55 + 100 * (i / 2);

                page.Graphics.DrawString(barcodes[i], sao, slo);

                slo.X = slo.X + sign * 266;
                sign = -sign;
            }

            // Code 32
            PdfCode32Barcode code32Barcode = new PdfCode32Barcode();
            code32Barcode.Data = "54925174";
            code32Barcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(code32Barcode, 173 - code32Barcode.Width / 2, 70);

            // Pharmacode
            PdfPharmacodeBarcode pharmacodeBarcode = new PdfPharmacodeBarcode();
            pharmacodeBarcode.Data = "128128";
            pharmacodeBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(pharmacodeBarcode, 173 + 266 - pharmacodeBarcode.Width / 2, 70);

            // PZN
            PdfPznBarcode pznBarcode = new PdfPznBarcode();
            pznBarcode.Data = "903271";
            pznBarcode.BarcodeTextPosition = PdfBarcodeTextPosition.Bottom;
            page.Graphics.DrawBarcode(pznBarcode, 173 - pznBarcode.Width / 2, 170);

            page.Graphics.CompressAndClose();
        }
예제 #38
0
        private static void CreateLaunchActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen blackPen = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = blackBrush;
            sao.Font = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("Launch actions:", font, blackBrush, 400, 360);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 380, 200, 20);
                slo.X = 500;
                slo.Y = 390;
                document.Pages[i].Graphics.DrawString("Launch samples explorer", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 380, 200, 20);

                // Create a launch action and attach it to the link.
                PdfLaunchAction launchAction = new PdfLaunchAction();
                launchAction.FileName = "Xfinium.Pdf.SamplesExplorer.Win.exe";
                link.Action = launchAction;
            }
        }
예제 #39
0
        private static void Draw2DBarcodes(PdfPage page, PdfFont titleFont, PdfFont barcodeFont)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen lightGrayPen = new PdfPen(PdfRgbColor.LightGray, 0.5);

            page.Graphics.DrawString("2D barcodes", titleFont, brush, 40, 20);
            for (int i = 0; i < 3; i++)
            {
                page.Graphics.DrawLine(lightGrayPen, 40, 50 + 150 * i, 570, 50 + 150 * i);
            }
            page.Graphics.DrawLine(lightGrayPen, 306, 50, 306, 500);

            string[] barcodes = new string[] { "Codablock F", "Code 16K", "PDF417", "Micro PDF417", "DataMatrix", "QR" };
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = brush;
            sao.Font = barcodeFont;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Top;

            slo.X = 173;
            int sign = 1;
            for (int i = 0; i < barcodes.Length; i++)
            {
                slo.Y = 55 + 150 * (i / 2);

                page.Graphics.DrawString(barcodes[i], sao, slo);

                slo.X = slo.X + sign * 266;
                sign = -sign;
            }

            // Codablock F
            PdfCodablockFBarcode codablockFBarcode = new PdfCodablockFBarcode();
            codablockFBarcode.Data = "*** Xfinium.Pdf ***";
            codablockFBarcode.Columns = 10;
            codablockFBarcode.Rows = 5;
            page.Graphics.DrawBarcode(codablockFBarcode, 173 - codablockFBarcode.Width / 2, 70);

            // Code 16K
            PdfCode16KBarcode code16KBarcode = new PdfCode16KBarcode();
            code16KBarcode.Data = "*** Xfinium.Pdf ***";
            code16KBarcode.Rows = 6;
            page.Graphics.DrawBarcode(code16KBarcode, 173 + 266 - code16KBarcode.Width / 2, 70);

            // PDF 417
            Pdf417RegularBarcode pdf417Barcode = new Pdf417RegularBarcode();
            pdf417Barcode.Data = "*** Xfinium.Pdf ***";
            pdf417Barcode.Columns = 10;
            pdf417Barcode.Rows = 0;
            page.Graphics.DrawBarcode(pdf417Barcode, 173 - pdf417Barcode.Width / 2, 220);

            // MicroPDF 417
            Pdf417MicroBarcode microPdf417Barcode = new Pdf417MicroBarcode();
            microPdf417Barcode.Data = "* Xfinium.Pdf *";
            microPdf417Barcode.BarcodeSize = Pdf417MicroBarcodeSize.Rows6Columns4;
            page.Graphics.DrawBarcode(microPdf417Barcode, 173 + 266 - microPdf417Barcode.Width / 2, 220);

            // DataMatrix
            PdfDataMatrixBarcode datamatrixBarcode = new PdfDataMatrixBarcode();
            datamatrixBarcode.Data = "*** Xfinium.Pdf ***";
            datamatrixBarcode.XDimension = 2;
            datamatrixBarcode.BarcodeSize = DataMatrixBarcodeSize.Auto;
            page.Graphics.DrawBarcode(datamatrixBarcode, 173 - datamatrixBarcode.Width / 2, 370);

            // QR Barcode
            PdfQrBarcode qrBarcode = new PdfQrBarcode();
            qrBarcode.XDimension = 2;
            qrBarcode.Data = "Xfinium.Pdf: http://www.xfiniumpdf.com/";
            qrBarcode.CharacterSet = PdfQrBarcodeCharacterSet.ISO88591;
            page.Graphics.DrawBarcode(qrBarcode, 173 + 266 - qrBarcode.Width / 2, 370);

            page.Graphics.CompressAndClose();
        }
예제 #40
0
        private static void CreateNamedActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen blackPen = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = blackBrush;
            sao.Font = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("Named actions:", font, blackBrush, 400, 20);

                /////////////
                // First page
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 40, 200, 20);
                slo.X = 500;
                slo.Y = 50;
                document.Pages[i].Graphics.DrawString("Go To First Page", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 40, 200, 20);

                // Create a named action and attach it to the link.
                PdfNamedAction namedAction = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.FirstPage;
                link.Action = namedAction;

                /////////////
                // Prev page
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 80, 200, 20);
                slo.Y = 90;
                document.Pages[i].Graphics.DrawString("Go To Previous Page", sao, slo);

                // Create a link annotation on top of the widget.
                link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 80, 200, 20);

                // Create a named action and attach it to the link.
                namedAction = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.PrevPage;
                link.Action = namedAction;

                /////////////
                // Next page
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 120, 200, 20);
                slo.Y = 130;
                document.Pages[i].Graphics.DrawString("Go To Next Page", sao, slo);

                // Create a link annotation on top of the widget.
                link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 120, 200, 20);

                // Create a named action and attach it to the link.
                namedAction = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.NextPage;
                link.Action = namedAction;

                /////////////
                // Last page
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 160, 200, 20);
                slo.Y = 170;
                document.Pages[i].Graphics.DrawString("Go To Last Page", sao, slo);

                // Create a link annotation on top of the widget.
                link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 160, 200, 20);

                // Create a named action and attach it to the link.
                namedAction = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.LastPage;
                link.Action = namedAction;

                /////////////
                // Print document
                /////////////
                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 200, 200, 20);
                slo.Y = 210;
                document.Pages[i].Graphics.DrawString("Print Document", sao, slo);

                // Create a link annotation on top of the widget.
                link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 200, 200, 20);

                // Create a named action and attach it to the link.
                namedAction = new PdfNamedAction();
                namedAction.NamedAction = PdfActionName.Print;
                link.Action = namedAction;
            }
        }
예제 #41
0
        private static void DrawTextRenderingModes(PdfPage page, PdfStandardFont titleFont)
        {
            PdfBrush brush = new PdfBrush();
            PdfPen redPen = new PdfPen(PdfRgbColor.Red, 0.5);
            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 12);
            PdfStandardFont helveticaBold = new PdfStandardFont(PdfStandardFontFace.Helvetica, 80);

            page.Graphics.DrawString("Text rendering modes", titleFont, brush, 20, 50);

            page.Graphics.DrawString("Fill text", helvetica, brush, 20, 90);
            page.Graphics.DrawString("Stroke text", helvetica, brush, 20, 160);
            page.Graphics.DrawString("Fill and stroke text", helvetica, brush, 20, 230);
            page.Graphics.DrawString("Invisible text", helvetica, brush, 20, 300);
            page.Graphics.DrawString("Fill and clip text", helvetica, brush, 20, 370);
            page.Graphics.DrawString("Stroke and clip text", helvetica, brush, 20, 440);
            page.Graphics.DrawString("Fill, stroke and clip text", helvetica, brush, 20, 510);
            page.Graphics.DrawString("Clip text", helvetica, brush, 20, 580);

            // Fill text - text interior is filled because only the brush is available for drawing.
            page.Graphics.DrawString("A B C", helveticaBold, brush, 300, 90);

            // Stroke text - text outline is stroked becuase only the pen is available for drawing.
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.X = 300;
            slo.Y = 160;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Font = helveticaBold;
            sao.Pen = redPen;
            sao.Brush = null;
            page.Graphics.DrawString("A B C", sao, slo);

            // Fill and stroke text - text interior is filled and text outline is stroked
            // because both pen and brush are available.
            slo.Y = 230;
            sao.Pen = redPen;
            sao.Brush = brush;
            page.Graphics.DrawString("A B C", sao, slo);

            // Invisible text - text is not displayed because both pen and brush are not available.
            slo.Y = 300;
            sao.Pen = null;
            sao.Brush = null;
            page.Graphics.DrawString("A B C", sao, slo);

            // Fill and clip text - text interior is filled and then text outline is added to current clipping path.
            page.Graphics.SaveGraphicsState();
            helveticaBold.TextRenderingMode = PdfTextRenderingMode.FillAndClipText;
            slo.Y = 370;
            sao.Pen = null;
            sao.Brush = brush;
            page.Graphics.DrawString("A B C", sao, slo);
            DrawHorizontalLines(page.Graphics, redPen, slo.X, slo.Y, 250, 70);
            page.Graphics.RestoreGraphicsState();

            // Stroke and clip text - text outline is stroked and then text outline is added to current clipping path.
            page.Graphics.SaveGraphicsState();
            helveticaBold.TextRenderingMode = PdfTextRenderingMode.StrokeAndClipText;
            slo.Y = 440;
            sao.Pen = redPen;
            sao.Brush = null;
            page.Graphics.DrawString("A B C", sao, slo);
            DrawHorizontalLines(page.Graphics, redPen, slo.X, slo.Y, 250, 70);
            page.Graphics.RestoreGraphicsState();

            // Fill, Stroke and clip text - text interior is filled, text outline is stroked and then text outline is added to current clipping path.
            page.Graphics.SaveGraphicsState();
            helveticaBold.TextRenderingMode = PdfTextRenderingMode.FillStrokeAndClipText;
            slo.Y = 510;
            sao.Pen = redPen;
            sao.Brush = brush;
            page.Graphics.DrawString("A B C", sao, slo);
            DrawHorizontalLines(page.Graphics, redPen, slo.X, slo.Y, 250, 70);
            page.Graphics.RestoreGraphicsState();

            // Clip text - text outline is added to current clipping path.
            page.Graphics.SaveGraphicsState();
            helveticaBold.TextRenderingMode = PdfTextRenderingMode.ClipText;
            slo.Y = 580;
            sao.Pen = redPen;
            sao.Brush = brush;
            page.Graphics.DrawString("A B C", sao, slo);
            DrawHorizontalLines(page.Graphics, redPen, slo.X, slo.Y, 250, 70);
            page.Graphics.RestoreGraphicsState();
        }