diff --git a/src/NFe/Danfce.php b/src/NFe/Danfce.php index ff1d8f38..e4ae8bc5 100644 --- a/src/NFe/Danfce.php +++ b/src/NFe/Danfce.php @@ -57,6 +57,7 @@ class Danfce extends DaCommon protected $urlQR = ''; protected $pdf; protected $margem = 2; + protected $textoExtra = ''; protected $flagResume = false; protected $hMaxLinha = 5; protected $hBoxLinha = 6; @@ -185,6 +186,16 @@ public function setOffLineDoublePrint($flag = true) $this->offline_double = $flag; } + /** + * Recebe uma string com uma informação adicionadl que sera impressa no final do pdf + * + * @param string $texto + */ + public function setExtraContent($texto) + { + $this->textoExtra = $texto; + } + /** * Renderiza o pdf * diff --git a/src/NFe/Traits/TraitBlocoIX.php b/src/NFe/Traits/TraitBlocoIX.php index 778afed3..598745aa 100644 --- a/src/NFe/Traits/TraitBlocoIX.php +++ b/src/NFe/Traits/TraitBlocoIX.php @@ -2,6 +2,8 @@ namespace NFePHP\DA\NFe\Traits; +use NFePHP\DA\Legacy\Pdf; + /** * Bloco Informações sobre impostos aproximados */ @@ -44,9 +46,9 @@ protected function blocoIX($y) '', false ); - return $this->bloco9H + $y; + return $y + 3; } - + /** * Calcula a altura do bloco IX * Depende do conteudo de infCpl @@ -59,7 +61,7 @@ protected function calculateHeighBlokIX() $wprint = $this->paperwidth - (2 * $this->margem); $logoAlign = 'L'; $orientacao = 'P'; - $pdf = new \NFePHP\DA\Legacy\Pdf($orientacao, 'mm', $papel); + $pdf = new Pdf($orientacao, 'mm', $papel); $fsize = 7; $aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => '']; if ($this->paperwidth < 70) { @@ -68,7 +70,12 @@ protected function calculateHeighBlokIX() } $linhas = str_replace(';', "\n", $this->infCpl); $hfont = (imagefontheight($fsize)/72)*13; - $numlinhas = $pdf->getNumLines($linhas, $wprint, $aFont)+2; + $numlinhas = $pdf->getNumLines($linhas, $wprint, $aFont); + if (!empty($this->textoExtra)) { + $linhas = str_replace(';', "\n", $this->textoExtra); + $hfont = (imagefontheight($fsize)/72)*13; + $numlinhas += $pdf->getNumLines($linhas, $wprint, $aFont); + } return (int) ($numlinhas * $hfont) + 2; } } diff --git a/src/NFe/Traits/TraitBlocoX.php b/src/NFe/Traits/TraitBlocoX.php index 1d75b2d8..d5019ea8 100644 --- a/src/NFe/Traits/TraitBlocoX.php +++ b/src/NFe/Traits/TraitBlocoX.php @@ -9,18 +9,13 @@ trait TraitBlocoX { protected function blocoX($y) { - //$this->bloco9H = 3; - - /* - $aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => '']; - $this->pdf->textBox($this->margem, $y, $this->wPrint, $this->bloco9H, '', $aFont, 'T', 'C', true, '', false); - */ - $aFont = ['font'=> $this->fontePadrao, 'size' => 6, 'style' => 'I']; if ($this->paperwidth < 70) { $aFont = ['font'=> $this->fontePadrao, 'size' => 4, 'style' => 'I']; } if (!empty($this->creditos)) { + $y += 4; + $this->pdf->textBox( $this->margem, $y, @@ -35,6 +30,24 @@ protected function blocoX($y) true ); } + + if (!empty($this->textoExtra)) { + $y += 4; + + $this->pdf->textBox( + $this->margem, + $y, + $this->wPrint, + $this->bloco9H, + $this->textoExtra, + $aFont, + 'T', + 'L', + false, + '', + true + ); + } return $this->bloco9H + $y; } }