예제 #1
0
        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;
        }