DrawImage() публичный Метод

Draws the specified image.
public DrawImage ( XImage image, PointF point ) : void
image XImage
point PointF
Результат void
Пример #1
0
        public override void Render(ref PdfSharp.Drawing.XGraphics gfx, double offsetLeft, double offsetTop, double scaleX, double scaleY)
        {
            PreRender(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);

            double imgwidth  = Util.MillimeterToPoint(ImageWidth) * scaleX,
                   imgheight = Util.MillimeterToPoint(ImageHeight) * scaleY,
                   imgpadx   = Util.MillimeterToPoint(ImagePaddingX) * scaleX,
                   imgpady   = Util.MillimeterToPoint(ImagePaddingY) * scaleY,
                   left      = Util.MillimeterToPoint(offsetLeft + Left),
                   top       = Util.MillimeterToPoint(offsetTop + Top),
                   width     = Util.MillimeterToPoint(Width * scaleX),
                   height    = Util.MillimeterToPoint(Height * scaleY);


            for (double y = 0; y + imgpady + imgheight < height; y += imgheight + imgpady)
            {
                if (RightToLeft)
                {
                    for (double x = width - imgwidth; x > 0; x -= imgwidth + imgpadx)
                    {
                        if (images.Count > 0)
                        {
                            gfx.DrawImage((XImage)images.Dequeue(), left + x, top + y, imgwidth, imgheight);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    for (double x = 0; x + imgpadx + imgwidth < width; x += imgwidth + imgpadx)
                    {
                        if (images.Count > 0)
                        {
                            gfx.DrawImage((XImage)images.Dequeue(), left + x, top + y, imgwidth, imgheight);
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                if (images.Count == 0)
                {
                    break;
                }
            }


            base.Render(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);
        }
Пример #2
0
    /// <summary>
    /// Demonstrates the use of XGraphics.DrawImage.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

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

      gfx.DrawImage(image, 100, 100, 400, 400);

      XImage image2 = XImage.FromFile(@"..\..\images\image009.gif");  

      gfx.DrawImage(image2, 100, 500, 400, 200);
    }
Пример #3
0
    /// <summary>
    /// Demonstrates the use of XGraphics.DrawImage.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XImage image = XImage.FromFile(@"..\..\images\test.png");  
      gfx.DrawImage(image, 100, 100, 400, 400);

      XImage image2 = XImage.FromFile(@"..\..\images\empira.png");  
      gfx.DrawImage(image2, 100, 500, 200, 200);

      XImage image3 = XImage.FromFile(@"..\..\images\reddot.png");  
      gfx.DrawImage(image3, 300, 500, 200, 200);
    }
Пример #4
0
        public static byte[] AppendImageToPdf(byte[] pdf, byte[] img, Point position, double scale)
        {
            using (System.IO.MemoryStream msPdf = new System.IO.MemoryStream(pdf))
            {
                using (System.IO.MemoryStream msImg = new System.IO.MemoryStream(img))
                {
                    System.Drawing.Image       image    = System.Drawing.Image.FromStream(msImg);
                    PdfSharp.Pdf.PdfDocument   document = PdfSharp.Pdf.IO.PdfReader.Open(msPdf);
                    PdfSharp.Pdf.PdfPage       page     = document.Pages[0];
                    PdfSharp.Drawing.XGraphics gfx      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                    PdfSharp.Drawing.XImage    ximg     = PdfSharp.Drawing.XImage.FromGdiPlusImage(image);

                    gfx.DrawImage(
                        ximg,
                        position.X,
                        position.Y,
                        ximg.Width * scale,
                        ximg.Height * scale
                        );

                    using (System.IO.MemoryStream msFinal = new System.IO.MemoryStream())
                    {
                        document.Save(msFinal);
                        return(msFinal.ToArray());
                    }
                }
            }
        }
Пример #5
0
        public override void Render(ref PdfSharp.Drawing.XGraphics gfx, double offsetLeft, double offsetTop, double scaleX, double scaleY)
        {
            PreRender(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);
            if (SourceImage != null)
            {
                double widthScale  = (Width * scaleX) / SourceImage.Width;
                double heightScale = (Height * scaleY) / SourceImage.Height;

                double scale = Math.Min(widthScale, heightScale);

                double width  = SourceImage.Width * scale;
                double height = SourceImage.Height * scale;

                double offsetLeftImage = ((Width * scaleX) - width) / 2.0;
                double offsetTopImage  = ((Height * scaleY) - height) / 2.0;

                gfx.DrawImage(SourceImage,
                              Util.MillimeterToPoint(offsetLeft + Left + offsetLeftImage),
                              Util.MillimeterToPoint(offsetTop + Top + offsetTopImage),
                              Util.MillimeterToPoint(width),
                              Util.MillimeterToPoint(height));
            }
            else
            {
                gfx.DrawRectangle(XBrushes.White, new Rectangle(
                                      (int)Util.MillimeterToPoint(offsetLeft + Left),
                                      (int)Util.MillimeterToPoint(offsetTop + Top),
                                      (int)Util.MillimeterToPoint(Width * scaleX),
                                      (int)Util.MillimeterToPoint(Height * scaleY)));
            }

            base.Render(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);
        }
Пример #6
0
 public void DrawTo(XGraphics context)
 {
     var state = context.Save();
     layout.Transform(context, form.Size);
     form.PageIndex = sourcePageIndex;
     context.DrawImage(form, 0, 0);
     context.Restore(state);
 }
Пример #7
0
    /// <summary>
    /// Draws an image scaled.
    /// </summary>
    void DrawImageScaled(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawImage (scaled)");

      XImage image = XImage.FromFile(jpegSamplePath);
      gfx.DrawImage(image, 0, 0, 250, 140);

      EndBox(gfx);
    }
Пример #8
0
    void RenderGIFs(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XImage image = XImage.FromFile(gifSamplePath);

      // Left position in point
      double x = (250 - image.PixelWidth * 72 / image.HorizontalResolution) / 2;
      gfx.DrawImage(image, x, 0);
    }
Пример #9
0
        public void Render(XGraphics gfx, FixedElement element)
        {
            var specification = (Image) element.Specification;
            var source = ((PdfSharpImage) specification.Source).Source;

            gfx.DrawImage(source,
                          element.InnerBox.Left.Points,
                          element.InnerBox.Top.Points - element.VisiblePartOfSpecification.Top.Points,
                          element.InnerBox.Width.Points,
                          source.PixelHeight);
        }
Пример #10
0
    /// <summary>
    /// Draws an image in original size.
    /// </summary>
    void DrawImage(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawImage (original)");

      XImage image = XImage.FromFile(jpegSamplePath);

      // Left position in point
      double x = (250 - image.PixelWidth * 72 / image.HorizontalResolution) / 2;
      gfx.DrawImage(image, x, 0);

      EndBox(gfx);
    }
Пример #11
0
    /// <summary>
    /// Demonstrates the use of XGraphics.DrawImage.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);
      gfx.SmoothingMode = XSmoothingMode.None;

      //XImage image = XImage.FromFile(@"..\..\images\PNG (200x100).png");
      //XImage image = XImage.FromFile(@"..\..\images\CMYK balloons.tif");  
      //XImage image = XImage.FromFile(@"..\..\images\Dune.tif");  
      //XImage image = XImage.FromFile(@"..\..\images\Fern.tif");  
      XImage image = XImage.FromFile(@"../../images/Rose (RGB 8).tif");  

      gfx.DrawImage(image, 100, 100, 400, 400);
    }
Пример #12
0
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XImage image = XImage.FromFile(@"..\..\images\Z3.jpg");
      //XImage image = XImage.FromFile(@"..\..\images\CityLogo.jpeg");
      double width = image.PixelWidth;
      double height = image.PixelHeight;
      //double resolution = image.Format
      width.GetType();
      height.GetType();
      //gfx.DrawImage(image, 100, 100, 200, 200);
      gfx.DrawImage(image, 100, 100);
    }
Пример #13
0
        public void DrawStats(XGraphics gfx)
        {
            XFont large = new XFont("Arial", 20);
            XFont small = new XFont("Arial", 12);

            double yOff = page_.Height * 0.11;

            XRect rect = new XRect(20, yOff, page_.Width - 40, page_.Height - (yOff + 20));
            DrawingUtil.DrawOutlineRect(rect, gfx, cornerRadius);
            gfx.DrawRoundedRectangle(backgroundBrush, rect, cornerRadius);
            XPoint center = new XPoint(page_.Width * 0.5, page_.Height * 0.45);

            XImage sideLunge = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\SideLunge.png");
            XImage frontLunge = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\FrontLunge.png");

            gfx.DrawString("Left Lunge", large, XBrushes.Black, new XPoint(center.X - page_.Width * 0.25, page_.Height * 0.25), XStringFormats.Center);
            gfx.DrawString("Right Lunge", large, XBrushes.Black, new XPoint(center.X + page_.Width * 0.25, page_.Height * 0.25), XStringFormats.Center);

            for (int i = 0; i < 4; i++)
            {
                Parameter param1 = userParameters_.ElementAt(dataReadStart + i);
                Parameter param2 = userParameters_.ElementAt(dataReadStart + i + 4);
                char degree = Convert.ToChar('\u00b0');
                XBrush leftParamCol = XBrushes.Green;
                XBrush rightParamCol = XBrushes.Green;

                double y = (i * page_.Height * 0.15f) + page_.Height * 0.35;
                gfx.DrawString(param1.Name, small, XBrushes.Black, new XPoint(center.X - page_.Width * 0.25, y), XStringFormats.Center);

                leftParamCol = DrawingUtil.Instance.ChooseBrushColor(param1.Color);
                XRect infoRect = new XRect(center.X - page_.Width * 0.25 - 25, y + 20, 50, 35);
                DrawingUtil.DrawOutlineRect(infoRect, gfx, new XSize(10, 10));
                gfx.DrawRoundedRectangle(leftParamCol, infoRect, new XSize(10, 10));
                gfx.DrawString(param1.Value.ToString() + degree, small, XBrushes.Black, new XPoint(infoRect.X + 25, infoRect.Y + 17.5), XStringFormats.Center);

                gfx.DrawString(param2.Name, small, XBrushes.Black, new XPoint(center.X + page_.Width * 0.25, y), XStringFormats.Center);
                rightParamCol = DrawingUtil.Instance.ChooseBrushColor(param2.Color);
                infoRect = new XRect(center.X + page_.Width * 0.25 - 25, y + 20, 50, 35);
                DrawingUtil.DrawOutlineRect(infoRect, gfx, new XSize(10, 10));
                gfx.DrawRoundedRectangle(rightParamCol, infoRect, new XSize(10, 10));
                gfx.DrawString(param2.Value.ToString() + degree, small, XBrushes.Black, new XPoint(infoRect.X + 25, infoRect.Y + 17.5), XStringFormats.Center);

                XImage img = i > 1 ? frontLunge : sideLunge;

                double wRatio = (double)img.PixelWidth / (double)sideLunge.PixelHeight;
                XRect imgRect = new XRect(center.X - wRatio * 40, y, wRatio * 80, 80);
                gfx.DrawImage(img, imgRect);
            }
        }
Пример #14
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);
    }
Пример #15
0
 private static void PrintLogo(XGraphics gfx)
 {
     try
     {
         XImage image = XImage.FromFile("Logo.jpg");
         const double dx = 350, dy = 140;
         //gfx.TranslateTransform(dx / 2, dy / 2);
         gfx.ScaleTransform(0.5);
         //gfx.TranslateTransform(-dx / 2, -dy / 2);
         double width = image.PixelWidth * 72 / image.HorizontalResolution;
         double height = image.PixelHeight * 72 / image.HorizontalResolution;
         gfx.DrawImage(image, 5, 5, dx, dy);
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Пример #16
0
        /// <summary>
        /// Renders the content of the page.
        /// </summary>
        public void Render(XGraphics xGraphics)
        {
            const double textPossitionX = 50;
            double textPossitionY = 100;
            const string fontFamilyName = "Times";
            const int fontSizeHeader = 18;
            const int fontSizeText = 12;

            XFont fontHeader = new XFont(fontFamilyName, fontSizeHeader, XFontStyle.Bold);
            XFont fontText = new XFont(fontFamilyName, fontSizeText);
            XFont fontItalic = new XFont(fontFamilyName, fontSizeText, XFontStyle.BoldItalic);
            double lineSpacing = fontText.GetHeight(xGraphics);

            xGraphics.DrawString("This is Header", fontHeader, XBrushes.Black, textPossitionX, textPossitionX);
            textPossitionY += lineSpacing;
            xGraphics.DrawString("This is normal.", fontText, XBrushes.Black, textPossitionX, textPossitionY);
            textPossitionY += lineSpacing;
            xGraphics.DrawString("This is Italic.", fontItalic, XBrushes.Black, textPossitionX, textPossitionY);

            textPossitionY += lineSpacing*3;

            //Bitmap bitmap = (Bitmap)Image.FromFile(@"E:\temp\klicaj.jpeg");
            XImage xImage = null;
            if (item != null)
            {
                if (item.Image != null)
                {
                    MemoryStream memoryStream = new MemoryStream(item.Image);
                    Bitmap bitmap = (Bitmap) Image.FromStream(memoryStream, true, true);
                    xImage = XImage.FromGdiPlusImage(bitmap);
                }
            }

            if (xImage != null)
            {
                XRect rcImage = new XRect(100, textPossitionY, 100, 100*Math.Sqrt(2));
                xGraphics.DrawImage(xImage, rcImage);
            }

            XGraphicsState state = xGraphics.Save();
            xGraphics.Restore(state);
        }
Пример #17
0
        /// <summary>
        /// Draw the texture image in the given graphics at the given location.
        /// </summary>
        public void DrawRectangle(XGraphics g, double x, double y, double width, double height)
        {
            var prevState = g.Save();
            g.IntersectClip(new XRect(x, y, width, height));

            double rx = _translateTransformLocation.X;
            double w = _image.PixelWidth, h = _image.PixelHeight;
            while (rx < x + width)
            {
                double ry = _translateTransformLocation.Y;
                while (ry < y + height)
                {
                    g.DrawImage(_image, rx, ry, w, h);
                    ry += h;
                }
                rx += w;
            }

            g.Restore(prevState);
        }
Пример #18
0
 void DrawPngMissed(XGraphics gfx, double _indRow, double _indCol)
 {
     object O = Resources.ResourceManager.GetObject("Erreur");
     XImage image = XImage.FromGdiPlusImage((System.Drawing.Image)O);
     double dx = (80 * _indCol) + 33;
     double dy = (113 * _indRow) + 28;
     double width = 57;
     double height = 80;
     gfx.DrawImage(image, dx, dy, width, height);
 }
Пример #19
0
 void DrawPng(XGraphics gfx, double _indRow, double _indCol, string pngSamplePath)
 {
     XImage image;
     if (XImage.ExistsFile(pngSamplePath))
     {
         image = XImage.FromFile(pngSamplePath);
     }
     else
     {
         object O = Resources.ResourceManager.GetObject("Erreur");
         image = XImage.FromGdiPlusImage((System.Drawing.Image)O);
     }
     double dx = (80 * _indCol) + 33;
     double dy = (113 * _indRow) + 28;
     double width = 57;
     double height = 80;
     gfx.DrawImage(image, dx, dy, width, height);
 }
Пример #20
0
        void DrawPng(XGraphics gfx, double _indRow, double _indCol, System.Drawing.Image _imgThumb)
        {
            // Si l'image est plus large que haute, on la fait tourner
            if (_imgThumb.Width > _imgThumb.Height)
            {
                _imgThumb.RotateFlip(RotateFlipType.Rotate270FlipNone);
            }

            XImage image = XImage.FromGdiPlusImage(_imgThumb);
            double dx = (80 * _indCol) + 33;
            double dy = (113 * _indRow) + 28;
            double width = 57;
            double height = 80;
            gfx.DrawImage(image, dx, dy, width, height);
        }
    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
    }
Пример #22
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);
    }
Пример #23
0
    /// <summary>
    /// Renders the matrix code.
    /// </summary>
    protected internal override void Render(XGraphics gfx, XBrush brush, XPoint position)
    {
      XGraphicsState state = gfx.Save();

      switch (this.direction)
      {
        case CodeDirection.RightToLeft:
          gfx.RotateAtTransform(180, position);
          break;

        case CodeDirection.TopToBottom:
          gfx.RotateAtTransform(90, position);
          break;

        case CodeDirection.BottomToTop:
          gfx.RotateAtTransform(-90, position);
          break;
      }

      XPoint pos = position + CodeBase.CalcDistance(this.anchor, AnchorType.TopLeft, this.size);

      if (this.matrixImage == null)
        this.matrixImage = DataMatrixImage.GenerateMatrixImage(Text, Encoding, Rows, Columns);

      if (QuietZone > 0)
      {
        XSize sizeWithZone = new XSize(this.size.width, this.size.height);
        sizeWithZone.width = sizeWithZone.width / (Columns + 2 * QuietZone) * Columns;
        sizeWithZone.height = sizeWithZone.height / (Rows + 2 * QuietZone) * Rows;

        XPoint posWithZone = new XPoint(pos.X, pos.Y);
        posWithZone.X += size.width / (Columns + 2 * QuietZone) * QuietZone;
        posWithZone.Y += size.height / (Rows + 2 * QuietZone) * QuietZone;

        gfx.DrawRectangle(XBrushes.White, pos.x, pos.y, size.width, size.height);
        gfx.DrawImage(matrixImage, posWithZone.x, posWithZone.y, sizeWithZone.width, sizeWithZone.height);
      }
      else
        gfx.DrawImage(matrixImage, pos.x, pos.y, this.size.width, this.size.height);

      gfx.Restore(state);
    }
Пример #24
0
 public static void DrawImageFromFile(XGraphics gfx, string jpegSamplePath, XUnit x, XUnit y, XUnit width, XUnit height)
 {
     XImage image = XImage.FromFile(jpegSamplePath);
     gfx.DrawImage(image, x, y, width, height);
 }
Пример #25
0
 public static void DrawImage(XGraphics gfx, XImage image, XUnit x, XUnit y, XUnit width, XUnit height)
 {
     gfx.DrawImage(image, x, y, width, height);
 }
Пример #26
0
        public bool ExportToPDF(string FileNamePDF, bool ShowFile)
        {
            string strFileTmpPdf = string.Empty ;
            PdfDocument objDocument = null;
            FileInfo objFileInfo = null;
            PdfPage objPage = null;
            XImage objImage = null;
            try
            {
            // Create a new PDF document
            objDocument = new PdfDocument();
            objDocument.Info.Title = "Criado por OPUS DIGITALIZADOR";
            objDocument.Info.Author = "OPUS Comérico Exterior Ltda";
            objDocument.Info.Creator = "OPUS DIGITALIZADOR";

            //Se o diretório de PDF não existir eu o crio
            if (!Directory.Exists(System.Configuration.ConfigurationSettings.AppSettings["DIRPDF"].ToString())) {
                Directory.CreateDirectory (System.Configuration.ConfigurationSettings.AppSettings["DIRPDF"].ToString());
            }

            strFileTmpPdf = System.Configuration.ConfigurationSettings.AppSettings["DIRPDF"].ToString()+ FileNamePDF;
            foreach (string strFileName in System.IO.Directory.GetFiles(System.Configuration.ConfigurationSettings.AppSettings["DIRIMGSCANNER"].ToString() + FileNamePDF))
            {
                objFileInfo = new FileInfo(strFileName);

                if (objFileInfo.Extension.ToUpper() == System.Configuration.ConfigurationSettings.AppSettings["EXTIMG"].ToString())
                {
                    // Create an empty page
                    objPage = objDocument.AddPage();

                    // Get an XGraphics object for drawing
                    objGfx = XGraphics.FromPdfPage(objPage);

                    objImage = XImage.FromFile(strFileName);

                    //double x = (250 - objImage.PixelWidth * 72 / objImage.HorizontalResolution) / 2;
                    int x = Convert.ToInt32 (System.Configuration.ConfigurationSettings.AppSettings["BEGINX"].ToString());
                    int y = Convert.ToInt32 (System.Configuration.ConfigurationSettings.AppSettings["BEGINY"].ToString());
                    int largura = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["WIDTH"].ToString());
                    int altura = Convert.ToInt32 (System.Configuration.ConfigurationSettings.AppSettings["HEIGHT"].ToString());

                    objGfx.DrawImage(objImage,x, y, largura,altura );

                    if (File.Exists(strFileTmpPdf)) File.Delete(strFileTmpPdf);

                    objDocument.Save(strFileTmpPdf);

                }
            }

            if (ShowFile) Process.Start(strFileTmpPdf);
            return true;
            }
            catch (Exception ex)
            {
            throw ex;
            }
            finally {

            objPage = null;

            objImage.Dispose();
            objImage = null;

            objDocument.Dispose();
            objDocument = null;

            objFileInfo = null;

            }
        }
Пример #27
0
        public void DrawHeaderAndFooter(PdfDocument document, PdfPage page, XGraphics gfx, string title)
        {
            //PropSpect Logo
            var filename = Path.Combine(p.ServerProperty.MapPath("~/Content/Images"), "PropSpect.png");
            XImage image = XImage.FromFile(filename);
            gfx.DrawImage(image, 20, 20, 120, 50);


            //Title Text
            XRect rect = new XRect(new XPoint(), gfx.PageSize);
            rect.Inflate(-10, -25);
            gfx.DrawString(title, p.Font16Bold, XBrushes.Black, rect, XStringFormats.TopCenter);

            //Title Date
            if (!string.IsNullOrEmpty(title))
            {
                rect.Inflate(0, -18);
                gfx.DrawString("Date: " + DateTime.Now.ToString("yyyy-MM-dd"), p.Font14, XBrushes.Black, rect, XStringFormats.TopCenter);
            }            

            //Customer Logo
            filename = Path.Combine(p.ServerProperty.MapPath("~/Content/Images"), "olea.png");
            image = XImage.FromFile(filename);
            gfx.DrawImage(image, page.Width - 20 - 120, 20, 120, 50);


            //Footer
            rect = new XRect(20, page.Height - 20, page.Width - 40, 10);
            XStringFormat format = new XStringFormat();
            format.Alignment = XStringAlignment.Near;
            format.LineAlignment = XLineAlignment.Far;
            gfx.DrawString("Copyright: Paideia Solutions 2016", p.Font8Italic, XBrushes.Black, rect, format);


            format.Alignment = XStringAlignment.Far;
            gfx.DrawString(document.PageCount.ToString(), p.Font8Italic, XBrushes.Black, rect, format);

            //document.Outlines.Add(title, page, true);
        }
Пример #28
0
        void DrawPdfImage(XGraphics gfx, double W, double H)
        {
            string pdfSamplePath = @"C:\Users\Anil\Documents\Visual Studio 2013\Projects\GC_02\GC_02\Gas_CA.pdf";

            XImage image = XImage.FromFile(pdfSamplePath);

            gfx.DrawImage(image, 0, 0, W, H);
        }
        public static void Test(PdfSharp.Drawing.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(System.Drawing.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 * System.Math.Sqrt(2));

            gfx.DrawRectangle(XBrushes.Snow, rcImage);
            gfx.DrawImage(XPdfForm.FromFile("../../../../../PDFs/SomeLayout.pdf"), rcImage);
            gfx.Restore(state);
        }
Пример #30
0
 static void DrawImage(XGraphics gfx, string jpegSameplePath, int x, int y, int width, int height)
 {
     XImage image = XImage.FromFile(jpegSameplePath);
     gfx.DrawImage(image, x, y, width, height);
 }
Пример #31
0
        public static void DrawImageAlpha(XGraphics graphics, float alpha, ImageHolder holder, Rectangle targetRect)
        {
            if (alpha <= 0f)
                return;

            // Clamp and Quantize
            alpha = Math.Min(1f, alpha);
            alpha = (float)Math.Round(alpha * 16f) / 16f;
            int key = (int)Math.Round(alpha * 16);

            Image image = holder.Image;
            XImage ximage;

            int w = image.Width, h = image.Height;

            lock (holder)
            {
                if (image.Tag == null || !(image.Tag is Dictionary<int, XImage>))
                    image.Tag = new Dictionary<int, XImage>();

                Dictionary<int, XImage> dict = image.Tag as Dictionary<int, XImage>;
                if (dict.ContainsKey(key))
                {
                    ximage = dict[key];
                }
                else
                {
                    if (alpha >= 1f)
                    {
                        ximage = XImage.FromGdiPlusImage(image);
                    }
                    else
                    {
                        // Need to construct a new image (PdfSharp can't alpha-render images)
                        // Memoize these in the image itself, since most requests will be from
                        // a small set

                        Bitmap scratchBitmap = new Bitmap(w, h, PixelFormat.Format32bppArgb);
                        using (var scratchGraphics = Graphics.FromImage(scratchBitmap))
                        {
                            ColorMatrix matrix = new ColorMatrix();
                            matrix.Matrix00 = matrix.Matrix11 = matrix.Matrix22 = 1;
                            matrix.Matrix33 = alpha;

                            ImageAttributes attr = new ImageAttributes();
                            attr.SetColorMatrix(matrix);

                            scratchGraphics.DrawImage(image, new Rectangle(0, 0, w, h), 0, 0, w, h, GraphicsUnit.Pixel, attr);
                        }

                        ximage = XImage.FromGdiPlusImage(scratchBitmap);
                    }
                    dict[key] = ximage;
                }
            }

            lock (ximage)
            {
                graphics.DrawImage(ximage, targetRect, new XRect(0, 0, w, h), XGraphicsUnit.Point);
            }
        }
Пример #32
0
        private static void DrawPNG(XGraphics gfx, int number, string filename)
        {
            XImage image = default(XImage);
            image = XImage.FromFile(filename);

            const double dx = 250;
            const double dy = 140;
            double width = image.PixelWidth * 72 / image.HorizontalResolution;
            double height = image.PixelHeight * 72 / image.HorizontalResolution;

            gfx.DrawImage(image, (dx - width) / 2, (dy - height) / 2, width, height);
        }
Пример #33
0
        private static void PrepareInvoiceTop(XGraphics formGfx, XGraphicsState state, string InvoiceNumber)
        {
            string Headline = "Service Invoice " + InvoiceNumber + "";
            string MyName = TimeConnector.Data.Variables.SelectedContractor["CmpName"];
            string Phone = TimeConnector.Data.Variables.SelectedContractorContact["ConPhone"];
            string MyPhone = "Phone (" + Phone.Substring(0, 3) + ") " + Phone.Substring(4, 3) + "-" + Phone.Substring(7, 4) + "";
            string MyEmail = "Email: " + TimeConnector.Data.Variables.SelectedContractorContact["ConEmail"] + "";
            string MyAddress = TimeConnector.Data.Variables.SelectedContractor["CmpAddress"];
            string MyCityStateZip = "" + TimeConnector.Data.Variables.SelectedContractor["CmpCity"] + ", " + TimeConnector.Data.Variables.SelectedContractor["CmpState"] + "  " + TimeConnector.Data.Variables.SelectedContractor["CmpZip"] + "";
            string WeekEnding = TimeConnector.Data.Variables.SelectedPaydate["WeekEnd"];
            string PayDate = TimeConnector.Data.Variables.SelectedPaydate["PayDate"];
            string CompanyName = TimeConnector.Data.Variables.SelectedCompany["CmpName"];
            string CompanyContact = "c/o " + TimeConnector.Data.Variables.SelectedContact["ConName"] + "";
            string CompanyContactPhone = "" + TimeConnector.Data.Variables.SelectedContact["ConPhone"] + "";
            string CompanyContactEmail = "" + TimeConnector.Data.Variables.SelectedContact["ConEmail"] + "";
            string CompanyAddress = TimeConnector.Data.Variables.SelectedCompany["CmpAddress"];
            string CompanyCityStateZip = "" + TimeConnector.Data.Variables.SelectedCompany["CmpCity"] + ", " + TimeConnector.Data.Variables.SelectedCompany["CmpState"] + "  " + TimeConnector.Data.Variables.SelectedCompany["CmpZip"] + "";

            //----- Invoice Header
            XFont HeaderFont = new XFont("Imprint MT Shadow", 30, XFontStyle.Bold);
            string HeaderText = "I N V O I C E";
            XStringFormat format = new XStringFormat();
            format.Alignment = XStringAlignment.Near;
            format.LineAlignment = XLineAlignment.Near;
            XColor color = default(XColor);
            color = XColor.FromName("SteelBlue");
            color.A = 0.5;
            XBrush brush = default(XBrush);
            brush = new XSolidBrush(color);
            XPoint point = new XPoint(410, 20);
            formGfx.DrawString(HeaderText, HeaderFont, brush, point, format);

            //..... My Company Icon
            state = formGfx.Save();
            formGfx.DrawImage(XImage.FromFile("Images\\logo.png"), 20, 20, 65, 65);
            formGfx.Restore(state);

            //..... My Company Information
            DrawText(MyName, formGfx, new XFont(PdfFontMyInfo, 15, XFontStyle.Bold), XBrushes.SteelBlue, 95, 20);
            DrawText(MyAddress, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 45);
            DrawText(MyCityStateZip, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 55);
            DrawText(MyPhone, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 65);
            DrawText(MyEmail, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 75);

            XPen pen1 = new XPen(XColors.Maroon);
            pen1.Width = 1;
            //Dim pen2 As New XPen(XColors.Maroon)
            XPen pen2 = new XPen(XColors.SteelBlue);
            pen2.Width = 2;
            //Dim pen3 As New XPen(XColors.SteelBlue)
            XPen pen3 = new XPen(XColors.Maroon);
            pen3.Width = 1;
            formGfx.DrawBeziers(pen1, XPoint.ParsePoints("20,95 80,140 190,70 250,110"));

            DrawSignature(formGfx, 531, 696, "LightGray", 1);
            DrawSignature(formGfx, 530, 695, "Black", 1.5);
            DrawSignature(formGfx, 530, 695, "SteelBlue", 1);

            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("300,100 310,110 340,90 350,100"))  'Top
            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("312,108 322,118 332,99 342,110")) 'Top Center
            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("314,118 324,128 334,109 344,120")) 'Bottom Center
            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("310,130 315,140 330,120 335,130")) 'Bottom
            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("325,100 335,110 325,120 335,130")) 'Center

            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("300,100 310,110 340,90 350,100"))  'Top
            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("312,108 322,118 332,99 342,110")) 'Top Center
            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("314,118 324,128 334,109 344,120")) 'Bottom Center
            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("310,130 315,140 330,120 335,130")) 'Bottom
            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("325,100 335,110 325,120 335,130")) 'Center

            //..... ACS Company Icon
            DrawText("B I L L   T O :", formGfx, new XFont(PdfFont, 9, XFontStyle.Bold), XBrushes.Black, 60, 95);
            state = formGfx.Save();
            formGfx.DrawImage(XImage.FromFile("Images\\ACSIcon.jpg"), 20, 115, 65, 65);
            formGfx.Restore(state);

            //..... ACS Company Information
            DrawText(CompanyName, formGfx, new XFont(PdfFontMyInfo, 15, XFontStyle.Bold), XBrushes.Green, 95, 115);
            DrawText(CompanyContact, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 135);
            DrawText(CompanyAddress, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 145);
            DrawText(CompanyCityStateZip, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 155);
            DrawText(CompanyContactPhone, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 165);
            DrawText(CompanyContactEmail, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 175);

            //..... Invoice Information
            DrawLine(formGfx, 450, 590, 80, "SteelBlue", 0.5);
            DrawText("Invoice #:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 71);
            DrawText(InvoiceNumber, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Maroon, 530, 71);
            DrawLine(formGfx, 450, 590, 90, "SteelBlue", 0.5);
            DrawText("Week Ending:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 81);
            DrawText(WeekEnding, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 81);
            DrawLine(formGfx, 450, 590, 100, "SteelBlue", 0.5);
            DrawText("Pay Date:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 91);
            DrawText(PayDate, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 91);
            DrawLine(formGfx, 450, 590, 110, "SteelBlue", 0.5);
            DrawText("Hours Worked:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 101);
            DrawText(TimeConnector.Data.Invoice.FinHour, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 101);
            DrawLine(formGfx, 450, 590, 120, "SteelBlue", 0.5);
            DrawText("Balance Due:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 111);
            DrawText(TimeConnector.Data.Invoice.FinCost, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 111);
        }
Пример #34
-1
    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);
    }