public DrawPath ( XBrush brush, XGraphicsPath path ) : void | ||
brush | XBrush | |
path | XGraphicsPath | |
return | void |
using PdfSharp.Drawing; // Create a new PDF document PdfDocument document = new PdfDocument(); // Add a new page to the document PdfPage page = document.AddPage(); // Get an XGraphics object for the page XGraphics gfx = XGraphics.FromPdfPage(page); // Create a new path XGraphicsPath path = new XGraphicsPath(); // Add a line to the path path.AddLine(new XPoint(0, 0), new XPoint(100, 100)); // Draw the path onto the PDF document gfx.DrawPath(new XPen(XColors.Black), path); // Save the document to a file document.Save("example.pdf");
using PdfSharp.Drawing; // Create a new PDF document PdfDocument document = new PdfDocument(); // Add a new page to the document PdfPage page = document.AddPage(); // Get an XGraphics object for the page XGraphics gfx = XGraphics.FromPdfPage(page); // Create a new path XGraphicsPath path = new XGraphicsPath(); // Add a rectangle to the path path.AddRectangle(new XRect(10, 10, 100, 50)); // Draw the path onto the PDF document using a brush gfx.DrawPath(new XSolidBrush(XColors.Red), path); // Save the document to a file document.Save("example2.pdf");In this example, we create a new PDF document, add a new page to it, get an XGraphics object for the page, create a new path, add a rectangle to the path, and then draw the path onto the PDF document using DrawPath and a solid brush. Overall, the PdfSharp.Drawing XGraphics DrawPath method provides a simple way to draw paths onto a PDF document using C#. It is part of the PdfSharp library.
public DrawPath ( XBrush brush, XGraphicsPath path ) : void | ||
brush | XBrush | |
path | XGraphicsPath | |
return | void |