//////////////////////////////////////////////////////////////////// // Draw Happy Face //////////////////////////////////////////////////////////////////// private void DrawHappyFace( PdfContents Contents ) { // save graphics state Contents.SaveGraphicsState(); // translate coordinate origin to the center of the happy face Contents.Translate(4.25, 7.5); // change nonstroking (fill) color to yellow Contents.SetColorNonStroking(Color.Yellow); // draw happy face yellow oval Contents.DrawOval(-1.5, -1.0, 3.0, 2.0, PaintOp.Fill); // set line width to 0.2" this is the black circle around the eye Contents.SetLineWidth(0.2); // eye color is white with black outline circle Contents.SetColorNonStroking(Color.White); Contents.SetColorStroking(Color.Black); // draw eyes Contents.DrawOval(-0.75, 0.0, 0.5, 0.5, PaintOp.CloseFillStroke); Contents.DrawOval(0.25, 0.0, 0.5, 0.5, PaintOp.CloseFillStroke); // mouth color is black Contents.SetColorNonStroking(Color.Black); // draw mouth by creating a path made of one line and one Bezier curve Contents.MoveTo(-0.6, -0.4); Contents.LineTo(0.6, -0.4); Contents.DrawBezier(0.0, -0.8, 0, -0.8, -0.6, -0.4); // fill the path with black color Contents.SetPaintOp(PaintOp.Fill); // restore graphics sate Contents.RestoreGraphicsState(); return; }
public void vuelveAHacerElCheque(bool conImagen) { string path = Properties.Settings.Default.letra+ ":" + (object)Path.DirectorySeparatorChar + "cheques"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); if (File.Exists(FileName)) { try { File.Delete(FileName); } catch (IOException ex2) { System.Windows.Forms.MessageBox.Show(ex2.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } String fileImage = path + (object)Path.DirectorySeparatorChar + "cheque" + tipoDeBancoGlobal+".jpg"; Document = new PdfDocument(PaperType.sobreprima, false, UnitOfMeasure.Point, FileName); DefineFontResources(); DefineTilingPatternResource(); PdfPage Page = new PdfPage(Document); PdfContents Contents = new PdfContents(Page); Contents.SaveGraphicsState(); Contents.Translate(0.1, 0.1); const Double FontSize = 9.0; if(conImagen) { PdfImage Image = new PdfImage(Document, fileImage, 72.0, 50); Contents.SaveGraphicsState(); int top = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "topCheque" + tipoDeBancoGlobal)); int left = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "leftCheque" + tipoDeBancoGlobal)); int ancho = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "anchoCheque" + tipoDeBancoGlobal)); int largo = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "largoCheque" + tipoDeBancoGlobal)); Contents.DrawImage(Image, left, top, ancho, largo); Contents.RestoreGraphicsState(); } int fechaX = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "fechaX" + tipoDeBancoGlobal)); int fechaY = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "fechaY" + tipoDeBancoGlobal)); Contents.MoveTo(new PointD(fechaX, fechaY)); Contents.DrawText(ArialNormal, FontSize, fechaX, fechaY, fecha); Contents.RestoreGraphicsState(); Contents.SaveGraphicsState(); int nombreX = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "nombreX" + tipoDeBancoGlobal)); int nombreY = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "nombreY" + tipoDeBancoGlobal)); Contents.MoveTo(new PointD(nombreX, nombreY)); Contents.DrawText(ArialNormal, FontSize, nombreX, nombreY, nombre); Contents.RestoreGraphicsState(); Contents.SaveGraphicsState(); int cantidadX = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "cantidadX" + tipoDeBancoGlobal)); int cantidadY = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "cantidadY" + tipoDeBancoGlobal)); Contents.MoveTo(new PointD(cantidadX, cantidadY)); Contents.DrawText(ArialNormal, FontSize, cantidadX, cantidadY, total); Contents.RestoreGraphicsState(); Contents.SaveGraphicsState(); int letraX = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "letraX" + tipoDeBancoGlobal)); int letraY = Convert.ToInt32(DataBinder.Eval(Properties.Settings.Default, "letraY" + tipoDeBancoGlobal)); Contents.MoveTo(new PointD(letraX, letraY)); Contents.DrawText(ArialNormal, FontSize, letraX, letraY, numeroAletras); Contents.RestoreGraphicsState(); Contents.SaveGraphicsState(); Contents.RestoreGraphicsState(); Document.CreateFile(); String url = "file:" + (object)Path.DirectorySeparatorChar + (object)Path.DirectorySeparatorChar +FileName; // this.webBrowser1.Navigate(new Uri(url)); this.webView1.ZoomFactor = 1.0; this.webView1.Url = url; Properties.Settings.Default.Save(); }