PDF Mosaic: How to draw pies in PDF documents


Home       Features       Download       Tutorial       Version History       License       Source Code

 

This example shows how to draw pies and change the coordinate system of the canvas in PDF document.


 

using PDFMosaic;
using System.Drawing;
using System;
 
namespace PieAndTranslate
{
    class RectanglesAndTransparency
    {
        static void Main()
        {
            PDFDocument document = new PDFDocument();
            document.Pages.Add(new PDFPage(PDFPaperFormat.A4));
            PDFCanvas canvas = document.Pages[0].Canvas;
 
            PDFDeviceColor red = new PDFColorRGB(255, 0, 0);
            PDFDeviceColor green = new PDFColorRGB(0, 255, 0);
            PDFDeviceColor blue = new PDFColorRGB(0, 0, 255);
 
            PDFSolidBrush brush = new PDFSolidBrush(red);
            PDFSolidPen pen = new PDFSolidPen();
            pen.Width = 3;
 
            canvas.TranslateTransform(100, 200);
            canvas.DrawPie(brush, 0, 0, 50, 50, -90, 120);
            brush.Color = green;
            canvas.DrawPie(brush, 0, 0, 50, 50, 30, 120);
            brush.Color = blue;
            canvas.DrawPie(pen, brush, 0, 0, 50, 50, -90, -120);
 
            canvas.TranslateTransform(150, 0);
            canvas.ScaleTransform(1.5f, 1.5f);
            canvas.RotateTransform(90);
 
            brush.Color = red;
            canvas.DrawPie(brush, 0, 0, 50, 50, -90, 120);
            brush.Color = green;
            canvas.DrawPie(brush, 0, 0, 50, 50, 30, 120);
            brush.Color = blue;
            canvas.DrawPie(pen, brush, 0, 0, 50, 50, -90, -120);
 
            canvas.TranslateTransform(0, -150);
            canvas.ScaleTransform(1.5f, 1.5f);
            canvas.RotateTransform(45);
 
            brush.Color = red;
            canvas.DrawPie(brush, 0, 0, 50, 50, -90, 120);
            brush.Color = green;
            canvas.DrawPie(brush, 0, 0, 50, 50, 30, 120);
            brush.Color = blue;
            canvas.DrawPie(pen, brush, 0, 0, 50, 50, -90, -120);
 
            document.Save("PieAndTranslate.pdf", true);
        }
    }
}

 


Home       Features       Download       Tutorial       Version History       License       Source Code