Beispiel #1
0
        public static void CopyPath(CGPath cgpath)
        {
            var pdfpath = Path.GetTempPath() + ".pdf";
            var context = new CGContextPDF(NSUrl.FromFilename(pdfpath));

            CGRect rc = new CGRect(0, 0, 500, 500);

            context.BeginPage(rc);

            using (var gc = NSGraphicsContext.FromGraphicsPort(context, false))
            {
                var ctx = gc.CGContext;
                //ctx.SetStrokeColor(new CGColor(0, 0, 100));
                //ctx.SetLineWidth(2);
                //ctx.SetFillColor(new CGColor(100, 0, 0));

                ctx.AddPath(cgpath);
                ctx.DrawPath(CGPathDrawingMode.FillStroke);
            }

            context.EndPage();
            context.Close();

            var data = NSData.FromFile(pdfpath);

            NSPasteboard.GeneralPasteboard.ClearContents();
            NSPasteboard.GeneralPasteboard.SetDataForType(data, NSPasteboard.NSPdfType);
        }
 public void Context_Url_Rect_Info()
 {
     using (var url = new NSUrl(filename))
         using (var ctx = new CGContextPDF(url, new CGRect(0, 0, 1000, 1000), PDFInfoTest.GetInfo())) {
             ctx.AddDestination("monkey", CGPoint.Empty);
             ctx.Close();
         }
 }
Beispiel #3
0
        private void Close()
        {
            if (!_closed)
            {
                try
                {
                    if (_pageOpen)
                    {
                        _context.EndPage();
                    }

                    _context.Close();
                }
                catch (Exception exc)
                {
                    Logger.Warn(exc);
                }
                finally
                {
                    _closed = true;
                }
            }
        }