Ejemplo n.º 1
0
        /// <summary>
        /// Draws the Watermark
        /// </summary>
        /// <param name="gfx">XGraphics object</param>
        private void AddWatermark(XGraphics gfx)
        {
            gfx.RotateTransform(-40);
            XFont  font  = new XFont("Arial Rounded MT Bold", 60, XFontStyle.Regular);
            XBrush brush = new XSolidBrush(XColor.FromArgb(70, 255, 0, 0));

            gfx.DrawString("VALGKORT", font, brush, -120, 250);
            gfx.RotateTransform(40);
        }
        /// <summary>
        /// Demonstrates the use of XGraphics.Transform.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            gfx.Save();

            gfx.IntersectClip(new XRect(20, 20, 300, 500));
            gfx.DrawRectangle(XBrushes.Yellow, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);

            gfx.IntersectClip(new XRect(100, 200, 300, 500));
            gfx.DrawRectangle(XBrushes.LightBlue, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);

            gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
            gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));


            Matrix matrix = new Matrix();

            //matrix.Scale(2f, 1.5f);
            //matrix.Translate(-200, -400);
            //matrix.Rotate(45);
            //matrix.Translate(200, 400);
            //gfx.Transform = matrix;
            //gfx.TranslateTransform(50, 30);

#if true
            gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
            gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
            gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
            gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
            gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
            gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
            bool id = matrix.IsIdentity;
            matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
            //matrix.Translate(30, -50);
            matrix.Rotate(15, MatrixOrder.Prepend);
            //Matrix mtx = gfx.Transform.ToGdipMatrix();
            //gfx.Transform = matrix;

            gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
            gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));

            //gfx.ResetClip();
            gfx.Restore();

            gfx.DrawLine(XPens.Red, 0, 0, 1000, 1000);

            gfx.DrawPolygon(XPens.SandyBrown, GetPentagram(75, new PointF(150, 200)));
        }
Ejemplo n.º 3
0
        static void watermarkprint(XGraphics gfx, PdfPage page, XFont font)
        {
            string watermark = "TestME";


            // Get the size (in point) of the text
            XSize size = gfx.MeasureString(watermark, font);

            // Define a rotation transformation at the center of the page
            gfx.TranslateTransform(page.Width / 2, page.Height / 2);
            gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
            gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

            // Create a string format
            XStringFormat format = new XStringFormat();

            format.Alignment     = XStringAlignment.Near;
            format.LineAlignment = XLineAlignment.Near;

            // Create a dimmed red brush
            XBrush brush = new XSolidBrush(XColor.FromArgb(60, 128, 125, 123));

            // Draw the string
            gfx.DrawString(watermark, font, brush,
                           new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
                           format);
        }
Ejemplo n.º 4
0
        public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics)
        {
            if (!string.IsNullOrEmpty(Data))
            {
                var   watermark = Data;
                XSize size      = Graphics.MeasureString(watermark, owner.Font);

                // Define a rotation transformation at the center of the page
                Graphics.TranslateTransform(Page.Width / 2, Page.Height / 2);
                Graphics.RotateTransform(-Math.Atan(Page.Height / Page.Width) * 180 / Math.PI);
                Graphics.TranslateTransform(-Page.Width / 2, -Page.Height / 2);

                // Create a graphical path
                XGraphicsPath path = new XGraphicsPath();

                // Add the text to the path
                path.AddString(watermark, owner.Font.FontFamily, XFontStyle.BoldItalic, 150, new XPoint(0, (Page.Height / 2) - 80), XStringFormats.TopLeft);

                // Create a dimmed red pen and brush
                XPen   pen   = new XPen(XColor.FromArgb(50, 75, 0, 130), 3);
                XBrush brush = new XSolidBrush(XColor.FromArgb(50, 106, 90, 205));

                // Stroke the outline of the path
                Graphics.DrawPath(pen, brush, path);
            }
        }
Ejemplo n.º 5
0
        public void PostaviWathermark(string nazivKompanije, PdfPage strana)
        {
            XGraphics      gfx           = XGraphics.FromPdfPage(strana, XGraphicsPdfPageOptions.Prepend);
            XFont          font          = new XFont("Times New Roman", 26, XFontStyle.Bold);
            XTextFormatter textFormatter = new XTextFormatter(gfx);

            var size = gfx.MeasureString("PDFSharp", font);

            gfx.TranslateTransform(strana.Width / 2, strana.Height / 2);
            gfx.RotateTransform(-Math.Atan(strana.Height / strana.Width) * 180 / Math.PI);
            gfx.TranslateTransform(-strana.Width / 2, -strana.Height / 2);

            var format = new XStringFormat();

            format.Alignment     = XStringAlignment.Near;
            format.LineAlignment = XLineAlignment.Near;

            XBrush brush = new XSolidBrush(XColor.FromArgb(128, 141, 184, 224));

            gfx.DrawString(nazivKompanije.ToUpper(),
                           font,
                           brush,
                           new XPoint((strana.Width - size.Width) / 2, (strana.Height - size.Height) / 2), format);

            gfx.Dispose();
        }
Ejemplo n.º 6
0
        public static void DrawImageOnPage(PdfPage page, XImage image, double x, double y, double page_rotation)
        {
            XGraphics gfx = XGraphics.FromPdfPage(page);

            // there is a bug for landscape PDF files
            Console.WriteLine("orientation {0}", page.Orientation);
            if (page.Orientation == PdfSharp.PageOrientation.Landscape)
            {
                // Translate coordinate system. To solve a strange problem.
                gfx.RotateTransform(-90);
                gfx.TranslateTransform(-page.Height, 0);
            }

            // rotate
            if (page_rotation != 0.0)
            {
                Console.WriteLine("rotate {0} degree", page_rotation);

                XPoint centerPoint = new XPoint(page.Width / 2, page.Height / 2);
                gfx.RotateAtTransform(-page_rotation, centerPoint);
            }

            gfx.DrawImage(image, x, y);
            gfx.Dispose();
        }
Ejemplo n.º 7
0
        private void DrawWaterMarkDiagonal(int wx, int wy, string wText, XFont wFont, Color wColor)
        {
            XSize sf = gfx.MeasureString(wText, wFont);

            gfx.TranslateTransform(wx / 2, wy / 2);

            double Agle = -Math.Atan(wy / wx) * 90 / Math.PI;

            gfx.RotateTransform((float)Agle);
            gfx.TranslateTransform(-wx / 2, -wy / 2);

            XStringFormat wformat = new XStringFormat();

            wformat.Alignment     = XStringAlignment.Near;
            wformat.LineAlignment = XLineAlignment.Near;

            XBrush wbrush = new XSolidBrush(Color.FromArgb(20, wColor));

            wx = (int)(wx - sf.Width) / 2;
            wy = (int)(wy - sf.Height) / 2;

            XPoint Point_xy = new XPoint(wx, wy);

            gfx.DrawString(wText, wFont, wbrush, Point_xy, wformat);
        }
Ejemplo n.º 8
0
        public static void Run()
        {
            using (PdfDocument document = PdfReader.Open("BarCodeTest3.pdf", PdfDocumentOpenMode.Modify))
            {
                //create new pdf page
                PdfPage page = document.Pages[0];
                //declare a font for drawing in the PDF
                XFont font = new XFont(FontNames.MrvCode39S, 15, XFontStyle.Regular);
                using (XGraphics gfx = XGraphics.FromPdfPage(page))
                {
                    gfx.DrawString("*00112001*", font, XBrushes.Red,
                                   new XRect(72, 216, 0, 0), XStringFormats.BaseLineLeft);
                    gfx.DrawString("*00112001*", font, XBrushes.BlueViolet,
                                   new XRect(0, 120, 0, 0), XStringFormats.BaseLineLeft);
                    // Define a rotation transformation at the center of the page.
                    gfx.TranslateTransform(page.Width / 2, page.Height / 2);
                    gfx.RotateTransform(-90);
                    gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

                    gfx.DrawString("*00112001*", font, XBrushes.Red,
                                   new XRect(72, 216, 0, 0), XStringFormats.BaseLineLeft);
                    // x1 = W/2 - H/2 + y0;
                    // y1 = H/2 + W/2 - x0;
                    // letter size  x1 = y0 - 90;   y1 = 702 - x0;
                    // eg, (x1,y1)=(30,762)  ==> (x0,y0)=(-60,120)
                    gfx.DrawString("*00112001*", font, XBrushes.RoyalBlue,
                                   new XRect(-60, 120, 0, 0), XStringFormats.BaseLineLeft);
                }


                document.Save("BarCodeTest31.pdf");
            }
        }
Ejemplo n.º 9
0
 static void DrawFace(XGraphics gfx, XPen pen, XBrush brush)
 {
     for (int i = 0; i < 60; i++)
     {
         int size = i % 5 == 0 ? 100 : 30;
         gfx.DrawEllipse(pen, brush, 0 - size / 2, -900 - size / 2, size, size);
         gfx.RotateTransform(6);
     }
 }
Ejemplo n.º 10
0
        public IActionResult Watermark()
        {
            const string text =
                "Facin exeraessisit la consenim iureet dignibh eu facilluptat vercil dunt autpat. " +
                "Ecte magna faccum dolor sequisc iliquat, quat, quipiss equipit accummy niate magna " +
                "facil iure eraesequis am velit, quat atis dolore dolent luptat nulla adio odipissectet " +
                "lan venis do essequatio conulla facillandrem zzriusci bla ad minim inis nim velit eugait " +
                "aut aut lor at ilit ut nulla ate te eugait alit augiamet ad magnim iurem il eu feuissi.\n" +
                "Guer sequis duis eu feugait luptat lum adiamet, si tate dolore mod eu facidunt adignisl in " +
                "henim dolorem nulla faccum vel inis dolutpatum iusto od min ex euis adio exer sed del " +
                "dolor ing enit veniamcon vullutat praestrud molenis ciduisim doloborem ipit nulla consequisi.\n" +
                "Nos adit pratetu eriurem delestie del ut lumsandreet nis exerilisit wis nos alit venit praestrud " +
                "dolor sum volore facidui blaor erillaortis ad ea augue corem dunt nis  iustinciduis euisi.\n" +
                "Ut ulputate volore min ut nulpute dolobor sequism olorperilit autatie modit wisl illuptat dolore " +
                "min ut in ute doloboreet ip ex et am dunt at.";

            PdfDocument document = new PdfDocument();

            PdfPage        page = document.AddPage();
            XGraphics      gfx  = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);
            XFont          font = new XFont("Times New Roman", 16, XFontStyle.Bold);
            XTextFormatter tf   = new XTextFormatter(gfx);

            XRect xRect = new XRect(40, 40, 250, 220);

            gfx.DrawRectangle(XBrushes.SeaShell, xRect);
            tf.DrawString("Naslov", font, XBrushes.Black, xRect, XStringFormats.TopLeft);

            font = new XFont("Times New Roman", 10, XFontStyle.Bold);

            XRect rect = new XRect(40, 100, 250, 220);

            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            //tf.Alignment = ParagraphAlignment.Left;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            var size = gfx.MeasureString("PDFSharp", font);

            gfx.TranslateTransform(page.Width / 2, page.Height / 2);
            gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
            gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

            var format = new XStringFormat();

            format.Alignment     = XStringAlignment.Near;
            format.LineAlignment = XLineAlignment.Near;

            XBrush brush = new XSolidBrush(XColor.FromArgb(128, 255, 0, 0));

            gfx.DrawString("Wathermark", font, brush, new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2), format);
            MemoryStream stream = new MemoryStream();

            document.Save(stream, false);
            stream.Position = 0;
            return(File(stream, "application/pdf", "watermark.pdf"));
        }
Ejemplo n.º 11
0
        void DrawSecondHand(XGraphics gfx, XPen pen)
        {
            XGraphicsState gs = gfx.Save();

            gfx.RotateTransform(360 * Time.Second / 60 + 6 * Time.Millisecond / 1000);

            gfx.DrawEllipse(new XSolidBrush(pen.Color), -15, -15, 30, 30);
            gfx.DrawLine(pen, 0, 40, 0, -800);
            gfx.Restore(gs);
        }
Ejemplo n.º 12
0
        private static void RenderToGraphics(Render.RenderContext ctx, int rot, float translateX, float translateY, XGraphics graphics)
        {
            graphics.TranslateTransform(translateX, translateY);
            graphics.RotateTransform(rot * 90);

            using (Maps.Rendering.RenderUtil.SaveState(graphics))
            {
                if (ctx.clipPath != null)
                {
                    XMatrix m = ctx.ImageSpaceToWorldSpace;
                    graphics.MultiplyTransform(m);
                    graphics.IntersectClip(ctx.clipPath);
                    m.Invert();
                    graphics.MultiplyTransform(m);
                }

                ctx.graphics = graphics;
                Maps.Rendering.Render.RenderTile(ctx);
            }


            if (ctx.border && ctx.clipPath != null)
            {
                using (Maps.Rendering.RenderUtil.SaveState(graphics))
                {
                    // Render border in world space
                    XMatrix m = ctx.ImageSpaceToWorldSpace;
                    graphics.MultiplyTransform(m);
                    XPen pen = new XPen(ctx.styles.imageBorderColor, 0.2f);

                    // PdfSharp can't ExcludeClip so we take advantage of the fact that we know
                    // the path starts on the left edge and proceeds clockwise. We extend the
                    // path with a counterclockwise border around it, then use that to exclude
                    // the original path's region for rendering the border.
                    ctx.clipPath.Flatten();
                    RectangleF bounds = PathUtil.Bounds(ctx.clipPath);
                    bounds.Inflate(2 * (float)pen.Width, 2 * (float)pen.Width);
                    List <byte>   types  = new List <byte>(ctx.clipPath.Internals.GdiPath.PathTypes);
                    List <PointF> points = new List <PointF>(ctx.clipPath.Internals.GdiPath.PathPoints);

                    PointF key = points[0];
                    points.Add(new PointF(bounds.Left, key.Y)); types.Add(1);
                    points.Add(new PointF(bounds.Left, bounds.Bottom)); types.Add(1);
                    points.Add(new PointF(bounds.Right, bounds.Bottom)); types.Add(1);
                    points.Add(new PointF(bounds.Right, bounds.Top)); types.Add(1);
                    points.Add(new PointF(bounds.Left, bounds.Top)); types.Add(1);
                    points.Add(new PointF(bounds.Left, key.Y)); types.Add(1);
                    points.Add(new PointF(key.X, key.Y)); types.Add(1);

                    XGraphicsPath path = new XGraphicsPath(points.ToArray(), types.ToArray(), XFillMode.Winding);
                    graphics.IntersectClip(path);
                    graphics.DrawPath(pen, ctx.clipPath);
                }
            }
        }
Ejemplo n.º 13
0
        void DrawHourHand(XGraphics gfx, XPen pen, XBrush brush)
        {
            XGraphicsState gs = gfx.Save();

            gfx.RotateTransform(360 * Time.Hour / 12 + 30 * Time.Minute / 60);
            gfx.DrawPolygon(pen, brush,
                            new XPoint[] { new XPoint(0, 150), new XPoint(100, 0),
                                           new XPoint(0, -600), new XPoint(-100, 0) },
                            XFillMode.Winding);
            gfx.Restore(gs);
        }
Ejemplo n.º 14
0
        protected void DrawMinuteHand(XGraphics gfx, XPen pen, XBrush brush)
        {
            XGraphicsState gs = gfx.Save();

            gfx.RotateTransform(360 * Time.Minute / 60 + 6 * Time.Second / 60);

            gfx.DrawPolygon(pen, brush,
                            new XPoint[] { new XPoint(0, 200), new XPoint(50, 0), new XPoint(0, -800), new XPoint(-50, 0) },
                            XFillMode.Winding);
            gfx.Restore(gs);
        }
Ejemplo n.º 15
0
        private void addWatermark_Click(object sender, RoutedEventArgs e)
        {
            // Take existing pdf
            PdfDocument document = PdfReader.Open(filename, PdfDocumentOpenMode.Modify);

            var pagesCount = document.Pages.Count;



            string watermark = "Kowal";

            //Set Font

            XFont font = new XFont("Times New Roman", 100, XFontStyle.Bold);

            int n = 0;

            while (n < pagesCount)
            {
                var page = document.Pages[n];
                // Get an XGraphics object for drawing beneath the existing content
                XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);

                // Get the size (in point) of the text
                XSize size = gfx.MeasureString(watermark, font);

                // Define a rotation transformation at the center of the page
                gfx.TranslateTransform(page.Width / 2, page.Height / 2);
                gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
                gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

                // Create a string format
                XStringFormat format = new XStringFormat();
                format.Alignment     = XStringAlignment.Near;
                format.LineAlignment = XLineAlignment.Near;

                // Create a dimmed red brush
                XBrush brush = new XSolidBrush(XColor.FromArgb(128, 255, 0, 0));


                // Draw the string
                gfx.DrawString(watermark, font, brush,
                               new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2), format);
                n++;
            }


            //Save Document
            document.Save(filename);
        }
Ejemplo n.º 16
0
        private void DrawImageRotated(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "DrawImage (rotated)");
            XImage xImage = XImage.FromFile("../../../../../../dev/XGraphicsLab/images/Z3.jpg");

            gfx.TranslateTransform(125.0, 70.0);
            gfx.ScaleTransform(0.7);
            gfx.RotateTransform(-25.0);
            gfx.TranslateTransform(-125.0, -70.0);
            double num    = (double)(xImage.PixelWidth * 72) / xImage.HorizontalResolution;
            double height = (double)(xImage.PixelHeight * 72) / xImage.HorizontalResolution;

            gfx.DrawImage(xImage, (250.0 - num) / 2.0, 0.0, num, height);
            base.EndBox(gfx);
        }
        /// <summary>
        /// Demonstrates the use of XGraphics.Transform.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            //gfx.Clear(this.properties.General.BackColor.Color);
            //base.RenderPage(gfx);

            gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
            gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));

            Matrix matrix = new Matrix();

            //matrix.Scale(2f, 1.5f);
            //matrix.Translate(-200, -400);
            //matrix.Rotate(45);
            //matrix.Translate(200, 400);
            //gfx.Transform = matrix;
            //gfx.TranslateTransform(50, 30);

#if true
            gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
            gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
            gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
            gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
            gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
            gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
            bool id = matrix.IsIdentity;
            matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
            //matrix.Translate(30, -50);
            matrix.Rotate(15, MatrixOrder.Prepend);
            //Matrix mtx = gfx.Transform.ToGdipMatrix();
            //gfx.Transform = matrix;

            gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
            gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));
        }
Ejemplo n.º 18
0
        public override void SetTransformation(double translateX, double translateY, double rotate, double scaleX, double scaleY)
        {
            // Revert to original state, and immediately put this state on the stack again.
            XGraphics.Restore();
            XGraphics.Save();

            XGraphics.TranslateTransform(translateX, translateY);
            if (rotate != 0.0)
            {
                XGraphics.RotateTransform(rotate / System.Math.PI * 180.0);
            }
            if (scaleX != 1.0 || scaleY != 1.0)
            {
                XGraphics.ScaleTransform(scaleX, scaleY);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Demonstrates the use of XGraphics.DrawImage.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            XImage image = XImage.FromFile(@"..\..\images\Test (OS2).bmp");

            double dx = gfx.PageSize.Width;
            double dy = gfx.PageSize.Height;

#if true
            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.RotateTransform(-60);
            gfx.TranslateTransform(-dx / 2, -dy / 2);
#endif

            gfx.DrawImage(image, (dx - image.PixelWidth) / 2, (dy - image.PixelHeight) / 2, image.PixelWidth, image.PixelHeight);
        }
Ejemplo n.º 20
0
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            XImage image = XImage.FromFile(@"..\..\..\..\samples\PDFs\SomeLayout.pdf");

            double dx = gfx.PageSize.Width;
            double dy = gfx.PageSize.Height;

#if true
            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.RotateTransform(-25);
            gfx.TranslateTransform(-dx / 2, -dy / 2);
#endif

            gfx.DrawImage(image, (dx - image.PixelWidth) / 2, (dy - image.PixelHeight) / 2, image.PixelWidth, image.PixelHeight);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Draws an image transformed.
        /// </summary>
        void DrawImageRotated(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawImage (rotated)");

            var image = XImage.FromFile(JpegSamplePath);

            const double dx = 250, dy = 140;

            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.ScaleTransform(0.7);
            gfx.RotateTransform(-25);
            gfx.TranslateTransform(-dx / 2, -dy / 2);
            var width  = image.PixelWidth * 72 / image.HorizontalResolution;
            var height = image.PixelHeight * 72 / image.HorizontalResolution;

            gfx.DrawImage(image, (dx - width) / 2, 0, width, height);

            EndBox(gfx);
        }
Ejemplo n.º 22
0
        public static void DrawChevron(XGraphics graphics, PointF pos, float angle, float size, Brush fillBrush)
        {
            if (m_chevronPath == null)
            {
                var apex        = new PointF(0.5f, 0);
                var leftCorner  = new PointF(-0.5f, 0.5f);
                var rightCorner = new PointF(-0.5f, -0.5f);
                m_chevronPath = new XGraphicsPath();
                m_chevronPath.AddLine(apex, rightCorner);
                m_chevronPath.AddLine(rightCorner, leftCorner);
                m_chevronPath.AddLine(leftCorner, apex);
            }
            var state = graphics.Save();

            graphics.TranslateTransform(pos.X, pos.Y);
            graphics.RotateTransform(angle);
            graphics.ScaleTransform(size, size);
            graphics.DrawPath(fillBrush, m_chevronPath);
            graphics.Restore(state);
        }
Ejemplo n.º 23
0
        public static void verticalBarCode2()
        {
            using (PdfDocument document = new PdfDocument())
            {
                //create pdf header
                document.Info.Title        = "My barcode";
                document.Info.Author       = "Me";
                document.Info.Subject      = "Barcode";
                document.Info.Keywords     = "Barcode, Ean13";
                document.Info.CreationDate = DateTime.Now;

                //create new pdf page
                PdfPage page = document.AddPage();
                page.Width  = XUnit.FromPoint(672);
                page.Height = XUnit.FromPoint(890);

                using (XGraphics gfx = XGraphics.FromPdfPage(page))
                {
                    //make sure the font is embedded
                    var options = new XPdfFontOptions(PdfFontEncoding.Unicode);

                    //declare a font for drawing in the PDF
                    XFont          fontEan      = new XFont("mrvcode39s", 20, XFontStyle.Regular, options);
                    XTextFormatter tf           = new XTextFormatter(gfx);
                    var            stringFormat = new XStringFormat();
                    stringFormat.Alignment = XStringAlignment.Center;

                    gfx.RotateTransform(-90.0);
                    //create the barcode from string
                    var point1 = new XPoint(-20, -20);
                    var point2 = new XPoint(20, 20);
                    gfx.DrawString("*12234*", fontEan, XBrushes.Black, new XRect(point1, point2), stringFormat);
                }


                document.Save("VerticalBarCodeNew.pdf");
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Renders the content of the page.
        /// </summary>
        public void Render(XGraphics gfx)
        {
            XRect  rect;
            XPen   pen;
            double x = 50, y = 100;
            XFont  fontH1     = new XFont("Times", 18, XFontStyle.Bold);
            XFont  font       = new XFont("Times", 12);
            XFont  fontItalic = new XFont("Times", 12, XFontStyle.BoldItalic);
            double ls         = font.GetHeight(gfx);

            // Draw some text
            gfx.DrawString("Create PDF on the fly with PDFsharp",
                           fontH1, XBrushes.Black, x, x);
            gfx.DrawString("With PDFsharp you can use the same code to draw graphic, " +
                           "text and images on different targets.", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("The object used for drawing is the XGraphics object.",
                           font, XBrushes.Black, x, y);
            y += 2 * ls;

            // Draw an arc
            pen           = new XPen(XColors.Red, 4);
            pen.DashStyle = XDashStyle.Dash;
            gfx.DrawArc(pen, x + 20, y, 100, 60, 150, 120);

            // Draw a star
            XGraphicsState gs = gfx.Save();

            gfx.TranslateTransform(x + 140, y + 30);
            for (int idx = 0; idx < 360; idx += 10)
            {
                gfx.RotateTransform(10);
                gfx.DrawLine(XPens.DarkGreen, 0, 0, 30, 0);
            }
            gfx.Restore(gs);

            // Draw a rounded rectangle
            rect = new XRect(x + 230, y, 100, 60);
            pen  = new XPen(XColors.DarkBlue, 2.5);
            XColor color1 = XColor.FromKnownColor(KnownColor.DarkBlue);
            XColor color2 = XColors.Red;
            XLinearGradientBrush lbrush = new XLinearGradientBrush(rect, color1, color2,
                                                                   XLinearGradientMode.Vertical);

            gfx.DrawRoundedRectangle(pen, lbrush, rect, new XSize(10, 10));

            // Draw a pie
            pen           = new XPen(XColors.DarkOrange, 1.5);
            pen.DashStyle = XDashStyle.Dot;
            gfx.DrawPie(pen, XBrushes.Blue, x + 360, y, 100, 60, -130, 135);

            // Draw some more text
            y += 60 + 2 * ls;
            gfx.DrawString("With XGraphics you can draw on a PDF page as well as " +
                           "on any System.Drawing.Graphics object.", font, XBrushes.Black, x, y);
            y += ls * 1.1;
            gfx.DrawString("Use the same code to", font, XBrushes.Black, x, y);
            x += 10;
            y += ls * 1.1;
            gfx.DrawString("• draw on a newly created PDF page", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw above or beneath of the content of an existing PDF page",
                           font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw in a window", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw on a printer", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw in a bitmap image", font, XBrushes.Black, x, y);
            x -= 10;
            y += ls * 1.1;
            gfx.DrawString("You can also import an existing PDF page and use it like " +
                           "an image, e.g. draw it on another PDF page.", font, XBrushes.Black, x, y);
            y += ls * 1.1 * 2;
            gfx.DrawString("Imported PDF pages are neither drawn nor printed; create a " +
                           "PDF file to see or print them!", fontItalic, XBrushes.Firebrick, x, y);
            y += ls * 1.1;
            gfx.DrawString("Below this text is a PDF form that will be visible when " +
                           "viewed or printed with a PDF viewer.", fontItalic, XBrushes.Firebrick, x, y);
            y += ls * 1.1;
            XGraphicsState state   = gfx.Save();
            XRect          rcImage = new XRect(100, y, 100, 100 * Math.Sqrt(2));

            gfx.DrawRectangle(XBrushes.Snow, rcImage);
            gfx.DrawImage(XPdfForm.FromFile("../../../../../PDFs/SomeLayout.pdf"), rcImage);
            gfx.Restore(state);
        }
Ejemplo n.º 25
0
 public void RotateTransform(float angle)
 {
     _transform.Rotate(angle);
     _graphics.RotateTransform(angle);
 }
Ejemplo n.º 26
0
        // The end goal is to have a user select the path of a PDf in need of watermarks.
        // Submit the file and press GO. Once they press Go, it grabs the pdf and watermarks it, then saves it in the network folder.

        public void markPDF(string filepath, string watermark, string userfile, int fontSize, string destination)
        {
            string userWatermark = watermark;

            // If the watermark field is empty.
            if (string.IsNullOrEmpty(filepath))
            {
                MessageBox.Show("ERROR: No PDF selected. \n \nSelect a correct file.", "WaterPDF", MessageBoxButtons.OK);// Alert the user
            }
            // If the path field is empty.
            else if (string.IsNullOrEmpty(userWatermark))
            {
                MessageBox.Show("ERROR: No Watermark text. \n \nEnter text for the watermark.", "WaterPDF", MessageBoxButtons.OK);  // Alert the user.
            }
            // If the new filename is empty.
            else if (string.IsNullOrWhiteSpace(userfile))
            {
                MessageBox.Show("ERROR: No save filename. \n \nEnter a save filename", "WaterPDF", MessageBoxButtons.OK); // Alert the user.
            }
            else if (string.IsNullOrWhiteSpace(destination))
            {
                MessageBox.Show("ERROR : No destination. \n \nChoose a save folder.", "WaterPDF", MessageBoxButtons.OK); // Alert the user.
            }
            else
            {
                // Creates a new file path to save the watermarked PDF.
                string newFileName = destination + @"\" + userfile + ".pdf";

                // Opens the file from the path provided.
                PdfDocument document = PdfReader.Open(filepath);

                // Counts the amount of pages in the PDF.
                PdfPages pages = document.Pages;

                // foreach page in pdf
                // Paint the pdf and then move onto the next one?

                // Sets the first page as the page to work on.
                PdfPage page  = document.Pages[0];
                string  fonts = Convert.ToString(fontSize);

                int.TryParse(fonts, out int result);

                // Creating the font variable.
                XFont font = new XFont("Arial", result, XFontStyle.Regular);
                // Creating the graphics.
                XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append);

                var size = gfx.MeasureString(watermark, font);

                // Creating the coordinates.
                gfx.TranslateTransform(page.Width / 2, page.Height / 2);
                gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
                gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

                var format = new XStringFormat();
                format.Alignment     = XStringAlignment.Near;
                format.LineAlignment = XLineAlignment.Near;

                // Creating the brush to paint with.
                XBrush brush = new XSolidBrush(XColor.FromKnownColor(XKnownColor.LightSlateGray));

                gfx.DrawString(watermark, font, brush,
                               new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
                               format);

                gfx.DrawString(watermark, font, brush,
                               new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
                               format);

                // Saves it in the provided location.
                document.Save(newFileName);
                if (MessageBox.Show("Your PDF has been watered.", "WaterPDF") == DialogResult.OK)
                {
                    // Alerts the user that the file was saved and creates an explorer window of the destination.
                    System.Diagnostics.Process.Start("explorer.exe", destination);
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Draws the axis title.
        /// </summary>
        internal override void Draw()
        {
            AxisRendererInfo      ari  = (AxisRendererInfo)this.rendererParms.RendererInfo;
            AxisTitleRendererInfo atri = ari.axisTitleRendererInfo;

            if (atri.AxisTitleText != "")
            {
                XGraphics gfx = this.rendererParms.Graphics;
                if (atri.AxisTitleOrientation != 0)
                {
                    XRect layout = atri.Rect;
                    layout.X = -(layout.Width / 2);
                    layout.Y = -(layout.Height / 2);

                    double x = 0;
                    switch (atri.AxisTitleAlignment)
                    {
                    case HorizontalAlignment.Center:
                        x = atri.X + atri.Width / 2;
                        break;

                    case HorizontalAlignment.Right:
                        x = atri.X + atri.Width - layout.Width / 2;
                        break;

                    case HorizontalAlignment.Left:
                    default:
                        x = atri.X;
                        break;
                    }

                    double y = 0;
                    switch (atri.AxisTitleVerticalAlignment)
                    {
                    case VerticalAlignment.Center:
                        y = atri.Y + atri.Height / 2;
                        break;

                    case VerticalAlignment.Bottom:
                        y = atri.Y + atri.Height - layout.Height / 2;
                        break;

                    case VerticalAlignment.Top:
                    default:
                        y = atri.Y;
                        break;
                    }

                    XStringFormat xsf = new XStringFormat();
                    xsf.Alignment     = XStringAlignment.Center;
                    xsf.LineAlignment = XLineAlignment.Center;

                    XGraphicsState state = gfx.Save();
                    gfx.TranslateTransform(x, y);
                    gfx.RotateTransform(-atri.AxisTitleOrientation);
                    gfx.DrawString(atri.AxisTitleText, atri.AxisTitleFont, atri.AxisTitleBrush, layout, xsf);
                    gfx.Restore(state);
                }
                else
                {
                    XStringFormat format = new XStringFormat();
                    switch (atri.AxisTitleAlignment)
                    {
                    case HorizontalAlignment.Center:
                        format.Alignment = XStringAlignment.Center;
                        break;

                    case HorizontalAlignment.Right:
                        format.Alignment = XStringAlignment.Far;
                        break;

                    case HorizontalAlignment.Left:
                    default:
                        format.Alignment = XStringAlignment.Near;
                        break;
                    }

                    switch (atri.AxisTitleVerticalAlignment)
                    {
                    case VerticalAlignment.Center:
                        format.LineAlignment = XLineAlignment.Center;
                        break;

                    case VerticalAlignment.Bottom:
                        format.LineAlignment = XLineAlignment.Far;
                        break;

                    case VerticalAlignment.Top:
                    default:
                        format.LineAlignment = XLineAlignment.Near;
                        break;
                    }

                    gfx.DrawString(atri.AxisTitleText, atri.AxisTitleFont, atri.AxisTitleBrush, atri.Rect, format);
                }
            }
        }
Ejemplo n.º 28
0
        static void Main()
        {
            const string watermark = "PDFsharp";
            const int    emSize    = 150;

            // Get a fresh copy of the sample PDF file
            const string filename = "Portable Document Format.pdf";

            File.Copy(Path.Combine("../../../../../PDFs/", filename),
                      Path.Combine(Directory.GetCurrentDirectory(), filename), true);

            // Create the font for drawing the watermark
            XFont font = new XFont("Times New Roman", emSize, XFontStyle.BoldItalic);

            // Open an existing document for editing and loop through its pages
            PdfDocument document = PdfReader.Open(filename);

            // Set version to PDF 1.4 (Acrobat 5) because we use transparency.
            if (document.Version < 14)
            {
                document.Version = 14;
            }

            for (int idx = 0; idx < document.Pages.Count; idx++)
            {
                //if (idx == 1) break;
                PdfPage page = document.Pages[idx];

                switch (idx % 3)
                {
                case 0:
                {
                    // Variation 1: Draw watermark as text string

                    // Get an XGraphics object for drawing beneath the existing content
                    XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);

#if true_
                    // Fill background with linear gradient color
                    XRect rect = page.MediaBox.ToXRect();
                    XLinearGradientBrush gbrush = new XLinearGradientBrush(rect,
                                                                           XColors.LightSalmon, XColors.WhiteSmoke, XLinearGradientMode.Vertical);
                    gfx.DrawRectangle(gbrush, rect);
#endif

                    // Get the size (in point) of the text
                    XSize size = gfx.MeasureString(watermark, font);

                    // Define a rotation transformation at the center of the page
                    gfx.TranslateTransform(page.Width / 2, page.Height / 2);
                    gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
                    gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

                    // Create a string format
                    XStringFormat format = new XStringFormat();
                    format.Alignment     = XStringAlignment.Near;
                    format.LineAlignment = XLineAlignment.Near;

                    // Create a dimmed red brush
                    XBrush brush = new XSolidBrush(XColor.FromArgb(128, 255, 0, 0));

                    // Draw the string
                    gfx.DrawString(watermark, font, brush,
                                   new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
                                   format);
                }
                break;

                case 1:
                {
                    // Variation 2: Draw watermark as outlined graphical path

                    // Get an XGraphics object for drawing beneath the existing content
                    XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);

                    // Get the size (in point) of the text
                    XSize size = gfx.MeasureString(watermark, font);

                    // Define a rotation transformation at the center of the page
                    gfx.TranslateTransform(page.Width / 2, page.Height / 2);
                    gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
                    gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

                    // Create a graphical path
                    XGraphicsPath path = new XGraphicsPath();

                    // Add the text to the path
                    path.AddString(watermark, font.FontFamily, XFontStyle.BoldItalic, 150,
                                   new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
                                   XStringFormats.Default);

                    // Create a dimmed red pen
                    XPen pen = new XPen(XColor.FromArgb(128, 255, 0, 0), 2);

                    // Stroke the outline of the path
                    gfx.DrawPath(pen, path);
                }
                break;

                case 2:
                {
                    // Variation 3: Draw watermark as transparent graphical path above text

                    // Get an XGraphics object for drawing above the existing content
                    XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append);

                    // Get the size (in point) of the text
                    XSize size = gfx.MeasureString(watermark, font);

                    // Define a rotation transformation at the center of the page
                    gfx.TranslateTransform(page.Width / 2, page.Height / 2);
                    gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
                    gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

                    // Create a graphical path
                    XGraphicsPath path = new XGraphicsPath();

                    // Add the text to the path
                    path.AddString(watermark, font.FontFamily, XFontStyle.BoldItalic, 150,
                                   new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
                                   XStringFormats.Default);

                    // Create a dimmed red pen and brush
                    XPen   pen   = new XPen(XColor.FromArgb(50, 75, 0, 130), 3);
                    XBrush brush = new XSolidBrush(XColor.FromArgb(50, 106, 90, 205));

                    // Stroke the outline of the path
                    gfx.DrawPath(pen, brush, path);
                }
                break;
                }
            }
            // Save the document...
            document.Save(filename);
            // ...and start a viewer
            Process.Start(filename);
        }
        /// <summary>
        /// Demonstrates the use of XLinearGradientBrush.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            XRect rect;
            XLinearGradientBrush brush;
            Graphics             grfx = gfx.Internals.Graphics;

            XLinearGradientBrush brush2 =
                new XLinearGradientBrush(
                    new XPoint(100, 100),
                    new XPoint(300, 300),
                    XColors.DarkRed, XColors.Yellow);

            //gfx.FillRectangle(brush, 0, 0, 600, 600);
            //gfx.TranslateTransform(35, 200);
            //gfx.RotateTransform(17);

            rect  = new XRect(20, 50, 100, 200);
            brush = new XLinearGradientBrush(rect,
                                             XColors.DarkRed, XColors.Yellow, XLinearGradientMode.Horizontal);
            gfx.DrawRectangle(XPens.Red, brush, rect);

            rect  = new XRect(140, 50, 100, 200);
            brush = new XLinearGradientBrush(rect,
                                             XColors.DarkRed, XColors.Yellow, XLinearGradientMode.Vertical);
            gfx.DrawRectangle(XPens.Red, brush, rect);

            rect  = new XRect(260, 50, 100, 200);
            brush = new XLinearGradientBrush(rect,
                                             XColors.DarkRed, XColors.Yellow, XLinearGradientMode.ForwardDiagonal);
            gfx.DrawRectangle(XPens.Red, brush, rect);

            rect  = new XRect(380, 50, 100, 200);
            brush = new XLinearGradientBrush(rect,
                                             XColors.DarkRed, XColors.Yellow, XLinearGradientMode.BackwardDiagonal);
            gfx.DrawRectangle(XPens.Red, brush, rect);


            gfx.TranslateTransform(80, 250);
            gfx.ScaleTransform(1.1);
            gfx.RotateTransform(20);

            rect  = new XRect(20, 50, 100, 200);
            brush = new XLinearGradientBrush(rect,
                                             XColors.Orange, XColors.DarkBlue, XLinearGradientMode.Horizontal);
            gfx.DrawRectangle(XPens.Red, brush, rect);

            rect  = new XRect(140, 50, 100, 200);
            brush = new XLinearGradientBrush(rect,
                                             XColors.Orange, XColors.DarkBlue, XLinearGradientMode.Vertical);
            gfx.DrawRectangle(XPens.Red, brush, rect);

            rect  = new XRect(260, 50, 100, 200);
            brush = new XLinearGradientBrush(rect,
                                             XColors.Orange, XColors.DarkBlue, XLinearGradientMode.ForwardDiagonal);
            gfx.DrawRectangle(XPens.Red, brush, rect);

            rect  = new XRect(380, 50, 100, 200);
            brush = new XLinearGradientBrush(rect,
                                             XColors.Orange, XColors.DarkBlue, XLinearGradientMode.BackwardDiagonal);
            gfx.DrawRectangle(XPens.Red, brush, rect);
        }
        public override void RenderPage(XGraphics gfx)
        {
#if true_
            // Create a new PDF document
            //PdfDocument document = new PdfDocument();

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

            // Create a new page
            //PdfPage page = document.AddPage();
            //XGraphics gfx = XGraphics.FromPdfPage(page);
            //gfx.DrawString("XPdfForm Sample", font, XBrushes.DarkGray, 15, 25, XStringFormat.Default);

            // Step 1: Create an XForm and draw some graphics on it

            // Create an empty XForm object with the specified width and height
            // A form is bound to its target document when it is created. The reason is that the form can
            // share fonts and other objects with its target document.
            XForm form = new XForm(gfx, XUnit.FromMillimeter(70), XUnit.FromMillimeter(55));

            // Create an XGraphics object for drawing the contents of the form.
            XGraphics formGfx = XGraphics.FromForm(form);

            // Draw a large transparent rectangle to visualize the area the form occupies
            XColor back = XColors.Orange;
            back.A = 0.2;
            XSolidBrush brush = new XSolidBrush(back);
            formGfx.DrawRectangle(brush, -10000, -10000, 20000, 20000);


            // On a form you can draw...

            //// ... text
            //formGfx.DrawString("Text, Graphics, Images, and Forms", new XFont("Verdana", 10, XFontStyle.Regular), XBrushes.Navy, 3, 0, XStringFormat.TopLeft);
            //XPen pen = XPens.LightBlue.Clone();
            //pen.Width = 2.5;

            // ... graphics like Bézier curves
            //formGfx.DrawBeziers(pen, XPoint.ParsePoints("30,120 80,20, 100,140 175,33.3"));

            //// ... raster images like GIF files
            //XGraphicsState state = formGfx.Save();
            //formGfx.RotateAtTransform(17, new XPoint(30, 30));
            //formGfx.DrawImage(XImage.FromFile("../../../../XGraphicsLab/images/Test.gif"), 20, 20);
            //formGfx.Restore(state);

            //// ... and forms like XPdfForm objects
            //state = formGfx.Save();
            //formGfx.RotateAtTransform(-8, new XPoint(165, 115));
            //formGfx.DrawImage(XPdfForm.FromFile("../../../../PDFs/SomeLayout.pdf"), new XRect(140, 80, 50, 50 * Math.Sqrt(2)));
            //formGfx.Restore(state);

            // When you finished drawing on the form, dispose the XGraphic object.
            formGfx.Dispose();


            // Step 2: Draw the XPdfForm on your PDF page like an image

            // Draw the form on the page of the document in its original size
            gfx.DrawImage(form, 20, 50);

#if true_
            // Draw it stretched
            gfx.DrawImage(form, 300, 100, 250, 40);

            // Draw and rotate it
            int d = 25;
            for (int idx = 0; idx < 360; idx += d)
            {
                gfx.DrawImage(form, 300, 480, 200, 200);
                gfx.RotateAtTransform(d, new XPoint(300, 480));
            }
#endif

            //// Save the document...
            //string filename = "XForms.pdf";
            //document.Save(filename);
            //// ...and start a viewer.
            //Process.Start(filename);
#else
            //base.RenderPage(gfx);

            int   cx = 300;
            int   cy = 240;
            XForm form;
            //if (gfx.PdfPage == null)
            form = new XForm(gfx, cx, cy);
            //else
            //  form = new XForm(gfx.PdfPage.Owner, cx, cy);

            double dx = gfx.PageSize.Width;
            double dy = gfx.PageSize.Height;

            XGraphics   formgfx = XGraphics.FromForm(form);
            XSolidBrush brush   = new XSolidBrush(XColor.FromArgb(128, 0, 255, 255));
            formgfx.DrawRectangle(brush, -1000, -1000, 2000, 2000);
            formgfx.DrawLine(XPens.Red, 0, 0, cx, cy);
            formgfx.DrawLine(XPens.Red, cx, 0, 0, cy);

            XFont font = new XFont("Times", 16, XFontStyle.BoldItalic);
            formgfx.DrawString("Text", font, XBrushes.DarkOrange, 0, 0, XStringFormats.TopLeft);
            formgfx.DrawString("Text", font, XBrushes.DarkOrange, new XRect(0, 0, cx, cy), XStringFormats.Center);

            // Required to finish drawing the form. Both cases are correct.
#if true
            formgfx.Dispose();
#else
            form.DrawingFinished();
#endif
            gfx.DrawImage(form, 50, 50);

#if true_
            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.RotateTransform(-25);
            gfx.TranslateTransform(-dx / 2, -dy / 2);

            gfx.DrawImage(form, (dx - form.Width) / 2, (dy - form.Height) / 2, form.Width, form.Height);
#endif
#endif
        }