protected string MontaHtml(string urlImagemLogo, string urlImagemBarra, string imagemCodigoBarras) { var html = new StringBuilder(); var parametrosBoleto = new BoletoBancario.BoletoRenderParams(this, urlImagemLogo, urlImagemBarra, imagemCodigoBarras); //Oculta o cabeçalho das instruções do boleto if (!Boleto.Opcoes.OcultarInstrucoes) html.Append(GeraHtmlInstrucoes()); if (this.Boleto.Opcoes.ExibirDemonstrativo && this.Boleto.Demonstrativos.Any()) { html.Append(Html.ReciboCedenteRelatorioValores); html.Append(Html.ReciboCedenteParte5); html.Append(Html.CabecalhoTabelaDemonstrativo); var grupoDemonstrativo = new StringBuilder(); foreach (var relatorio in this.Boleto.Demonstrativos) { var first = true; foreach (var item in relatorio.Itens) { grupoDemonstrativo.Append(Html.GrupoDemonstrativo); if (first) { grupoDemonstrativo = grupoDemonstrativo.Replace("@DESCRICAOGRUPO", relatorio.Descricao); first = false; } else { grupoDemonstrativo = grupoDemonstrativo.Replace("@DESCRICAOGRUPO", string.Empty); } grupoDemonstrativo = grupoDemonstrativo.Replace("@DESCRICAOITEM", item.Descricao); grupoDemonstrativo = grupoDemonstrativo.Replace("@REFERENCIAITEM", item.Referencia); grupoDemonstrativo = grupoDemonstrativo.Replace("@VALORITEM", item.Valor.ToString("R$ ##,##0.00")); } grupoDemonstrativo.Append(Html.TotalDemonstrativo); grupoDemonstrativo = grupoDemonstrativo.Replace( "@VALORTOTALGRUPO", relatorio.Itens.Sum(c => c.Valor).ToString("R$ ##,##0.00")); } html = html.Replace("@ITENSDEMONSTRATIVO", grupoDemonstrativo.ToString()); } if (Boleto.Opcoes.Formato != FormatoBoleto.Carne) { //Mostra o comprovante de entrega if (Boleto.Opcoes.MostrarComprovanteEntrega | Boleto.Opcoes.MostrarComprovanteEntregaLivre) { html.Append(HtmlComprovanteEntrega); //Html da linha pontilhada if (Boleto.Opcoes.OcultarReciboSacado) html.Append(Html.ReciboSacadoParte8); } //Oculta o recibo do sacabo do boleto if (!Boleto.Opcoes.OcultarReciboSacado) { html.Append(GeraHtmlReciboSacado()); //Caso mostre o Endereço do Cedente if (parametrosBoleto.MostrarEnderecoCedente) { if (Cedente.Endereco == null) throw new ArgumentNullException("Endereço do Cedente"); string numero = !String.IsNullOrEmpty(Cedente.Endereco.Numero) ? Cedente.Endereco.Numero + ", " : ""; parametrosBoleto.EnderecoCedente = string.Concat(Cedente.Endereco.End, " , ", numero); if (Cedente.Endereco.CEP == String.Empty) { parametrosBoleto.EnderecoCedente += string.Format("{0} - {1}/{2}", Cedente.Endereco.Bairro, Cedente.Endereco.Cidade, Cedente.Endereco.UF); } else { parametrosBoleto.EnderecoCedente += string.Format("{0} - {1}/{2} - CEP: {3}", Cedente.Endereco.Bairro, Cedente.Endereco.Cidade, Cedente.Endereco.UF, Utils.FormataCEP(Cedente.Endereco.CEP)); } } } } if (Boleto.Opcoes.Formato != FormatoBoleto.Carne) html.Append(GerarHtmlReciboCedente()); else { html.Append(GeraHtmlCarne("", GerarHtmlReciboCedente())); } if (String.IsNullOrEmpty(Boleto.Cedente.Logo)) parametrosBoleto.LocalLogoCliente = parametrosBoleto.UrlImagemLogo; return Boleto.Banco.RenderizaBoleto(html, parametrosBoleto).ToString(); }
protected string MontaHtml(string urlImagemLogo, string urlImagemBarra, string imagemCodigoBarras) { var html = new StringBuilder(); var parametrosBoleto = new BoletoBancario.BoletoRenderParams(this, urlImagemLogo, urlImagemBarra, imagemCodigoBarras); //Oculta o cabeçalho das instruções do boleto if (!Boleto.Opcoes.OcultarInstrucoes) { html.Append(GeraHtmlInstrucoes()); } if (this.Boleto.Opcoes.ExibirDemonstrativo && this.Boleto.Demonstrativos.Any()) { html.Append(Html.ReciboCedenteRelatorioValores); html.Append(Html.ReciboCedenteParte5); html.Append(Html.CabecalhoTabelaDemonstrativo); var grupoDemonstrativo = new StringBuilder(); foreach (var relatorio in this.Boleto.Demonstrativos) { var first = true; foreach (var item in relatorio.Itens) { grupoDemonstrativo.Append(Html.GrupoDemonstrativo); if (first) { grupoDemonstrativo = grupoDemonstrativo.Replace("@DESCRICAOGRUPO", relatorio.Descricao); first = false; } else { grupoDemonstrativo = grupoDemonstrativo.Replace("@DESCRICAOGRUPO", string.Empty); } grupoDemonstrativo = grupoDemonstrativo.Replace("@DESCRICAOITEM", item.Descricao); grupoDemonstrativo = grupoDemonstrativo.Replace("@REFERENCIAITEM", item.Referencia); grupoDemonstrativo = grupoDemonstrativo.Replace("@VALORITEM", item.Valor.ToString("R$ ##,##0.00")); } grupoDemonstrativo.Append(Html.TotalDemonstrativo); grupoDemonstrativo = grupoDemonstrativo.Replace( "@VALORTOTALGRUPO", relatorio.Itens.Sum(c => c.Valor).ToString("R$ ##,##0.00")); } html = html.Replace("@ITENSDEMONSTRATIVO", grupoDemonstrativo.ToString()); } if (Boleto.Opcoes.Formato != FormatoBoleto.Carne) { //Mostra o comprovante de entrega if (Boleto.Opcoes.MostrarComprovanteEntrega | Boleto.Opcoes.MostrarComprovanteEntregaLivre) { html.Append(HtmlComprovanteEntrega); //Html da linha pontilhada if (Boleto.Opcoes.OcultarReciboSacado) { html.Append(Html.ReciboSacadoParte8); } } //Oculta o recibo do sacabo do boleto if (!Boleto.Opcoes.OcultarReciboSacado) { html.Append(GeraHtmlReciboSacado()); //Caso mostre o Endereço do Cedente if (parametrosBoleto.MostrarEnderecoCedente) { if (Cedente.Endereco == null) { throw new ArgumentNullException("Endereço do Cedente"); } string numero = !String.IsNullOrEmpty(Cedente.Endereco.Numero) ? Cedente.Endereco.Numero + ", " : ""; parametrosBoleto.EnderecoCedente = string.Concat(Cedente.Endereco.End, " , ", numero); if (Cedente.Endereco.CEP == String.Empty) { parametrosBoleto.EnderecoCedente += string.Format("{0} - {1}/{2}", Cedente.Endereco.Bairro, Cedente.Endereco.Cidade, Cedente.Endereco.UF); } else { parametrosBoleto.EnderecoCedente += string.Format("{0} - {1}/{2} - CEP: {3}", Cedente.Endereco.Bairro, Cedente.Endereco.Cidade, Cedente.Endereco.UF, Utils.FormataCEP(Cedente.Endereco.CEP)); } } } } if (Boleto.Opcoes.Formato != FormatoBoleto.Carne) { html.Append(GerarHtmlReciboCedente()); } else { html.Append(GeraHtmlCarne("", GerarHtmlReciboCedente())); } if (String.IsNullOrEmpty(Boleto.Cedente.Logo)) { parametrosBoleto.LocalLogoCliente = parametrosBoleto.UrlImagemLogo; } return(Boleto.Banco.RenderizaBoleto(html, parametrosBoleto).ToString()); }