private void CreatePDF() { _c1pdf = new C1.C1Pdf.C1PdfDocument(); //start document _c1pdf.Clear(); TEMP_DIR = Server.MapPath("../Temp"); if (Directory.Exists(TEMP_DIR)) { } else { Directory.CreateDirectory(TEMP_DIR); } //prepare to draw with Gdi-like commands int penWidth = 0; int penRGB = 0; Rectangle rc = new Rectangle(50, 50, 300, 200); string text = "Hello world of .NET Graphics and PDF.\r\nNice to meet you."; Font font = new Font("Times New Roman", 16, FontStyle.Italic | FontStyle.Underline); //start, c1, c2, end1, c3, c4, end PointF[] bezierPoints = new PointF[] { new PointF(110f, 200f), new PointF(120f, 110f), new PointF(135f, 150f), new PointF(150f, 200f), new PointF(160f, 250f), new PointF(165f, 200f), new PointF(150f, 100f) }; //draw to pdf document C1.C1Pdf.C1PdfDocument g = _c1pdf; g.FillPie(Brushes.Red, rc, 0, 20f); g.FillPie(Brushes.Green, rc, 20f, 30f); g.FillPie(Brushes.Blue, rc, 60f, 12f); g.FillPie(Brushes.Gold, rc, -80f, -20f); for (float sa = 0; sa < 360; sa += 40) { Color penColor = Color.FromArgb(penRGB, penRGB, penRGB); Pen pen = new Pen(penColor, penWidth++); penRGB = penRGB + 20; g.DrawArc(pen, rc, sa, 40f); } g.DrawRectangle(Pens.Red, rc); g.DrawBeziers(Pens.Blue, bezierPoints); g.DrawString(text, font, Brushes.Black, rc); }
//============================================================================= // test arcs and pies private void button3_Click(object sender, System.EventArgs e) { _c1pdf.Clear(); _c1pdf.Compression = C1.C1Pdf.CompressionEnum.None; int penWidth = 0; int penRGB = 0; Rectangle rc = new Rectangle(0, 0, 300, 200); string text = "Hello world of .NET Graphics and PDF.\r\nNice to meet you."; Font font = new Font("Times New Roman", 12, FontStyle.Italic | FontStyle.Underline); // start, c1, c2, end1, c3, c4, end PointF[] bezierPoints = new PointF[] { new PointF(10f, 100f), new PointF(20f, 10f), new PointF(35f, 50f), new PointF(50f, 100f), new PointF(60f, 150f), new PointF(65f, 100f), new PointF(50f, 50f) }; // draw to .NET Graphics object Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); using (Graphics g = Graphics.FromImage(bmp)) { g.FillRectangle(Brushes.White, 0, 0, bmp.Width, bmp.Height); g.FillPie(Brushes.Red, rc, 0, 20f); g.FillPie(Brushes.Green, rc, 20f, 30f); g.FillPie(Brushes.Blue, rc, 60f, 12f); g.FillPie(Brushes.Gold, rc, -80f, -20f); for (float sa = 0; sa < 360; sa += 40) { Color penColor = Color.FromArgb(penRGB, penRGB, penRGB); Pen pen = new Pen(penColor, penWidth++); penRGB = penRGB + 20; g.DrawArc(pen, rc, sa, 40f); } g.DrawRectangle(Pens.Red, rc); g.DrawBeziers(Pens.Blue, bezierPoints); g.DrawString(text, font, Brushes.Black, rc); g.Dispose(); } this.pictureBox1.Image = bmp; this.pictureBox1.Refresh(); // draw to pdf document penWidth = 0; penRGB = 0; if (true) { C1.C1Pdf.C1PdfDocument g = _c1pdf; g.FillPie(Brushes.Red, rc, 0, 20f); g.FillPie(Brushes.Green, rc, 20f, 30f); g.FillPie(Brushes.Blue, rc, 60f, 12f); g.FillPie(Brushes.Gold, rc, -80f, -20f); for (float sa = 0; sa < 360; sa += 40) { Color penColor = Color.FromArgb(penRGB, penRGB, penRGB); Pen pen = new Pen(penColor, penWidth++); penRGB = penRGB + 20; g.DrawArc(pen, rc, sa, 40f); } g.DrawRectangle(Pens.Red, rc); g.DrawBeziers(Pens.Blue, bezierPoints); g.DrawString(text, font, Brushes.Black, rc); } // show pdf document SaveAndShow(@"c:\temp\test\arcpie.pdf"); }