diff --git a/NFe.Danfe.Base/NFCe/NFCe.frx b/NFe.Danfe.Base/NFCe/NFCe.frx index ecaadeb0a..af072cdf6 100644 --- a/NFe.Danfe.Base/NFCe/NFCe.frx +++ b/NFe.Danfe.Base/NFCe/NFCe.frx @@ -1,5 +1,5 @@  - + using System; using System.Collections; using System.Collections.Generic; @@ -192,29 +192,57 @@ namespace FastReport if ( (NfceModoImpressao) ((Int32)Report.GetParameterValue("NfceModoImpressao")) != NfceModoImpressao.UnicaPagina) return; - PgNfce.PaperHeight = - (rtbEmitLogoHeight + - phbEmitenteHeight + - ((Boolean)Report.GetParameterValue("NfceCancelado") ? phbCancelado.Height : 0)+ - ghbProdutosUmaLinhaHeight + - dbProdutosUmaLinhaHeight + - ghbProdutosDuasLinhasHeight + - dbProdutosDuasLinhasHeight + - gfbProdutosHeight + - dbPagamentoHeight + - dbDetPagamentoHeight + - dbTributosHeight + - dbObservacaoHeight + - dbInfoFiscalHeight + - dbNumeroSerieDhHeight + - dbConsultaHeight + - dbDestinatarioHeight + - dbQrCodeNormalHeight + - dbQrCodeLateralHeight + - dbProtocoloHeigth - ) / - Units.Millimeters + PgNfce.TopMargin + PgNfce.BottomMargin; + CompactarTopDeDesignDasBandas(); + PgNfce.PaperHeight = (rtbEmitLogoHeight + + phbEmitenteHeight + + ((Boolean)Report.GetParameterValue("NfceCancelado") ? phbCancelado.Height : 0)+ + ghbProdutosUmaLinhaHeight + + dbProdutosUmaLinhaHeight + + ghbProdutosDuasLinhasHeight + + dbProdutosDuasLinhasHeight + + gfbProdutosHeight + + cbDescontoHeight + + child2Height + + dbPagamentoHeight + + dbDetPagamentoHeight + + dbTrocoHeight + + dbTributosHeight + + dbObservacaoHeight + + dbInfoFiscalHeight + + dbNumeroSerieDhHeight + + dbConsultaHeight + + dbInfProtxMsgHeight + + dbDestinatarioHeight + + dbQrCodeNormalHeight + + dbQrCodeLateralHeight + + dbProtocoloHeigth + + dbTextoRodapeHeight + ) / Units.Millimeters + PgNfce.TopMargin + PgNfce.BottomMargin; + } + + /// <summary> + /// Compacta o Top de DESIGN de todas as bandas da página para ~0, preservando a ordem relativa + /// (incrementos de 0.01px). No modo de impressão em página única o PaperHeight é calculado do + /// tamanho do conteúdo e pode ficar menor que o Top de design das últimas bandas (~297mm de + /// layout empilhado no designer); nesse caso, ao calcular a altura de bandas CanShrink, o + /// FastReport aplica altura = min(alturaDoConteudo, alturaDaPagina - TopDeDesign) e o resultado + /// fica NEGATIVO, puxando as bandas seguintes para cima e desmontando o fim do cupom (QR Code, + /// protocolo, tributos e rodapé) em cupons com poucos itens. O Top de design não define a + /// posição real de impressão (as bandas fluem em sequência), então compactá-lo não altera o + /// visual e apenas elimina o recorte. + /// </summary> + private void CompactarTopDeDesignDasBandas() + { + float topCompacto = 0; + foreach (Base c in PgNfce.AllObjects) + { + BandBase b = c as BandBase; + if (b == null) + continue; + b.Top = topCompacto; + topCompacto += 0.01f; + } } float dbProdutosUmaLinhaHeight; @@ -280,13 +308,13 @@ namespace FastReport float dbPagamentoHeight; private void dbPagamento_AfterPrint(object sender, EventArgs e) { - dbPagamentoHeight = (dbPagamento.Visible ? dbPagamento.Height : 0); + dbPagamentoHeight += (dbPagamento.Visible ? dbPagamento.Height : 0); } float dbDetPagamentoHeight; private void dbDetPagamento_AfterPrint(object sender, EventArgs e) { - dbDetPagamentoHeight = (dbDetPagamento.Visible ? dbDetPagamento.Height : 0); + dbDetPagamentoHeight += (dbDetPagamento.Visible ? dbDetPagamento.Height : 0); } float dbTributosHeight; @@ -313,6 +341,48 @@ namespace FastReport dbQrCodeNormalHeight = (dbQrCodeNormal.Visible ? dbQrCodeNormal.Height : 0); } + float dbQrCodeLateralHeight; + private void dbQrCodeLateral_AfterPrint(object sender, EventArgs e) + { + dbQrCodeLateralHeight = (dbQrCodeLateral.Visible ? dbQrCodeLateral.Height : 0); + } + + float dbProtocoloHeigth; + private void dbProtocolo_AfterPrint(object sender, EventArgs e) + { + dbProtocoloHeigth = (dbProtocolo.Visible ? dbProtocolo.Height : 0); + } + + float dbTrocoHeight; + private void dbTroco_AfterPrint(object sender, EventArgs e) + { + dbTrocoHeight = (dbTroco.Visible ? dbTroco.Height : 0); + } + + float cbDescontoHeight; + private void cbDesconto_AfterPrint(object sender, EventArgs e) + { + cbDescontoHeight = (cbDesconto.Visible ? cbDesconto.Height : 0); + } + + float child2Height; + private void Child2_AfterPrint(object sender, EventArgs e) + { + child2Height = (Child2.Visible ? Child2.Height : 0); + } + + float dbInfProtxMsgHeight; + private void dbInfProtxMsg_AfterPrint(object sender, EventArgs e) + { + dbInfProtxMsgHeight = (dbInfProtxMsg.Visible ? dbInfProtxMsg.Height : 0); + } + + float dbTextoRodapeHeight; + private void dbTextoRodape_AfterPrint(object sender, EventArgs e) + { + dbTextoRodapeHeight = (dbTextoRodape.Visible ? dbTextoRodape.Height : 0); + } + private void cbDesconto_BeforePrint(object sender, EventArgs e) { cbDesconto.Visible = ((Decimal)Report.GetColumnValue("NFCe.NFe.infNFe.total.ICMSTot.vDesc")) > 0; @@ -339,25 +409,12 @@ namespace FastReport dbTroco.Visible = Report.GetColumnValue("NFCe.NFe.infNFe.pag.vTroco") != null; } - private void dbQrCodeLateral_BeforePrint(object sender, EventArgs e) { TrataCamposDestinatario(); dbQrCodeLateral.Visible = ((NfceLayoutQrCode) Report.GetParameterValue("NfceLayoutQrCode") == NfceLayoutQrCode.Lateral); } - float dbQrCodeLateralHeight; - private void dbQrCodeLateral_AfterPrint(object sender, EventArgs e) - { - dbQrCodeLateralHeight = (dbQrCodeLateral.Visible ? dbQrCodeLateral.Height : 0); - } - - float dbProtocoloHeigth; - private void dbProtocolo_AfterPrint(object sender, EventArgs e) - { - dbProtocoloHeigth = (dbProtocolo.Visible ? dbProtocolo.Height : 0); - } - private void dbQrCodeNormal_BeforePrint(object sender, EventArgs e) { dbQrCodeNormal.Visible = ((NfceLayoutQrCode) Report.GetParameterValue("NfceLayoutQrCode") == NfceLayoutQrCode.Abaixo); @@ -437,7 +494,22 @@ namespace FastReport + + + + + + + + + + + + + + + @@ -572,7 +644,9 @@ namespace FastReport - + + + @@ -584,9 +658,13 @@ namespace FastReport + + + + @@ -594,9 +672,14 @@ namespace FastReport - - - + + + + + + + + @@ -676,7 +759,154 @@ namespace FastReport + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -694,6 +924,11 @@ namespace FastReport + + + + + @@ -754,7 +989,48 @@ namespace FastReport + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -851,9 +1127,27 @@ namespace FastReport + + + + + + + + + + + + + + + + + + @@ -1026,12 +1320,12 @@ namespace FastReport - + - + @@ -1045,7 +1339,7 @@ namespace FastReport - + @@ -1067,7 +1361,7 @@ namespace FastReport - + @@ -1093,7 +1387,7 @@ namespace FastReport - +