protected void Page_Load(object sender, EventArgs e) { try { // Apenas para achar o posicionamento do conteudo padrão: Banco/Vencimento/Valor 44 - 25 = 19 posiçoes iniciais // ------------------------1234567890123456789_______CAMPO_LIVRE_______ // ------------------------_BANCO_VENC_VALOR__1234567890123456789012345 string cCodBarrasCoreto = "03392642100000001009717792500000019720301101"; // Comparativo...........: 03392642100000001009717792500000019720301101 logOut.InnerText = "iniciando\r\n"; // Usa uma rotina pré existente para montar só o campo livre string cCampoLivre = Banco_Banespa.CampoLivre(new Boleto(), "97177925000", "1972030"); CampoLivre.Text = cCampoLivre; // Se a ideia é validar o campo livre pose-se pegar direto o inicio da código de barras direto sem o digito verificador string cCodBarras = cCodBarrasCoreto.Substring(0, 4) + cCodBarrasCoreto.Substring(5, 14) + cCampoLivre; //cCodBarrasCoreto.Substring(19, 25); string cDV = CobUtil.Modulo11Padrao(cCodBarras, 9).ToString(); // Só a Caixa calcula direfente! cCodBarras = cCodBarras.Substring(0, 4) + cDV + cCodBarras.Substring(4); // Exibe o Código de barras CodigoBarras.Text = CobUtil.CodigoBarrasFormatado(cCodBarras, new int[] { 25 }); // Veja o Exemplo: BoletoCustomizado.aspx LinhaDigitavel.Text = CobUtil.CalcLinDigitavel(cCodBarras); // Gera o Código de barras no padrão: pf, pl, bf, bl (preto fino, preto largo, branco fino branco largo) Barras.Text = CobUtil.BarCode(cCodBarras) .Replace("bf", "<img src='imagens/b.gif' width=1 height=50>") .Replace("bl", "<img src='imagens/b.gif' width=3 height=50>") .Replace("pf", "<img src='imagens/p.gif' width=1 height=50>") .Replace("pl", "<img src='imagens/p.gif' width=3 height=50>"); } catch (Exception ex) { logOut.InnerText += "\r\n<b>" + ex.Message + "</b>\r\n" + ex.StackTrace; } }
// Copiado diretamente public static Bitmap BarCodeImage(string NumTexto, int nScale, float resolucao = 600f) { // Transforma o numero em uma string padrão de barras string cCodBar = CobUtil.BarCode(NumTexto); if (nScale < 3) { throw new Exception("Escala minima é 3"); } // Ajusta a Escala padrão //nScale /= 3; // Atenção, o ideal para a escala é ser multiplo de 3 int wSF = nScale / 3; int wSL = nScale; // Codigo de Barras 2 por 5 => 2 digitos são representados por 5 Barras PBPBP largas ou finas int nWidth = NumTexto.Length * 4 * nScale; Bitmap bmp = new Bitmap(nWidth, 50); bmp.SetResolution(resolucao, resolucao); Graphics g = Graphics.FromImage(bmp); g.Clear(Color.White); // Posição da linha atualmente desenhada (cursor) int nX = 0; for (int n = 0; n < cCodBar.Length; n += 2) { switch (cCodBar.Substring(n, 2)) { case "bf": g.FillRectangle(Brushes.White, nX, 0, wSF, 50); nX += wSF; break; case "pf": g.FillRectangle(Brushes.Black, nX, 0, wSF, 50); nX += wSF; break; case "bl": g.FillRectangle(Brushes.White, nX, 0, wSL, 50); nX += wSL; break; case "pl": g.FillRectangle(Brushes.Black, nX, 0, wSL, 50); nX += wSL; break; } } // Extrai apenas a imagem 100% util Bitmap bmp2 = new Bitmap(nX, 50); bmp2.SetResolution(resolucao, resolucao); g = Graphics.FromImage(bmp2); g.DrawImage(bmp, 0, 0); return(bmp2); }
protected override void Render(HtmlTextWriter output) { if (RenderCountImage > 0) { output.Write("<center><div style='width: 650px;'>"); Bitmap img = Boleto.ImageBoleto(); Graphics g; if (RenderCountImage == 1) { output.Write(CobUtil.ToBase64ImageTag(img, ImageFormat.Png)); } else { Bitmap img1 = new Bitmap(img.Width / 2, img.Height); g = Graphics.FromImage(img1); g.DrawImage(img, 0, 0); output.Write(CobUtil.ToBase64ImageTag(img1, ImageFormat.Png)); Bitmap img2 = new Bitmap(img.Width / 2, img.Height); g = Graphics.FromImage(img2); g.DrawImage(img, 0, 0, new Rectangle(img.Width / 2, 0, img.Width / 2, img.Height), GraphicsUnit.Pixel); output.Write(CobUtil.ToBase64ImageTag(img2, ImageFormat.Png)); } output.Write("</div></center>"); return; } if (this.CssField == null) { this.CssField = ""; } if (this.CssCell == null) { this.CssCell = ""; } // blt.CalculaBoleto(); string cLinhaDigitavel = blt.LinhaDigitavel; string cBarras = CobUtil.BarCode(blt.CodigoBarras); // compatibilidade XHTML output.WriteLine("<div class='BoletoWeb'>"); TableRow row; TableCell cell; #region "Linha digitavel" Table tbLinha = new Table(); tbLinha.CellPadding = 0; tbLinha.CellSpacing = 0; tbLinha.Width = new Unit("640"); row = new TableRow(); cell = new TableCell(); if (imageLogo == "") { cell.Text = String.Format("<img src='{0}' style='width:149px;height:38px;margin:1px'/>", GetImage(ImageGetType.Banco)); } else { cell.Text = String.Format("<img src='{0}{1}' class='BoletoWebLogo' />", this.ImagePath, this.imageLogo); } cell.ColumnSpan = 3; row.Cells.Add(cell); cell = new TableCell(); cell.Text = String.Format("<img src='{0}' width='2' height='30' align='right' />", GetImage(ImageGetType.p)); cell.VerticalAlign = VerticalAlign.Bottom; row.Cells.Add(cell); cell = new TableCell(); cell.HorizontalAlign = HorizontalAlign.Center; cell.VerticalAlign = VerticalAlign.Bottom; cell.Style.Add("padding-bottom", "5px;"); cell.Style.Add("font-size", "7pt"); cell.Style.Add("font-family", "Verdana,Arial"); cell.Text = "Banco<br/><font style='font-size: 11pt; font-weight: bold; font-family: Arial;'>" + blt.BancoCodigo + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.VerticalAlign = VerticalAlign.Bottom; cell.Text = String.Format("<img src='{0}' width='2' height='30' />", GetImage(ImageGetType.p)); cell.Width = new Unit("2px"); row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = this.CssField; cell.HorizontalAlign = HorizontalAlign.Right; cell.VerticalAlign = VerticalAlign.Bottom; cell.Style.Add("padding-bottom", "5px;"); cell.Wrap = false; cell.Width = new Unit("400"); cell.ColumnSpan = 8; row.Cells.Add(cell); tbLinha.Rows.Add(row); if (blt.ExibeReciboLinhaDigitavel) { tbLinha.Rows[0].Cells[4].Text = BoletoTextos.Recibo + "<br/><font style='font-size: 11pt; font-weight: bold; font-family: Arial;'>" + cLinhaDigitavel + "</font>"; } else { tbLinha.Rows[0].Cells[4].Text = BoletoTextos.Recibo; } #endregion // Recibo do Sacado #region "Boleto parte 1" if (blt.ExibeReciboSacado) { tbLinha.RenderControl(output); Table tbBol1 = new Table(); tbBol1.Width = new Unit("640"); if (ConfigureTable == null) { tbBol1.BorderWidth = new Unit("1"); tbBol1.BorderStyle = BorderStyle.Solid; tbBol1.GridLines = GridLines.Both; tbBol1.BorderColor = Color.Black; tbBol1.CellPadding = 1; tbBol1.CellSpacing = 0; } else { ConfigureTable(tbBol1); } #if NET2 || NET4 tbBol1.Attributes.Add("bordercolordark", "#000000"); tbBol1.Attributes.Add("bordercolorlight", "#000000"); #endif // Linha 1 row = new TableRow(); cell = new TableCell(); cell.ColumnSpan = 4; cell.Width = new Unit("350");; cell.CssClass = CssCell; cell.Text = BoletoTextos.Cedente + ":<br/>" + "<font class=" + CssField + "> " + blt.Cedente + (" - " + blt.CedenteDocumento) + ("</font><br/><font class=" + CssCell + ">Endereço: </font><font class=" + CssField + ">" + blt.CedenteEndereco) + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.Width = new Unit("160");; cell.Wrap = false; cell.CssClass = CssCell; cell.Text = BoletoTextos.CedenteConta + "<br/>" + "<div align=center class=" + CssField + "> " + blt.AgenciaConta + "</div>"; row.Cells.Add(cell); cell = new TableCell(); cell.Width = new Unit("130"); cell.CssClass = CssCell; cell.BackColor = _CellEspecialColor; cell.Text = "Vencimento<br>" + "<div align='right' class='" + CssField + "'"; if (_CellEspecialSize > 0) { cell.Text += "style='font-size:" + _CellEspecialSize.ToString() + "pt;'"; } cell.Text += string.Format(">{0:dd/MM/yyyy}", blt.DataVencimento) + "</div>"; row.Cells.Add(cell); tbBol1.Rows.Add(row); // Linha 2 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.ColumnSpan = 4; if (ExibeEnderecoReciboSacado) { cell.Text = BoletoTextos.Sacado + "<br/>" + "<font class=" + CssField + ">" + blt.SacadoCOD + (blt.SacadoCOD == "" ? "" : ": ") + blt.Sacado + " " + blt.SacadoDocumento + "<br>" + blt.SacadoEndereco + "<br>" + blt.Bairro + " - " + blt.Cidade + "<br>" + "CEP: " + blt.Cep + " - " + blt.UF + "</font>"; } else { cell.Text = BoletoTextos.Sacado + "<br/>" + "<font class=" + CssField + "> " + blt.Sacado + "</font>"; } row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "Nº Documento<br/>" + "<div align=center class=" + CssField + ">" + blt.NumeroDocumento + "</div>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Wrap = false; cell.Text = "Nosso Número<br/>" + "<div align=right class=" + CssField + ">" + blt.NossoNumeroExibicao + "</div>"; row.Cells.Add(cell); tbBol1.Rows.Add(row); // Linha 3 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.BackColor = _CellEspecialColor; cell.Text = "Espécie Moeda<br>" + "<font class=" + CssField + "> " + blt.MoedaEspecie + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "Parcela<br>" + "<div align=center class=" + CssField + "> " + ((blt.ParcelaNumero == 0) ? "" : blt.ParcelaNumero.ToString() + ((blt.ParcelaTotal == 0) ? "" : " / " + blt.ParcelaTotal.ToString())) + "</div>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "Qtde Moeda<br>" + "<div align=center class=" + CssField + "> " + ((blt.Quantidade == 0) ? "" : blt.Quantidade.ToString()) + "</div>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(x)Valor<br>" + "<div align=right class=" + CssField + "> " + ((blt.ValorUnitario == 0) ? "" : String.Format("{0:C}", blt.ValorUnitario)) + "</div>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(-)Descontos/Abatim.<br>" + "<div align=right class=" + CssField + "> " + ((blt.ValorDesconto == 0) ? "" : String.Format("{0:C}", blt.ValorDesconto)) + "</div>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.BackColor = _CellEspecialColor; cell.Text = "(=)Valor Documento<br>" + "<div align=right class=" + CssField + "> " + String.Format("{0:C}", blt.ValorDocumento) + "</div>"; row.Cells.Add(cell); tbBol1.Rows.Add(row); // Linha 5 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.VerticalAlign = VerticalAlign.Bottom; cell.ColumnSpan = 4; cell.Text = "Demonstrativo"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(+)Outros Acréscimos<br>" + "<div align=right class=" + CssField + "> " + ((blt.ValorAcrescimo == 0) ? "" : String.Format("{0:C}", blt.ValorAcrescimo)) + "</div>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(=)Valor Cobrado<br>" + "<div align=right class=" + CssField + "> " + ((blt.ValorCobrado == 0) ? "" : String.Format("{0:C}", blt.ValorCobrado)) + "</div>"; row.Cells.Add(cell); tbBol1.Rows.Add(row); // Linha 6 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.VerticalAlign = VerticalAlign.Top; if (string.IsNullOrEmpty(blt.Demonstrativo)) { cell.Height = new Unit("20"); } if (string.IsNullOrEmpty(blt.Demonstrativo)) { cell.Height = new Unit("50"); } cell.ColumnSpan = 6; if (blt.Demonstrativo != null) { cell.Text = "<div class=" + CssField + ">" + blt.Demonstrativo.Replace("\r\n", "<br/>") + "</div>"; } row.Cells.Add(cell); tbBol1.Rows.Add(row); if (!string.IsNullOrEmpty(blt.Informacoes)) { row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.VerticalAlign = VerticalAlign.Top; cell.Height = new Unit("50"); cell.ColumnSpan = 6; if (blt.Demonstrativo != null) { cell.Text = "<div class=" + CssField + " align='center'>" + blt.Informacoes.Replace("\r\n", "<br>") + "</div>"; } row.Cells.Add(cell); tbBol1.Rows.Add(row); } tbBol1.RenderControl(output); if (this.ImageCorte != "") { output.Write("<img src='" + this.ImagePath + this.ImageCorte + "' class='BoletoWebCorte'>"); } else { output.Write("<img src='" + GetImage(ImageGetType.corte) + "' class='BoletoWebCorte'>"); } output.Write("<br><br>"); } #endregion tbLinha.Rows[0].Cells[0].Text = String.Format("<img src='{0}' style='width:149px;height:38px;margin:1px'/>", GetImage(ImageGetType.Banco)); tbLinha.Rows[0].Cells[4].Text = "<font style='font-size: 11pt; font-weight: bold; font-family: Arial;'>" + cLinhaDigitavel + "</font>"; tbLinha.RenderControl(output); // Boleto Padrão IPTE #region "Boleto Parte 2" Table tbBol2 = new Table(); tbBol2.Width = new Unit("640"); if (ConfigureTable == null) { tbBol2.BorderWidth = new Unit("1"); tbBol2.BorderStyle = BorderStyle.Solid; tbBol2.GridLines = GridLines.Both; tbBol2.BorderColor = Color.Black; #if NET2 || NET4 tbBol2.Attributes.Add("bordercolordark", "#000000"); tbBol2.Attributes.Add("bordercolorlight", "#000000"); #endif tbBol2.CellPadding = 1; tbBol2.CellSpacing = 0; } else { ConfigureTable(tbBol2); } // Linha 1 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.Width = new Unit("480"); cell.ColumnSpan = 6; cell.Text = "Local de pagamento<br>" + "<font class=" + CssField + "> " + blt.LocalPagamento + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Width = new Unit("130"); cell.BackColor = _CellEspecialColor; cell.Text = "Vencimento<br>" + "<div align='right' class='" + CssField + "'"; if (_CellEspecialSize > 0) { cell.Text += "style='font-size:" + _CellEspecialSize.ToString() + "pt;'"; } cell.Text += string.Format(">{0:dd/MM/yyyy}", blt.DataVencimento) + "</div>"; row.Cells.Add(cell); tbBol2.Rows.Add(row); // Linha 2 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.ColumnSpan = 6; cell.Text = BoletoTextos.Cedente + ":<br/>" + "<font class=" + CssField + "> " + blt.Cedente + (" - " + blt.CedenteDocumento) + ("</font><br/><font class=" + CssCell + ">Endereço: </font><font class=" + CssField + ">" + blt.CedenteEndereco) + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Wrap = false; cell.Text = BoletoTextos.CedenteConta + "<br/>" + "<div align=right class=" + CssField + ">" + blt.AgenciaConta + "</div>"; row.Cells.Add(cell); tbBol2.Rows.Add(row); // Linha 3 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.Width = new Unit("120"); cell.Text = "Data Documento<br>" + "<font class=" + CssField + "> " + string.Format("{0:dd/MM/yyyy}", blt.DataDocumento) + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Width = new Unit("120"); cell.ColumnSpan = 2; cell.Text = "Nº Documento<br>" + "<font class=" + CssField + "> " + blt.NumeroDocumento + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = BoletoTextos.EspecieDoc + "<br/>" + "<font class=" + CssField + "> " + Boleto.Especie + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "Aceite<br>" + "<font class=" + CssField + "> " + Boleto.Aceite + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Width = new Unit("110"); cell.Text = _TextoDataProcessamento + "<br>" + "<font class=" + CssField + "> " + string.Format("{0:dd/MM/yyyy}", blt.DataProcessamento) + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Wrap = false; cell.Text = "Nosso Número<br>" + "<div align=right class=" + CssField + ">" + blt.NossoNumeroExibicao + "</div>"; row.Cells.Add(cell); tbBol2.Rows.Add(row); // Linha 4 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; if (blt.CIP != "") // quando houve o campo { cell.Text = "Uso do Banco<br>" + "<font class=" + CssField + "> " + blt.UsoBanco + " CIP: " + blt.CIP + "</font>"; row.Cells.Add(cell); cell = new TableCell(); } else { cell = new TableCell(); cell.ColumnSpan = 2; } cell.CssClass = CssCell; cell.Text = "Carteira<br>" + "<font class=" + CssField + "> " + blt.CarteiraExibicao + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.BackColor = _CellEspecialColor; cell.Text = "Espécie<br>" + "<font class=" + CssField + "> " + blt.MoedaEspecie + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "Parcela<br>" + "<div align=center class=" + CssField + "> " + ((blt.ParcelaNumero == 0) ? "" : blt.ParcelaNumero.ToString() + ((blt.ParcelaTotal == 0) ? "" : " / " + blt.ParcelaTotal.ToString())) + "</div>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "Qtde Moeda<br>" + "<font class=" + CssField + "> " + ((blt.Quantidade == 0) ? "" : blt.Quantidade.ToString()) + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(x)Valor<br>" + "<font class=" + CssField + "> " + ((blt.ValorUnitario == 0) ? "" : String.Format("{0:C}", blt.ValorUnitario)) + "</font>"; row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.BackColor = _CellEspecialColor; cell.Text = "(=)Valor Documento<br>" + "<div align=right class=" + CssField + "> " + String.Format("{0:C}", blt.ValorDocumento) + "</div>"; row.Cells.Add(cell); tbBol2.Rows.Add(row); // Linha 5 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.ColumnSpan = 6; cell.RowSpan = 5; cell.VerticalAlign = VerticalAlign.Top; if (blt.Instrucoes != null) { cell.Text = BoletoTextos.Instrucoes + "<br/>" + "<font class=" + CssField + ">" + blt.Instrucoes.Replace("\r\n", "<br/>") + "</font>"; } row.Cells.Add(cell); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(-)Descontos/Abatim.<br>" + "<div align=right class=" + CssField + "> " + ((blt.ValorDesconto == 0) ? "" : String.Format("{0:C}", blt.ValorDesconto)) + "</div>"; row.Cells.Add(cell); tbBol2.Rows.Add(row); // Linha 6 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(-)Outras Deduções<br>" + "<div align=right class=" + CssField + "> " + ((blt.ValorOutras == 0) ? "" : String.Format("{0:C}", blt.ValorOutras)) + "</div>"; row.Cells.Add(cell); tbBol2.Rows.Add(row); // Linha 7 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(+)Mora/Multa<br>" + "<div align=right class=" + CssField + "> " + ((blt.ValorMoraMulta == 0) ? "" : String.Format("{0:C}", blt.ValorMoraMulta)) + "</div>"; row.Cells.Add(cell); tbBol2.Rows.Add(row); // Linha 8 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(+)Outros Acréscimos<br>" + "<div align=right class=" + CssField + "> " + ((blt.ValorAcrescimo == 0) ? "" : String.Format("{0:C}", blt.ValorAcrescimo)) + "</div>"; row.Cells.Add(cell); tbBol2.Rows.Add(row); // Linha 9 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.Text = "(=)Valor Cobrado<br>" + "<div align=right class=" + CssField + "> " + ((blt.ValorCobrado == 0) ? "" : String.Format("{0:C}", blt.ValorCobrado)) + "</div>"; row.Cells.Add(cell); tbBol2.Rows.Add(row); // Linha 9 row = new TableRow(); cell = new TableCell(); cell.CssClass = CssCell; cell.Height = new Unit("70"); cell.ColumnSpan = 7; cell.VerticalAlign = VerticalAlign.Top; if (blt.SacadoEndereco == "") { cell.Text = BoletoTextos.Sacado + "<br/>" + "<font class=" + CssField + ">" + blt.SacadoCOD + (blt.SacadoCOD == "" ? "" : ": ") + blt.Sacado + " " + blt.SacadoDocumento + "</font>"; } else { cell.Text = BoletoTextos.Sacado + "<br/>" + "<font class=" + CssField + ">" + blt.SacadoCOD + (blt.SacadoCOD == "" ? "" : ": ") + blt.Sacado + " " + blt.SacadoDocumento + "<br>" + blt.SacadoEndereco + "<br>" + blt.Bairro + " - " + blt.Cidade + "<br>" + "CEP: " + blt.Cep + " - " + blt.UF + "</font>"; } row.Cells.Add(cell); tbBol2.Rows.Add(row); tbBol2.RenderControl(output); #endregion // Código de Barras #region "Separador / Autenticação" Table tbFicha = new Table(); tbFicha.CellPadding = 0; tbFicha.CellSpacing = 0; tbFicha.Width = new Unit("640"); row = new TableRow(); cell = new TableCell(); cell.Text = (blt.Avalista == "") ? "" : (BoletoTextos.Avalista + ": ") + blt.Avalista; cell.CssClass = this.cssCell; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Autenticação Mecânica - FICHA DE COMPENSAÇÃO"; cell.CssClass = this.cssCell; cell.HorizontalAlign = HorizontalAlign.Right; row.Cells.Add(cell); tbFicha.Rows.Add(row); tbFicha.RenderControl(output); //output.Write("<table border=1 width='640'><tr><td class='" + this.CssCell + "'>" + // ((blt.Avalista == "") ? "" : (BoletoTextos.Avalista + ": ") + blt.Avalista) + // "</td><td align=right class=" + this.CssCell + ">"); //output.Write("Autenticação Mecânica - FICHA DE COMPENSAÇÃO</td></tr></table>"); //output.Write("<table border=1 width='640'><tr><td>"); #endregion #region "Código de barras" Table tbcodBar = new Table(); tbcodBar.CellPadding = 0; tbcodBar.CellSpacing = 0; tbcodBar.Width = new Unit("640"); row = new TableRow(); cell = new TableCell(); if (_BarCod == "") { StringBuilder sb = new StringBuilder(); string cP = GetImage(ImageGetType.p); string cB = GetImage(ImageGetType.b); for (int i = 0; i < cBarras.Length; i += 2) { switch (cBarras.Substring(i, 2)) { case "bf": if (imgCodBar) { sb.Append("<img src='" + cB + "' border='0' height='50' width='1' />"); } else { sb.Append("<div style='display:inline-block;height:50px;width:1px;background-color:fff;'></div>"); } break; case "pf": if (imgCodBar) { sb.Append("<img src='" + cP + "' border='0' height='50' width='1' />"); } else { sb.Append("<div style='display:inline-block;height:50px;width:1px;background-color:000;'></div>"); } break; case "bl": if (imgCodBar) { sb.Append("<img src='" + cB + "' border='0' height='50' width='3' />"); } else { sb.Append("<div style='display:inline-block;height:50px;width:3px;background-color:fff;'></div>"); } break; case "pl": if (imgCodBar) { sb.Append("<img src='" + cP + "' border='0' height='50' width='3' />"); } else { sb.Append("<div style='display:inline-block;height:50px;width:3px;background-color:000;'></div>"); } break; } } cell.Text = sb.ToString(); } else { cell.Text = string.Format("<img src='{0}' border='0' />", _BarCod); } row.Cells.Add(cell); tbcodBar.Rows.Add(row); if (!string.IsNullOrEmpty(blt.Informacoes)) { // output.Write("<tr><td align='center'>" + blt.Informacoes + "</td></tr>"); row = new TableRow(); cell = new TableCell(); cell.CssClass = CssField; cell.HorizontalAlign = HorizontalAlign.Center; cell.Text = blt.Informacoes; row.Cells.Add(cell); tbcodBar.Rows.Add(row); } //output.Write("</table>"); tbcodBar.RenderControl(output); #endregion output.WriteLine("</div>"); }