public void DrawRect() { Ensure(); context.SetFillColor(Color.CGColor); context.FillRect(Bounds); }
protected override void AddPageImpl(float width, float height) { if (_closed) { throw new Exception("Unable to add a page because the PDFContext is already closed."); } if (_data == null) { _data = new NSMutableData(); var consumer = new CGDataConsumer(_data); _context = new CGContextPDF(consumer, CGRect.Empty, null); _context.SetFillColorSpace(CGColorSpace.CreateDeviceRGB()); _context.SetStrokeColorSpace(CGColorSpace.CreateDeviceRGB()); } if (_pageOpen) { _context.EndPage(); } _context.BeginPage(new CGRect(0, 0, width, height)); _context.TranslateCTM(0, height); _context.ScaleCTM(1, -1); _context.SetLineWidth(1); _context.SetFillColor(new CGColor(1, 1)); _context.SetStrokeColor(new CGColor(0, 1)); _pageOpen = true; _canvas.Context = _context; }
static void Main () { NSApplication.Init (); NSUrl path = NSUrl.FromFilename (Path.Combine ("../../..", "demo.pdf")); //Escape out of generate-pdf.app/Contents/Resources var pdf = new CGContextPDF (path, new RectangleF (0, 0, 617, 792)); pdf.BeginPage (null); pdf.SetFillColor (1, 0, 0, 1); pdf.AddArc (300, 300, 100, 0, (float) (2 * Math.PI), true); pdf.FillPath (); pdf.EndPage (); pdf.Flush (); }
static void Main() { NSApplication.Init(); NSUrl path = NSUrl.FromFilename(Path.Combine("../../..", "demo.pdf")); //Escape out of generate-pdf.app/Contents/Resources var pdf = new CGContextPDF(path, new RectangleF(0, 0, 617, 792)); pdf.BeginPage(null); pdf.SetFillColor(1, 0, 0, 1); pdf.AddArc(300, 300, 100, 0, (float)(2 * Math.PI), true); pdf.FillPath(); pdf.EndPage(); pdf.Flush(); }