// The PrintPage event is raised for each page to be printed. private void pd_PrintPage(object sender, PrintPageEventArgs ev) { PrintTicketEgresosResponse[] printTicketEgresos = repository.getEgresosTicket(this.printTicketEgresosRequest); foreach (var r in printTicketEgresos) { PrintTicketEgresosResponse item = new PrintTicketEgresosResponse(); item.Texto = r.Texto; item.Formato = r.Formato; StringFormat format1 = new StringFormat(StringFormatFlags.NoClip); Font tmpFont = new Font(drawFont.Name, drawFont.Size); int FontSpace = 10; // Por default alineado a la izquierda format1.Alignment = StringAlignment.Far; string[] formatos = item.Formato.Split('|'); foreach (var f in formatos) { if (f == "center") { format1.Alignment = StringAlignment.Center; } else if (f.IndexOf("font") != -1) { tmpFont = new Font(f.Split(':')[1], Convert.ToInt32(f.Split(':')[2])); FontSpace = 5 + Convert.ToInt32(f.Split(':')[2]); } } pos.X = startX; pos.Y = startY + Offset; ev.Graphics.DrawString(item.Texto, tmpFont, drawBrush, pos, format1); Offset = Offset + FontSpace; } ev.HasMorePages = false; }
/// <summary> /// Extrae la informacion de la lectura X y Z /// </summary> /// <param name="printTicketEgresosRequest"></param> public PrintTicketEgresosResponse[] getEgresosTicket(PrintTicketEgresosRequest printTicketEgresosRequest) { List <PrintTicketEgresosResponse> printTicketEgresosResponsList = new List <PrintTicketEgresosResponse>(); var parameters = new Dictionary <string, object>(); if (string.IsNullOrEmpty(printTicketEgresosRequest.FolioCorteZ)) { printTicketEgresosRequest.FolioCorteZ = ""; } else { printTicketEgresosRequest.FolioRetiro = ""; } parameters.Add("@FolioRetiro", printTicketEgresosRequest.FolioRetiro); parameters.Add("@FolioCorteZ", printTicketEgresosRequest.FolioCorteZ); foreach (var c in data.GetDataReader("dbo.sp_vanti_DatosTicketEgresosParciales", parameters)) { PrintTicketEgresosResponse printTicketEgresos = new PrintTicketEgresosResponse(); printTicketEgresos.Texto = c.GetValue(1).ToString(); printTicketEgresos.Formato = c.GetValue(0).ToString(); printTicketEgresosResponsList.Add(printTicketEgresos); } return(printTicketEgresosResponsList.ToArray()); }