private void button11_Click(object sender, System.EventArgs e) { // initialize C1.C1Pdf.C1PdfDocument pdf = new C1.C1Pdf.C1PdfDocument(); // create points PointF[] pts = new PointF[] { new PointF(50f, 100f), new PointF(100f, 10f), new PointF(250f, 50f), new PointF(400f, 100f), new PointF(500f, 150f), new PointF(550f, 250f), new PointF(400f, 300f) }; // draw Bezier spline pdf.DrawBeziers(new Pen(Color.Blue, 4), pts); // show points pdf.DrawLines(Pens.Gray, pts); for (int i = 0; i < pts.Length; i++) { Brush brush = (i % 3 == 0)? Brushes.Red: Brushes.Green; pdf.FillRectangle(brush, pts[i].X - 2, pts[i].Y - 2, 4, 4); } // save document string fileName = tempdir + "beziers.pdf"; pdf.Save(fileName); System.Diagnostics.Process.Start(fileName); }
private void GdiModel_Load(object sender, EventArgs e) { //start document _c1pdf.Clear(); //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); //save pdf file string filename = GetTempFileName(".pdf"); _c1pdf.Save(filename); //display it webBrowser1.Navigate(filename); }
private void button5_Click(object sender, System.EventArgs e) { // create pdf document C1.C1Pdf.C1PdfDocument g = new C1.C1Pdf.C1PdfDocument(); // set up to draw 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); PointF[] bezierpts = 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 pdf document int penWidth = 0; int penRGB = 0; 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 startAngle = 0; startAngle < 360; startAngle += 40) { Color penColor = Color.FromArgb(penRGB, penRGB, penRGB); Pen pen = new Pen(penColor, penWidth++); penRGB = penRGB + 20; g.DrawArc(pen, rc, startAngle, 40f); } g.DrawRectangle(Pens.Red, rc); g.DrawBeziers(Pens.Blue, bezierpts); g.DrawString(text, font, Brushes.Black, rc); // show it string fileName = tempdir + "graphics.pdf"; g.Save(fileName); System.Diagnostics.Process.Start(fileName); }