diff --git a/src/MDFe/Damdfe.php b/src/MDFe/Damdfe.php index 4306f298..aa01b913 100644 --- a/src/MDFe/Damdfe.php +++ b/src/MDFe/Damdfe.php @@ -23,26 +23,20 @@ class Damdfe extends DaCommon { - protected $yDados = 0; - protected $xml; // string XML NFe - protected $errMsg = ''; // mesagens de erro - protected $errStatus = false;// status de erro TRUE um erro ocorreu false sem erros + protected $xml; // string XML MDFe protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####"; protected $margemInterna = 2; protected $id; protected $chMDFe; protected $tpAmb; protected $ide; - protected $xCondUso; protected $dhEvento; protected $cStat; - protected $xMotivo; - protected $CNPJDest = ''; protected $mdfeProc; protected $nProt; protected $tpEmis; protected $qrCodMDFe; - protected $baseFont = array('font' => 'Times', 'size' => 8, 'style' => ''); + protected $baseFont = array('font' => 'arial', 'size' => 8, 'style' => ''); protected $infMDFe; protected $emit; protected $CPF; @@ -319,14 +313,14 @@ private function headerMDFePaisagem($x, $y, $pag) $nImgH = round($h / 3, 0); $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); $xImg = round(($w - $nImgW) / 2 + $x, 0); - $yImg = $y + 3; + $yImg = $y + 4; $x1 = $x; $y1 = round($yImg + $nImgH + 1, 0); $tw = $w; } if ($this->logoAlign == 'R') { - $nImgW = round($w / 3, 0); - $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); + $nImgW = round((round($maxW * 0.50, 0)) / 3, 0); + $nImgH = round(($h - $y) - 2, 0) + $y; $xImg = round($x + ($w - (1 + $nImgW)), 0); $yImg = round(($h - $nImgH) / 2, 0) + $y; $x1 = $x; @@ -339,11 +333,9 @@ private function headerMDFePaisagem($x, $y, $pag) $y1 = round($h / 3 + $y, 0); $tw = $w; } - if ($this->qrCodMDFe !== null) { $this->qrCodeDamdfe($y - 3); } - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); $texto = $this->xNome; $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'L', 0, ''); @@ -537,14 +529,14 @@ private function headerMDFeRetrato($x, $y, $pag) $nImgH = round($h / 3, 0); $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); $xImg = round(($w - $nImgW) / 2 + $x, 0); - $yImg = $y + 3; + $yImg = $y - 1; $x1 = $x; $y1 = round($yImg + $nImgH + 1, 0); $tw = $w; } if ($this->logoAlign == 'R') { - $nImgW = round($w / 3, 0); - $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); + $nImgW = round((round($maxW * 0.50, 0)) / 3, 0); + $nImgH = round(($h - $y) - 2, 0) + $y; $xImg = round($x + ($w - (1 + $nImgW)), 0); $yImg = round(($h - $nImgH) / 2, 0) + $y; $x1 = $x; @@ -557,11 +549,9 @@ private function headerMDFeRetrato($x, $y, $pag) $y1 = $y; $tw = $w; } - if ($this->qrCodMDFe !== null) { $this->qrCodeDamdfe($y - 3); } - $aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; $texto = $this->xNome; $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'L', 0, ''); @@ -661,7 +651,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x, $y, $x2 - 22, 2, $texto, $aFont, 'T', 'L', 0, '', false); $texto = $this->mod; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => ''); $this->pdf->textBox($x, $y + 4, $x2 - 22, 4, $texto, $aFont, 'T', 'L', 0, '', false); if ($this->orientacao == 'P') { @@ -674,7 +664,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x1, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'L', 0, '', false); $texto = $this->serie; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => ''); $this->pdf->textBox($x1, $y + 4, $x2 - 22, 4, $texto, $aFont, 'T', 'L', 0, '', false); $x1 += $x2 - 22; @@ -683,7 +673,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x1, $y, $x2 - 6, 8, $texto, $aFont, 'T', 'L', 0, '', false); $texto = $this->formatField(str_pad($this->nMDF, 9, '0', STR_PAD_LEFT), '###.###.###'); - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => ''); $this->pdf->textBox($x1, $y + 4, $x2 - 6, 4, $texto, $aFont, 'T', 'L', 0, '', false); $x1 += $x2 - 5; $this->pdf->textBox($x1, $y, $x2 - 23, 10, '', $this->baseFont, 'T', 'L', 0, '', 0, 0, 0, 1); @@ -691,7 +681,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x1, $y, $x2 - 23, 8, $texto, $aFont, 'T', 'L', 0, '', false); $texto = '1/1'; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => ''); $this->pdf->textBox($x1, $y + 4, $x2 - 23, 4, $texto, $aFont, 'T', 'L', 0, '', false); $x1 += $x2 - 22; if ($this->orientacao == 'P') { @@ -705,7 +695,7 @@ private function bodyMDFe($x, $y) $this->pdf->textBox($x1, $y, $x3 - 1, 8, $texto, $aFont, 'T', 'L', 0, '', false); $data = explode('T', $this->dhEmi); $texto = $this->ymdTodmy($data[0]) . ' - ' . $data[1]; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B'); $this->pdf->textBox($x1, $y + 4, $x3 - 1, 4, $texto, $aFont, 'T', 'L', 0, '', false); $x1 += $x3; @@ -714,7 +704,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x1, $y, $x2 - 16, 8, $texto, $aFont, 'T', 'L', 0, '', false); $texto = $this->UFIni; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B'); $this->pdf->textBox($x1, $y + 4, $x2 - 16, 4, $texto, $aFont, 'T', 'L', 0, '', false); $maxW = $this->wPrint; @@ -724,7 +714,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x1, $y, $x2 - 16, 4, $texto, $aFont, 'T', 'L', 0, '', false); $texto = $this->UFFim; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B'); $this->pdf->textBox($x1, $y + 4, $x2 - 16, 4, $texto, $aFont, 'T', 'L', 0, '', false); $maxW = $this->wPrint; @@ -740,7 +730,7 @@ private function bodyMDFe($x, $y) $texto = $this->aquav->getElementsByTagName('cEmbar')->item(0)->nodeValue; $texto .= ' - '; $texto .= $this->aquav->getElementsByTagName('xEmbar')->item(0)->nodeValue; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B'); $this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'L', 0, '', false); } @@ -775,7 +765,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x1, $y, $x2 - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false); $texto = str_pad($this->qCTe, 3, '0', STR_PAD_LEFT); - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B'); $this->pdf->textBox($x1, $y + 4, $x2 - 2, 4, $texto, $aFont, 'T', 'L', 0, '', false); $x1 += $x2; $this->pdf->textBox($x1, $y, $x2 - 1, 10, '', $this->baseFont, 'T', 'L', 0, '', 0, 0, 0, 1); @@ -783,7 +773,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x1, $y, $x2 - 1, 8, $texto, $aFont, 'T', 'L', 0, '', false); $texto = str_pad($this->qNFe, 3, '0', STR_PAD_LEFT); - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B'); $this->pdf->textBox($x1, $y + 4, $x2 - 1, 4, $texto, $aFont, 'T', 'L', 0, '', false); $x1 += $x2; $this->pdf->textBox($x1, $y, $x2, 10, '', $this->baseFont, 'T', 'L', 0, '', 0, 0, 0, 1); @@ -800,7 +790,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); $texto = number_format($this->qCarga, 4, ',', '.'); - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B'); $this->pdf->textBox($x1, $y + 4, $x2, 4, $texto, $aFont, 'T', 'L', 0, '', false); } $this->pdf->setFillColor(255, 255, 255); @@ -810,7 +800,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); $this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); $texto = str_pad($this->qMDFe, 3, '0', STR_PAD_LEFT); - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B'); $this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); $ya = $y + 12; @@ -823,7 +813,7 @@ private function bodyMDFe($x, $y) } $this->pdf->textBox($x, $ya, $maxW / 2, 8, $texto, $aFont, 'T', 'L', 0, ''); $texto = number_format($this->qCarga, 4, ',', '.'); - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B'); $this->pdf->textBox($x, $ya + 4, $x2, 10, $texto, $aFont, 'T', 'L', 0, '', false); } @@ -843,7 +833,7 @@ private function bodyMDFe($x, $y) $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); $texto = 'Protocolo de Autorização'; $this->pdf->textBox($x, $y, $maxW / 2, 8, $texto, $aFont, 'T', 'L', 0, ''); - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => ''); if (is_object($this->mdfeProc)) { $tsHora = $this->toTimestamp($this->dhRecbto); $texto = $this->nProt . ' - ' . date('d/m/Y H:i:s', $tsHora); @@ -958,7 +948,7 @@ private function bodyMDFe($x, $y) $altura += 4; $pgNode = $this->valePed->item($i)->getElementsByTagName('CNPJPg'); $texto = $pgNode->length == 0 ? '' : $pgNode->item(0)->nodeValue; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => ''); $this->pdf->textBox($x1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false); } $x1 += $x2 - 3; @@ -971,7 +961,7 @@ private function bodyMDFe($x, $y) $altura += 4; $pgNode = $this->valePed->item($i)->getElementsByTagName('CNPJForn'); $texto = $pgNode->length == 0 ? '' : $pgNode->item(0)->nodeValue; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => ''); $this->pdf->textBox($x1, $altura, $x2 - 3, 10, $texto, $aFont, 'T', 'L', 0, '', false); } $x1 += $x2 - 3; @@ -983,7 +973,7 @@ private function bodyMDFe($x, $y) for ($i = 0; $i < $valesPedagios; $i++) { $altura += 4; $texto = $this->valePed->item($i)->getElementsByTagName('nCompra')->item(0)->nodeValue; - $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); + $aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => ''); $this->pdf->textBox($x1, $altura, $x2 + 6, 10, $texto, $aFont, 'T', 'L', 0, '', false); } if (!$temVales) {