Skip to content

Commit

Permalink
Correções no PDF do MDF-e e alterado o tamanho de algumas fontes de 1…
Browse files Browse the repository at this point in the history
…0 para 9.
  • Loading branch information
icompsoftcleiton committed Jan 19, 2024
1 parent e2727f7 commit ac8262c
Showing 1 changed file with 25 additions and 35 deletions.
60 changes: 25 additions & 35 deletions src/MDFe/Damdfe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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, '');
Expand Down Expand Up @@ -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;
Expand All @@ -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, '');
Expand Down Expand Up @@ -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') {
Expand All @@ -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;
Expand All @@ -683,15 +673,15 @@ 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);
$texto = 'FL';
$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') {
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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);
}

Expand Down Expand Up @@ -775,15 +765,15 @@ 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);
$texto = 'Qtd. NF-e';
$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);
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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);
}

Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit ac8262c

Please sign in to comment.