Passed
Push — master ( f47aed...e4694f )
by Roberto
05:27
created
src/NFe/Danfe.php 1 patch
Spacing   +314 added lines, -321 removed lines patch added patch discarded remove patch
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      * ativa ou desativa o modo de debug
299 299
      * @var integer
300 300
      */
301
-    protected $debugMode=2;
301
+    protected $debugMode = 2;
302 302
     /**
303 303
      * Creditos para integrador
304 304
      * @var string
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             $this->fontePadrao = $fonteDANFE;
357 357
         }
358 358
         //se for passado o xml
359
-        if (! empty($this->xml)) {
359
+        if (!empty($this->xml)) {
360 360
             $this->dom = new Dom();
361 361
             $this->dom->loadXML($this->xml);
362 362
             $this->nfeProc    = $this->dom->getElementsByTagName("nfeProc")->item(0);
@@ -513,10 +513,10 @@  discard block
 block discarded – undo
513 513
         //total inicial de paginas
514 514
         $totPag = 1;
515 515
         //largura imprimivel em mm: largura da folha menos as margens esq/direita
516
-        $this->wPrint = $maxW-($margEsq*2);
516
+        $this->wPrint = $maxW - ($margEsq * 2);
517 517
         //comprimento (altura) imprimivel em mm: altura da folha menos as margens
518 518
         //superior e inferior
519
-        $this->hPrint = $maxH-$margSup-$margInf;
519
+        $this->hPrint = $maxH - $margSup - $margInf;
520 520
         // estabelece contagem de paginas
521 521
         $this->pdf->aliasNbPages();
522 522
         // fixa as margens
@@ -554,34 +554,28 @@  discard block
 block discarded – undo
554 554
         }
555 555
         //calcular a altura necessária para os dados adicionais
556 556
         if ($this->orientacao == 'P') {
557
-            $this->wAdic = round($this->wPrint*0.66, 0);
557
+            $this->wAdic = round($this->wPrint * 0.66, 0);
558 558
         } else {
559
-            $this->wAdic = round(($this->wPrint-$this->wCanhoto)*0.5, 0);
559
+            $this->wAdic = round(($this->wPrint - $this->wCanhoto) * 0.5, 0);
560 560
         }
561 561
         $fontProduto = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
562 562
         $this->textoAdic = '';
563 563
         if (isset($this->retirada)) {
564
-            $txRetCNPJ = ! empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
565
-                $this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue :
566
-                '';
567
-            $txRetxLgr = ! empty($this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue) ?
568
-                $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue :
569
-                '';
570
-            $txRetnro = ! empty($this->retirada->getElementsByTagName("nro")->item(0)->nodeValue) ?
571
-                $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue :
572
-                's/n';
564
+            $txRetCNPJ = !empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
565
+                $this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue : '';
566
+            $txRetxLgr = !empty($this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue) ?
567
+                $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue : '';
568
+            $txRetnro = !empty($this->retirada->getElementsByTagName("nro")->item(0)->nodeValue) ?
569
+                $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue : 's/n';
573 570
             $txRetxCpl = $this->pSimpleGetValue($this->retirada, "xCpl", " - ");
574
-            $txRetxBairro = ! empty($this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue) ?
575
-                $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue :
576
-                '';
577
-            $txRetxMun = ! empty($this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue) ?
578
-                $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue :
579
-                '';
580
-            $txRetUF = ! empty($this->retirada->getElementsByTagName("UF")->item(0)->nodeValue) ?
581
-                $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue :
582
-                '';
583
-            $this->textoAdic .= "LOCAL DE RETIRADA : ".
584
-                    $txRetCNPJ.
571
+            $txRetxBairro = !empty($this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue) ?
572
+                $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue : '';
573
+            $txRetxMun = !empty($this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue) ?
574
+                $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue : '';
575
+            $txRetUF = !empty($this->retirada->getElementsByTagName("UF")->item(0)->nodeValue) ?
576
+                $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue : '';
577
+            $this->textoAdic .= "LOCAL DE RETIRADA : " .
578
+                    $txRetCNPJ .
585 579
                     '-' .
586 580
                     $txRetxLgr .
587 581
                     ', ' .
@@ -598,24 +592,24 @@  discard block
 block discarded – undo
598 592
         }
599 593
         //dados do local de entrega da mercadoria
600 594
         if (isset($this->entrega)) {
601
-            $txRetCNPJ = ! empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
595
+            $txRetCNPJ = !empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
602 596
                 $this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue : '';
603
-            $txRetxLgr = ! empty($this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue) ?
597
+            $txRetxLgr = !empty($this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue) ?
604 598
                 $this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue : '';
605
-            $txRetnro = ! empty($this->entrega->getElementsByTagName("nro")->item(0)->nodeValue) ?
599
+            $txRetnro = !empty($this->entrega->getElementsByTagName("nro")->item(0)->nodeValue) ?
606 600
                 $this->entrega->getElementsByTagName("nro")->item(0)->nodeValue : 's/n';
607 601
             $txRetxCpl = $this->pSimpleGetValue($this->entrega, "xCpl", " - ");
608
-            $txRetxBairro = ! empty($this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue) ?
602
+            $txRetxBairro = !empty($this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue) ?
609 603
                 $this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue : '';
610
-            $txRetxMun = ! empty($this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue) ?
604
+            $txRetxMun = !empty($this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue) ?
611 605
                 $this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue : '';
612
-            $txRetUF = ! empty($this->entrega->getElementsByTagName("UF")->item(0)->nodeValue) ?
606
+            $txRetUF = !empty($this->entrega->getElementsByTagName("UF")->item(0)->nodeValue) ?
613 607
                 $this->entrega->getElementsByTagName("UF")->item(0)->nodeValue : '';
614 608
             if ($this->textoAdic != '') {
615 609
                 $this->textoAdic .= ". \r\n";
616 610
             }
617
-            $this->textoAdic .= "LOCAL DE ENTREGA : ".$txRetCNPJ.'-'.$txRetxLgr.', '.$txRetnro.' '.$txRetxCpl.
618
-               ' - '.$txRetxBairro.' '.$txRetxMun.' - '.$txRetUF."\r\n";
611
+            $this->textoAdic .= "LOCAL DE ENTREGA : " . $txRetCNPJ . '-' . $txRetxLgr . ', ' . $txRetnro . ' ' . $txRetxCpl .
612
+               ' - ' . $txRetxBairro . ' ' . $txRetxMun . ' - ' . $txRetUF . "\r\n";
619 613
         }
620 614
         //informações adicionais
621 615
         $this->textoAdic .= $this->pGeraInformacoesDasNotasReferenciadas();
@@ -624,7 +618,7 @@  discard block
 block discarded – undo
624 618
             if ($this->textoAdic != '') {
625 619
                 $this->textoAdic .= ". \r\n";
626 620
             }
627
-            $this->textoAdic .= ! empty($this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue) ?
621
+            $this->textoAdic .= !empty($this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue) ?
628 622
                 'Inf. Contribuinte: ' .
629 623
                 trim($this->pAnfavea($this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue)) : '';
630 624
             $infPedido = $this->pGeraInformacoesDaTagCompra();
@@ -632,14 +626,14 @@  discard block
 block discarded – undo
632 626
                 $this->textoAdic .= $infPedido;
633 627
             }
634 628
             $this->textoAdic .= $this->pSimpleGetValue($this->dest, "email", ' Email do Destinatário: ');
635
-            $this->textoAdic .= ! empty($this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue) ?
629
+            $this->textoAdic .= !empty($this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue) ?
636 630
                 "\r\n Inf. fisco: " .
637 631
                 trim($this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue) : '';
638 632
             $obsCont = $this->infAdic->getElementsByTagName("obsCont");
639 633
             if (isset($obsCont)) {
640 634
                 foreach ($obsCont as $obs) {
641
-                    $campo =  $obsCont->item($i)->getAttribute("xCampo");
642
-                    $xTexto = ! empty($obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue) ?
635
+                    $campo = $obsCont->item($i)->getAttribute("xCampo");
636
+                    $xTexto = !empty($obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue) ?
643 637
                         $obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue : '';
644 638
                     $this->textoAdic .= "\r\n" . $campo . ':  ' . trim($xTexto);
645 639
                     $i++;
@@ -667,38 +661,38 @@  discard block
 block discarded – undo
667 661
         foreach ($alinhas as $linha) {
668 662
             $numlinhasdados += $this->pGetNumLines($linha, $this->wAdic, $fontProduto);
669 663
         }
670
-        $hdadosadic = round(($numlinhasdados+3) * $this->pdf->fontSize, 0);
664
+        $hdadosadic = round(($numlinhasdados + 3) * $this->pdf->fontSize, 0);
671 665
         if ($hdadosadic < 10) {
672 666
             $hdadosadic = 10;
673 667
         }
674 668
         //altura disponivel para os campos da DANFE
675
-        $hcabecalho = 47;//para cabeçalho
676
-        $hdestinatario = 25;//para destinatario
677
-        $hduplicatas = 12;//para cada grupo de 7 duplicatas
678
-        $himposto = 18;// para imposto
679
-        $htransporte = 25;// para transporte
680
-        $hissqn = 11;// para issqn
681
-        $hfooter = 5;// para rodape
682
-        $hCabecItens = 4;//cabeçalho dos itens
669
+        $hcabecalho = 47; //para cabeçalho
670
+        $hdestinatario = 25; //para destinatario
671
+        $hduplicatas = 12; //para cada grupo de 7 duplicatas
672
+        $himposto = 18; // para imposto
673
+        $htransporte = 25; // para transporte
674
+        $hissqn = 11; // para issqn
675
+        $hfooter = 5; // para rodape
676
+        $hCabecItens = 4; //cabeçalho dos itens
683 677
         //alturas disponiveis para os dados
684 678
         $hDispo1 = $this->hPrint - 10 - ($hcabecalho +
685 679
             $hdestinatario + ($linhasDup * $hduplicatas) + $himposto + $htransporte +
686 680
             ($linhaISSQN * $hissqn) + $hdadosadic + $hfooter + $hCabecItens +
687 681
             $this->pSizeExtraTextoFatura());
688 682
         if ($this->orientacao == 'P') {
689
-            $hDispo1 -= 23 * $this->qCanhoto;//para canhoto
683
+            $hDispo1 -= 23 * $this->qCanhoto; //para canhoto
690 684
             $w = $this->wPrint;
691 685
         } else {
692
-            $hcanhoto = $this->hPrint;//para canhoto
686
+            $hcanhoto = $this->hPrint; //para canhoto
693 687
             $w = $this->wPrint - $this->wCanhoto;
694 688
         }
695
-        $hDispo2 = $this->hPrint - 10 - ($hcabecalho + $hfooter + $hCabecItens)-4;
689
+        $hDispo2 = $this->hPrint - 10 - ($hcabecalho + $hfooter + $hCabecItens) - 4;
696 690
         //Contagem da altura ocupada para impressão dos itens
697 691
         $fontProduto = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
698 692
         $i = 0;
699 693
         $numlinhas = 0;
700 694
         $hUsado = $hCabecItens;
701
-        $w2 = round($w*0.28, 0);
695
+        $w2 = round($w * 0.28, 0);
702 696
         $hDispo = $hDispo1;
703 697
         $totPag = 1;
704 698
         while ($i < $this->det->length) {
@@ -710,7 +704,7 @@  discard block
 block discarded – undo
710 704
                 $hDispo = $hDispo2;
711 705
                 $hUsado = $hCabecItens;
712 706
                 // Remove canhoto para páginas secundárias em modo paisagem ('L')
713
-                $w2 = round($this->wPrint*0.28, 0);
707
+                $w2 = round($this->wPrint * 0.28, 0);
714 708
                 $i--; // decrementa para readicionar o item que não coube nessa pagina na outra.
715 709
             }
716 710
             $i++;
@@ -734,19 +728,19 @@  discard block
 block discarded – undo
734 728
         //coloca o cabeçalho
735 729
         $y = $this->pCabecalhoDANFE($x, $y, $pag, $totPag);
736 730
         //coloca os dados do destinatário
737
-        $y = $this->pDestinatarioDANFE($x, $y+1);
731
+        $y = $this->pDestinatarioDANFE($x, $y + 1);
738 732
         //coloca os dados das faturas
739
-        $y = $this->pFaturaDANFE($x, $y+1);
733
+        $y = $this->pFaturaDANFE($x, $y + 1);
740 734
         //coloca os dados dos impostos e totais da NFe
741
-        $y = $this->pImpostoDANFE($x, $y+1);
735
+        $y = $this->pImpostoDANFE($x, $y + 1);
742 736
         //coloca os dados do trasnporte
743
-        $y = $this->pTransporteDANFE($x, $y+1);
737
+        $y = $this->pTransporteDANFE($x, $y + 1);
744 738
         //itens da DANFE
745 739
         $nInicial = 0;
746
-        $y = $this->pItensDANFE($x, $y+1, $nInicial, $hDispo1, $pag, $totPag, $hCabecItens);
740
+        $y = $this->pItensDANFE($x, $y + 1, $nInicial, $hDispo1, $pag, $totPag, $hCabecItens);
747 741
         //coloca os dados do ISSQN
748 742
         if ($linhaISSQN == 1) {
749
-            $y = $this->pIssqnDANFE($x, $y+4);
743
+            $y = $this->pIssqnDANFE($x, $y + 4);
750 744
         } else {
751 745
             $y += 4;
752 746
         }
@@ -754,7 +748,7 @@  discard block
 block discarded – undo
754 748
         $y = $this->pDadosAdicionaisDANFE($x, $y, $hdadosadic);
755 749
         //coloca o rodapé da página
756 750
         if ($this->orientacao == 'P') {
757
-            $this->pRodape($xInic, $y-1);
751
+            $this->pRodape($xInic, $y - 1);
758 752
         } else {
759 753
             $this->pRodape($xInic, $this->hPrint + 1);
760 754
         }
@@ -774,7 +768,7 @@  discard block
 block discarded – undo
774 768
             //coloca o cabeçalho na página adicional
775 769
             $y = $this->pCabecalhoDANFE($x, $y, $n, $totPag);
776 770
             //coloca os itens na página adicional
777
-            $y = $this->pItensDANFE($x, $y+1, $nInicial, $hDispo2, $n, $totPag, $hCabecItens);
771
+            $y = $this->pItensDANFE($x, $y + 1, $nInicial, $hDispo2, $n, $totPag, $hCabecItens);
778 772
             //coloca o rodapé da página
779 773
             if ($this->orientacao == 'P') {
780 774
                 $this->pRodape($xInic, $y + 4);
@@ -787,7 +781,7 @@  discard block
 block discarded – undo
787 781
             }
788 782
         }
789 783
         //retorna o ID na NFe
790
-        if ($classPdf!==false) {
784
+        if ($classPdf !== false) {
791 785
             $aR = array(
792 786
              'id'=>str_replace('NFe', '', $this->infNFe->getAttribute("Id")),
793 787
              'classe_PDF'=>$this->pdf);
@@ -820,7 +814,7 @@  discard block
 block discarded – undo
820 814
         if ($startPos === false) {
821 815
             return $cdata;
822 816
         }
823
-        for ($x=$len; $x>0; $x--) {
817
+        for ($x = $len; $x > 0; $x--) {
824 818
             if (substr($cdata, $x, 1) == '>') {
825 819
                 $endPos = $x;
826 820
                 break;
@@ -831,15 +825,15 @@  discard block
 block discarded – undo
831 825
         } else {
832 826
             $parte1 = '';
833 827
         }
834
-        $parte2 = substr($cdata, $startPos, $endPos-$startPos+1);
828
+        $parte2 = substr($cdata, $startPos, $endPos - $startPos + 1);
835 829
         if ($endPos < $len) {
836 830
             $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
837 831
         } else {
838 832
             $parte3 = '';
839 833
         }
840
-        $texto = trim($parte1).' '.trim($parte3);
834
+        $texto = trim($parte1) . ' ' . trim($parte3);
841 835
         if (strpos($parte2, '<CDATA>') === false) {
842
-            $cdata = '<CDATA>'.$parte2.'</CDATA>';
836
+            $cdata = '<CDATA>' . $parte2 . '</CDATA>';
843 837
         } else {
844 838
             $cdata = $parte2;
845 839
         }
@@ -913,15 +907,15 @@  discard block
 block discarded – undo
913 907
         //grupo CADATA infCpl
914 908
         $t = $dom->getElementsByTagName('transmissor')->item(0);
915 909
         $r = $dom->getElementsByTagName('receptor')->item(0);
916
-        $versao = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
917
-            'Versao:'.$dom->getElementsByTagName('versao')->item(0)->nodeValue.' ' : '';
918
-        $especieNF = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
919
-            'Especie:'.$dom->getElementsByTagName('especieNF')->item(0)->nodeValue.' ' : '';
920
-        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
921
-            'Entrega:'.$dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue.' ' : '';
922
-        $dca = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
923
-            'dca:'.$dom->getElementsByTagName('dca')->item(0)->nodeValue.' ' : '';
924
-        $texto .= "".$versao.$especieNF.$fabEntrega.$dca;
910
+        $versao = !empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
911
+            'Versao:' . $dom->getElementsByTagName('versao')->item(0)->nodeValue . ' ' : '';
912
+        $especieNF = !empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
913
+            'Especie:' . $dom->getElementsByTagName('especieNF')->item(0)->nodeValue . ' ' : '';
914
+        $fabEntrega = !empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
915
+            'Entrega:' . $dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue . ' ' : '';
916
+        $dca = !empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
917
+            'dca:' . $dom->getElementsByTagName('dca')->item(0)->nodeValue . ' ' : '';
918
+        $texto .= "" . $versao . $especieNF . $fabEntrega . $dca;
925 919
         if (isset($t)) {
926 920
             if ($t->hasAttributes()) {
927 921
                 $texto .= " Transmissor ";
@@ -1011,14 +1005,14 @@  discard block
 block discarded – undo
1011 1005
         }
1012 1006
         //####################################################################################
1013 1007
         //coluna esquerda identificação do emitente
1014
-        $w = round($maxW*0.41, 0);
1008
+        $w = round($maxW * 0.41, 0);
1015 1009
         if ($this->orientacao == 'P') {
1016 1010
             $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I');
1017 1011
         } else {
1018 1012
             $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
1019 1013
         }
1020 1014
         $w1 = $w;
1021
-        $h=32;
1015
+        $h = 32;
1022 1016
         $oldY += $h;
1023 1017
         $this->pTextBox($x, $y, $w, $h);
1024 1018
         $texto = 'IDENTIFICAÇÃO DO EMITENTE';
@@ -1032,41 +1026,41 @@  discard block
 block discarded – undo
1032 1026
         //se não houver logo centraliza dos dados do emitente
1033 1027
         // coloca o logo
1034 1028
         if (is_file($this->logomarca)) {
1035
-            $logoInfo=getimagesize($this->logomarca);
1029
+            $logoInfo = getimagesize($this->logomarca);
1036 1030
             //largura da imagem em mm
1037
-            $logoWmm = ($logoInfo[0]/72)*25.4;
1031
+            $logoWmm = ($logoInfo[0] / 72) * 25.4;
1038 1032
             //altura da imagem em mm
1039
-            $logoHmm = ($logoInfo[1]/72)*25.4;
1040
-            if ($this->logoAlign=='L') {
1041
-                $nImgW = round($w/3, 0);
1042
-                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
1043
-                $xImg = $x+1;
1044
-                $yImg = round(($h-$nImgH)/2, 0)+$y;
1033
+            $logoHmm = ($logoInfo[1] / 72) * 25.4;
1034
+            if ($this->logoAlign == 'L') {
1035
+                $nImgW = round($w / 3, 0);
1036
+                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
1037
+                $xImg = $x + 1;
1038
+                $yImg = round(($h - $nImgH) / 2, 0) + $y;
1045 1039
                 //estabelecer posições do texto
1046
-                $x1 = round($xImg + $nImgW +1, 0);
1047
-                $y1 = round($h/3+$y, 0);
1048
-                $tw = round(2*$w/3, 0);
1049
-            } elseif ($this->logoAlign=='C') {
1050
-                $nImgH = round($h/3, 0);
1051
-                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
1052
-                $xImg = round(($w-$nImgW)/2+$x, 0);
1053
-                $yImg = $y+3;
1040
+                $x1 = round($xImg + $nImgW + 1, 0);
1041
+                $y1 = round($h / 3 + $y, 0);
1042
+                $tw = round(2 * $w / 3, 0);
1043
+            } elseif ($this->logoAlign == 'C') {
1044
+                $nImgH = round($h / 3, 0);
1045
+                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
1046
+                $xImg = round(($w - $nImgW) / 2 + $x, 0);
1047
+                $yImg = $y + 3;
1054 1048
                 $x1 = $x;
1055 1049
                 $y1 = round($yImg + $nImgH + 1, 0);
1056 1050
                 $tw = $w;
1057
-            } elseif ($this->logoAlign=='R') {
1058
-                $nImgW = round($w/3, 0);
1059
-                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
1060
-                $xImg = round($x+($w-(1+$nImgW)), 0);
1061
-                $yImg = round(($h-$nImgH)/2, 0)+$y;
1051
+            } elseif ($this->logoAlign == 'R') {
1052
+                $nImgW = round($w / 3, 0);
1053
+                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
1054
+                $xImg = round($x + ($w - (1 + $nImgW)), 0);
1055
+                $yImg = round(($h - $nImgH) / 2, 0) + $y;
1062 1056
                 $x1 = $x;
1063
-                $y1 = round($h/3+$y, 0);
1064
-                $tw = round(2*$w/3, 0);
1065
-            } elseif ($this->logoAlign=='F') {
1066
-                $nImgH = round($h-5, 0);
1067
-                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
1068
-                $xImg = round(($w-$nImgW)/2+$x, 0);
1069
-                $yImg = $y+3;
1057
+                $y1 = round($h / 3 + $y, 0);
1058
+                $tw = round(2 * $w / 3, 0);
1059
+            } elseif ($this->logoAlign == 'F') {
1060
+                $nImgH = round($h - 5, 0);
1061
+                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
1062
+                $xImg = round(($w - $nImgW) / 2 + $x, 0);
1063
+                $yImg = $y + 3;
1070 1064
                 $x1 = $x;
1071 1065
                 $y1 = round($yImg + $nImgH + 1, 0);
1072 1066
                 $tw = $w;
@@ -1074,7 +1068,7 @@  discard block
 block discarded – undo
1074 1068
             $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH);
1075 1069
         } else {
1076 1070
             $x1 = $x;
1077
-            $y1 = round($h/3+$y, 0);
1071
+            $y1 = round($h / 3 + $y, 0);
1078 1072
             $tw = $w;
1079 1073
         }
1080 1074
         // monta as informações apenas se diferente de full logo
@@ -1084,9 +1078,9 @@  discard block
 block discarded – undo
1084 1078
             $texto = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue;
1085 1079
             $this->pTextBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
1086 1080
             //endereço
1087
-            $y1 = $y1+5;
1081
+            $y1 = $y1 + 5;
1088 1082
             $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
1089
-            $fone = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue)
1083
+            $fone = !empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue)
1090 1084
                  ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue
1091 1085
                  : '';
1092 1086
             $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
@@ -1106,37 +1100,37 @@  discard block
 block discarded – undo
1106 1100
         //####################################################################################
1107 1101
         //coluna central Danfe
1108 1102
         $x += $w;
1109
-        $w=round($maxW * 0.17, 0);//35;
1103
+        $w = round($maxW * 0.17, 0); //35;
1110 1104
         $w2 = $w;
1111 1105
         $h = 32;
1112 1106
         $this->pTextBox($x, $y, $w, $h);
1113 1107
 
1114
-        if (! $this->pNotaCancelada()) {
1108
+        if (!$this->pNotaCancelada()) {
1115 1109
             // A PRINCIPIO NÃO PRECISAVA, POIS A NFE ESTÁ AUTORIZADA,
1116 1110
             // SÓ SE RETIRA O DANFE PARA NOTAS NÃO AUTORIZADAS
1117 1111
             $texto = "DANFE";
1118 1112
             $aFont = array('font'=>$this->fontePadrao, 'size'=>14, 'style'=>'B');
1119
-            $this->pTextBox($x, $y+1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
1113
+            $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
1120 1114
             $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
1121 1115
             $texto = 'Documento Auxiliar da Nota Fiscal Eletrônica';
1122 1116
             $h = 20;
1123
-            $this->pTextBox($x, $y+6, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
1117
+            $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
1124 1118
         }
1125 1119
 
1126 1120
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
1127 1121
         $texto = '0 - ENTRADA';
1128 1122
         $y1 = $y + 14;
1129 1123
         $h = 8;
1130
-        $this->pTextBox($x+2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1124
+        $this->pTextBox($x + 2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1131 1125
         $texto = '1 - SAÍDA';
1132 1126
         $y1 = $y + 17;
1133
-        $this->pTextBox($x+2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1127
+        $this->pTextBox($x + 2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1134 1128
         //tipo de nF
1135 1129
         $aFont = array('font'=>$this->fontePadrao, 'size'=>12, 'style'=>'B');
1136 1130
         $y1 = $y + 13;
1137 1131
         $h = 7;
1138 1132
         $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
1139
-        $this->pTextBox($x+27, $y1, 5, $h, $texto, $aFont, 'C', 'C', 1, '');
1133
+        $this->pTextBox($x + 27, $y1, 5, $h, $texto, $aFont, 'C', 'C', 1, '');
1140 1134
         //numero da NF
1141 1135
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1142 1136
         $y1 = $y + 20;
@@ -1158,7 +1152,7 @@  discard block
 block discarded – undo
1158 1152
         //####################################################################################
1159 1153
         //coluna codigo de barras
1160 1154
         $x += $w;
1161
-        $w = ($maxW-$w1-$w2);//85;
1155
+        $w = ($maxW - $w1 - $w2); //85;
1162 1156
         $w3 = $w;
1163 1157
         $h = 32;
1164 1158
         $this->pTextBox($x, $y, $w, $h);
@@ -1167,22 +1161,22 @@  discard block
 block discarded – undo
1167 1161
         $bW = 75;
1168 1162
         $bH = 12;
1169 1163
         //codigo de barras
1170
-        $this->pdf->Code128($x+(($w-$bW)/2), $y+2, $chave_acesso, $bW, $bH);
1164
+        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
1171 1165
         //linhas divisorias
1172
-        $this->pdf->Line($x, $y+4+$bH, $x+$w, $y+4+$bH);
1173
-        $this->pdf->Line($x, $y+12+$bH, $x+$w, $y+12+$bH);
1166
+        $this->pdf->Line($x, $y + 4 + $bH, $x + $w, $y + 4 + $bH);
1167
+        $this->pdf->Line($x, $y + 12 + $bH, $x + $w, $y + 12 + $bH);
1174 1168
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1175
-        $y1 = $y+4+$bH;
1169
+        $y1 = $y + 4 + $bH;
1176 1170
         $h = 7;
1177 1171
         $texto = 'CHAVE DE ACESSO';
1178 1172
         $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1179 1173
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
1180
-        $y1 = $y+8+$bH;
1174
+        $y1 = $y + 8 + $bH;
1181 1175
         $texto = $this->pFormat($chave_acesso, $this->formatoChave);
1182
-        $this->pTextBox($x+2, $y1, $w-2, $h, $texto, $aFont, 'T', 'C', 0, '');
1183
-        $y1 = $y+12+$bH;
1176
+        $this->pTextBox($x + 2, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, '');
1177
+        $y1 = $y + 12 + $bH;
1184 1178
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
1185
-        $chaveContingencia="";
1179
+        $chaveContingencia = "";
1186 1180
         if ($this->pNotaDPEC()) {
1187 1181
             $cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO DPEC';
1188 1182
         } else {
@@ -1193,16 +1187,16 @@  discard block
 block discarded – undo
1193 1187
             $chaveContingencia = $this->pGeraChaveAdicionalDeContingencia();
1194 1188
             $this->pdf->SetFillColor(0, 0, 0);
1195 1189
             //codigo de barras
1196
-            $this->pdf->Code128($x+11, $y1+1, $chaveContingencia, $bW*.9, $bH/2);
1190
+            $this->pdf->Code128($x + 11, $y1 + 1, $chaveContingencia, $bW * .9, $bH / 2);
1197 1191
         } else {
1198 1192
             $texto = 'Consulta de autenticidade no portal nacional da NF-e';
1199
-            $this->pTextBox($x+2, $y1, $w-2, $h, $texto, $aFont, 'T', 'C', 0, '');
1200
-            $y1 = $y+16+$bH;
1193
+            $this->pTextBox($x + 2, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, '');
1194
+            $y1 = $y + 16 + $bH;
1201 1195
             $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora';
1202 1196
             $this->pTextBox(
1203
-                $x+2,
1197
+                $x + 2,
1204 1198
                 $y1,
1205
-                $w-2,
1199
+                $w - 2,
1206 1200
                 $h,
1207 1201
                 $texto,
1208 1202
                 $aFont,
@@ -1218,7 +1212,7 @@  discard block
 block discarded – undo
1218 1212
         //natureza da operação
1219 1213
         $texto = 'NATUREZA DA OPERAÇÃO';
1220 1214
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1221
-        $w = $w1+$w2;
1215
+        $w = $w1 + $w2;
1222 1216
         $y = $oldY;
1223 1217
         $oldY += $h;
1224 1218
         $x = $oldX;
@@ -1248,7 +1242,7 @@  discard block
 block discarded – undo
1248 1242
                 $cStat = '';
1249 1243
             } else {
1250 1244
                 if (isset($this->nfeProc)) {
1251
-                    $texto = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ?
1245
+                    $texto = !empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ?
1252 1246
                             $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue : '';
1253 1247
                     $tsHora = $this->pConvertTime($this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue);
1254 1248
                     if ($texto != '') {
@@ -1279,25 +1273,25 @@  discard block
 block discarded – undo
1279 1273
         $texto = 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.';
1280 1274
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1281 1275
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1282
-        $texto = ! empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue)
1276
+        $texto = !empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue)
1283 1277
              ? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue
1284 1278
              : '';
1285 1279
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1286 1280
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1287 1281
         //CNPJ
1288 1282
         $x += $w;
1289
-        $w = ($maxW-(2*$w));
1283
+        $w = ($maxW - (2 * $w));
1290 1284
         $texto = 'CNPJ / CPF';
1291 1285
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1292 1286
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1293 1287
         //Pegando valor do CPF/CNPJ
1294
-        if (! empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1288
+        if (!empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1295 1289
             $texto = $this->pFormat(
1296 1290
                 $this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1297 1291
                 "###.###.###/####-##"
1298 1292
             );
1299 1293
         } else {
1300
-            $texto = ! empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1294
+            $texto = !empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1301 1295
                 $this->pFormat(
1302 1296
                     $this->emit->getElementsByTagName("CPF")->item(0)->nodeValue,
1303 1297
                     "###.###.###-##"
@@ -1313,9 +1307,9 @@  discard block
 block discarded – undo
1313 1307
         if ($this->pNotaCancelada()) {
1314 1308
             //101 Cancelamento
1315 1309
             $x = 10;
1316
-            $y = $this->hPrint-130;
1310
+            $y = $this->hPrint - 130;
1317 1311
             $h = 25;
1318
-            $w = $maxW-(2*$x);
1312
+            $w = $maxW - (2 * $x);
1319 1313
             $this->pdf->SetTextColor(90, 90, 90);
1320 1314
             $texto = "NFe CANCELADA";
1321 1315
             $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
@@ -1326,12 +1320,12 @@  discard block
 block discarded – undo
1326 1320
         if ($this->pNotaDPEC() || $this->tpEmis == 4) {
1327 1321
             //DPEC
1328 1322
             $x = 10;
1329
-            $y = $this->hPrint-130;
1323
+            $y = $this->hPrint - 130;
1330 1324
             $h = 25;
1331
-            $w = $maxW-(2*$x);
1325
+            $w = $maxW - (2 * $x);
1332 1326
             $this->pdf->SetTextColor(200, 200, 200);
1333
-            $texto = "DANFE impresso em contingência -\n".
1334
-                     "DPEC regularmente recebido pela Receita\n".
1327
+            $texto = "DANFE impresso em contingência -\n" .
1328
+                     "DPEC regularmente recebido pela Receita\n" .
1335 1329
                      "Federal do Brasil";
1336 1330
             $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
1337 1331
             $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
@@ -1340,22 +1334,22 @@  discard block
 block discarded – undo
1340 1334
         if ($this->pNotaDenegada()) {
1341 1335
             //110 301 302 Denegada
1342 1336
             $x = 10;
1343
-            $y = $this->hPrint-130;
1337
+            $y = $this->hPrint - 130;
1344 1338
             $h = 25;
1345
-            $w = $maxW-(2*$x);
1339
+            $w = $maxW - (2 * $x);
1346 1340
             $this->pdf->SetTextColor(90, 90, 90);
1347 1341
             $texto = "NFe USO DENEGADO";
1348 1342
             $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
1349 1343
             $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1350 1344
             $y += $h;
1351 1345
             $h = 5;
1352
-            $w = $maxW-(2*$x);
1346
+            $w = $maxW - (2 * $x);
1353 1347
             if (isset($this->infProt)) {
1354 1348
                 $xMotivo = $this->infProt->getElementsByTagName("xMotivo")->item(0)->nodeValue;
1355 1349
             } else {
1356 1350
                 $xMotivo = '';
1357 1351
             }
1358
-            $texto = "SEM VALOR FISCAL\n".$xMotivo;
1352
+            $texto = "SEM VALOR FISCAL\n" . $xMotivo;
1359 1353
             $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
1360 1354
             $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1361 1355
             $this->pdf->SetTextColor(0, 0, 0);
@@ -1364,29 +1358,29 @@  discard block
 block discarded – undo
1364 1358
         if ($tpAmb != 1) {
1365 1359
             $x = 10;
1366 1360
             if ($this->orientacao == 'P') {
1367
-                $y = round($this->hPrint*2/3, 0);
1361
+                $y = round($this->hPrint * 2 / 3, 0);
1368 1362
             } else {
1369
-                $y = round($this->hPrint/2, 0);
1363
+                $y = round($this->hPrint / 2, 0);
1370 1364
             }
1371 1365
             $h = 5;
1372
-            $w = $maxW-(2*$x);
1366
+            $w = $maxW - (2 * $x);
1373 1367
             $this->pdf->SetTextColor(90, 90, 90);
1374 1368
             $texto = "SEM VALOR FISCAL";
1375 1369
             $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
1376 1370
             $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1377 1371
             $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
1378 1372
             $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1379
-            $this->pTextBox($x, $y+14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1373
+            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1380 1374
             $this->pdf->SetTextColor(0, 0, 0);
1381 1375
         } else {
1382 1376
             $x = 10;
1383 1377
             if ($this->orientacao == 'P') {
1384
-                $y = round($this->hPrint*2/3, 0);
1378
+                $y = round($this->hPrint * 2 / 3, 0);
1385 1379
             } else {
1386
-                $y = round($this->hPrint/2, 0);
1380
+                $y = round($this->hPrint / 2, 0);
1387 1381
             }//fim orientacao
1388 1382
             $h = 5;
1389
-            $w = $maxW-(2*$x);
1383
+            $w = $maxW - (2 * $x);
1390 1384
             $this->pdf->SetTextColor(90, 90, 90);
1391 1385
             //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1392 1386
             if (($this->tpEmis == 2 || $this->tpEmis == 5) && !$this->pNotaDPEC()) {
@@ -1396,7 +1390,7 @@  discard block
 block discarded – undo
1396 1390
                 $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1397 1391
                 $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
1398 1392
                 $texto = "devido à problemas técnicos";
1399
-                $this->pTextBox($x, $y+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1393
+                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1400 1394
             } else {
1401 1395
                 if (!isset($this->nfeProc)) {
1402 1396
                     if (!$this->pNotaDPEC()) {
@@ -1407,9 +1401,9 @@  discard block
 block discarded – undo
1407 1401
                     $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
1408 1402
                     $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1409 1403
                     if (!$this->pNotaDPEC()) {
1410
-                        $this->pTextBox($x, $y+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1404
+                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1411 1405
                     } else {
1412
-                        $this->pTextBox($x, $y+25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1406
+                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1413 1407
                     }
1414 1408
                 }//fim nefProc
1415 1409
             }//fim tpEmis
@@ -1444,7 +1438,7 @@  discard block
 block discarded – undo
1444 1438
         $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
1445 1439
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1446 1440
         //NOME / RAZÃO SOCIAL
1447
-        $w = round($maxW*0.61, 0);
1441
+        $w = round($maxW * 0.61, 0);
1448 1442
         $w1 = $w;
1449 1443
         $y += 3;
1450 1444
         $texto = 'NOME / RAZÃO SOCIAL';
@@ -1459,19 +1453,19 @@  discard block
 block discarded – undo
1459 1453
         }
1460 1454
         //CNPJ / CPF
1461 1455
         $x += $w;
1462
-        $w = round($maxW*0.23, 0);
1456
+        $w = round($maxW * 0.23, 0);
1463 1457
         $w2 = $w;
1464 1458
         $texto = 'CNPJ / CPF';
1465 1459
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1466 1460
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1467 1461
         //Pegando valor do CPF/CNPJ
1468
-        if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1462
+        if (!empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1469 1463
             $texto = $this->pFormat(
1470 1464
                 $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1471 1465
                 "###.###.###/####-##"
1472 1466
             );
1473 1467
         } else {
1474
-            $texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1468
+            $texto = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1475 1469
                     $this->pFormat(
1476 1470
                         $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue,
1477 1471
                         "###.###.###-##"
@@ -1481,15 +1475,15 @@  discard block
 block discarded – undo
1481 1475
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1482 1476
         //DATA DA EMISSÃO
1483 1477
         $x += $w;
1484
-        $w = $maxW-($w1+$w2);
1478
+        $w = $maxW - ($w1 + $w2);
1485 1479
         $wx = $w;
1486 1480
         $texto = 'DATA DA EMISSÃO';
1487 1481
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1488 1482
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1489
-        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
1483
+        $dEmi = !empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
1490 1484
                 $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
1491 1485
         if ($dEmi == '') {
1492
-            $dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
1486
+            $dEmi = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
1493 1487
                     $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
1494 1488
             $aDemi = explode('T', $dEmi);
1495 1489
             $dEmi = $aDemi[0];
@@ -1502,7 +1496,7 @@  discard block
 block discarded – undo
1502 1496
             $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, '');
1503 1497
         }
1504 1498
         //ENDEREÇO
1505
-        $w = round($maxW*0.47, 0);
1499
+        $w = round($maxW * 0.47, 0);
1506 1500
         $w1 = $w;
1507 1501
         $y += $h;
1508 1502
         $x = $oldX;
@@ -1517,7 +1511,7 @@  discard block
 block discarded – undo
1517 1511
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true);
1518 1512
         //BAIRRO / DISTRITO
1519 1513
         $x += $w;
1520
-        $w = round($maxW*0.21, 0);
1514
+        $w = round($maxW * 0.21, 0);
1521 1515
         $w2 = $w;
1522 1516
         $texto = 'BAIRRO / DISTRITO';
1523 1517
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
@@ -1527,12 +1521,12 @@  discard block
 block discarded – undo
1527 1521
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1528 1522
         //CEP
1529 1523
         $x += $w;
1530
-        $w = $maxW-$w1-$w2-$wx;
1524
+        $w = $maxW - $w1 - $w2 - $wx;
1531 1525
         $w2 = $w;
1532 1526
         $texto = 'CEP';
1533 1527
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1534 1528
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1535
-        $texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1529
+        $texto = !empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1536 1530
                 $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1537 1531
         $texto = $this->pFormat($texto, "#####-###");
1538 1532
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
@@ -1543,10 +1537,10 @@  discard block
 block discarded – undo
1543 1537
         $texto = 'DATA DA SAÍDA/ENTRADA';
1544 1538
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1545 1539
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1546
-        $dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue) ?
1540
+        $dSaiEnt = !empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue) ?
1547 1541
                 $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue : '';
1548 1542
         if ($dSaiEnt == '') {
1549
-            $dSaiEnt = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue) ?
1543
+            $dSaiEnt = !empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue) ?
1550 1544
                     $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue : '';
1551 1545
             $aDsaient = explode('T', $dSaiEnt);
1552 1546
             $dSaiEnt = $aDsaient[0];
@@ -1563,7 +1557,7 @@  discard block
 block discarded – undo
1563 1557
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1564 1558
         $texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue;
1565 1559
         if (strtoupper(trim($texto)) == "EXTERIOR" && $this->dest->getElementsByTagName("xPais")->length > 0) {
1566
-            $texto .= " - " .  $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue;
1560
+            $texto .= " - " . $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue;
1567 1561
         }
1568 1562
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1569 1563
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
@@ -1578,18 +1572,18 @@  discard block
 block discarded – undo
1578 1572
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1579 1573
         //FONE / FAX
1580 1574
         $x += $w;
1581
-        $w = round(($maxW -$w1-$wx-8)/2, 0);
1575
+        $w = round(($maxW - $w1 - $wx - 8) / 2, 0);
1582 1576
         $w3 = $w;
1583 1577
         $texto = 'FONE / FAX';
1584 1578
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1585 1579
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1586
-        $texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue) ?
1580
+        $texto = !empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue) ?
1587 1581
                 $this->dest->getElementsByTagName("fone")->item(0)->nodeValue : '';
1588 1582
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1589 1583
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1590 1584
         //INSCRIÇÃO ESTADUAL
1591 1585
         $x += $w;
1592
-        $w = $maxW -$w1-$wx-8-$w3;
1586
+        $w = $maxW - $w1 - $wx - 8 - $w3;
1593 1587
         $texto = 'INSCRIÇÃO ESTADUAL';
1594 1588
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1595 1589
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
@@ -1603,10 +1597,10 @@  discard block
 block discarded – undo
1603 1597
         $texto = 'HORA DA SAÍDA/ENTRADA';
1604 1598
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1605 1599
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1606
-        $hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue) ?
1600
+        $hSaiEnt = !empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue) ?
1607 1601
                 $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue : '';
1608 1602
         if ($hSaiEnt == '') {
1609
-            $dhSaiEnt = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue) ?
1603
+            $dhSaiEnt = !empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue) ?
1610 1604
                     $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue : '';
1611 1605
             $tsDhSaiEnt = $this->pConvertTime($dhSaiEnt);
1612 1606
             if ($tsDhSaiEnt != '') {
@@ -1631,7 +1625,7 @@  discard block
 block discarded – undo
1631 1625
         if (isset($this->cobr)) {
1632 1626
             $fat = $this->cobr->getElementsByTagName("fat")->item(0);
1633 1627
             if (isset($fat)) {
1634
-                $textoIndPag="";
1628
+                $textoIndPag = "";
1635 1629
                 $indPag = $this->pSimpleGetValue($this->ide, "indPag");
1636 1630
                 if ($indPag === "0") {
1637 1631
                     $textoIndPag = "Pagamento à Vista - ";
@@ -1678,7 +1672,7 @@  discard block
 block discarded – undo
1678 1672
     protected function pFaturaDANFE($x, $y)
1679 1673
     {
1680 1674
         $linha = 1;
1681
-        $h = 8+3;
1675
+        $h = 8 + 3;
1682 1676
         $oldx = $x;
1683 1677
         $textoFatura = $this->pGetTextoFatura();
1684 1678
         //verificar se existem duplicatas
@@ -1699,27 +1693,27 @@  discard block
 block discarded – undo
1699 1693
             $dupcont = 0;
1700 1694
             $nFat = $this->dup->length;
1701 1695
             if ($textoFatura !== "" && $this->exibirTextoFatura) {
1702
-                $myH=6;
1696
+                $myH = 6;
1703 1697
                 $myW = $this->wPrint;
1704 1698
                 if ($this->orientacao == 'L') {
1705 1699
                     $myW -= $this->wCanhoto;
1706 1700
                 }
1707 1701
                 $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
1708 1702
                 $this->pTextBox($x, $y, $myW, $myH, $textoFatura, $aFont, 'C', 'L', 1, '');
1709
-                $y+=$myH+1;
1703
+                $y += $myH + 1;
1710 1704
             }
1711 1705
             if ($this->orientacao == 'P') {
1712
-                $w = round($this->wPrint/7.018, 0)-1;
1706
+                $w = round($this->wPrint / 7.018, 0) - 1;
1713 1707
             } else {
1714 1708
                 $w = 28;
1715 1709
             }
1716 1710
             $increm = 1;
1717 1711
             foreach ($this->dup as $k => $d) {
1718
-                $nDup = ! empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue) ?
1712
+                $nDup = !empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue) ?
1719 1713
                         $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue : '';
1720
-                $dDup = ! empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue) ?
1714
+                $dDup = !empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue) ?
1721 1715
                         $this->pYmd2dmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue) : '';
1722
-                $vDup = ! empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue) ?
1716
+                $vDup = !empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue) ?
1723 1717
                         'R$ ' . number_format(
1724 1718
                             $this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue,
1725 1719
                             2,
@@ -1728,14 +1722,14 @@  discard block
 block discarded – undo
1728 1722
                         ) : '';
1729 1723
                 $h = 8;
1730 1724
                 $texto = '';
1731
-                if ($nDup!='0' && $nDup!='') {
1725
+                if ($nDup != '0' && $nDup != '') {
1732 1726
                     $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1733 1727
                     $this->pTextBox($x, $y, $w, $h, 'Num.', $aFont, 'T', 'L', 1, '');
1734 1728
                     $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
1735 1729
                     $this->pTextBox($x, $y, $w, $h, $nDup, $aFont, 'T', 'R', 0, '');
1736 1730
                 } else {
1737 1731
                     $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1738
-                    $this->pTextBox($x, $y, $w, $h, ($dupcont+1)."", $aFont, 'T', 'L', 1, '');
1732
+                    $this->pTextBox($x, $y, $w, $h, ($dupcont + 1) . "", $aFont, 'T', 'L', 1, '');
1739 1733
                 }
1740 1734
                 $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1741 1735
                 $this->pTextBox($x, $y, $w, $h, 'Venc.', $aFont, 'C', 'L', 0, '');
@@ -1745,7 +1739,7 @@  discard block
 block discarded – undo
1745 1739
                 $this->pTextBox($x, $y, $w, $h, 'Valor', $aFont, 'B', 'L', 0, '');
1746 1740
                 $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
1747 1741
                 $this->pTextBox($x, $y, $w, $h, $vDup, $aFont, 'B', 'R', 0, '');
1748
-                $x += $w+$increm;
1742
+                $x += $w + $increm;
1749 1743
                 $dupcont += 1;
1750 1744
                 if ($this->orientacao == 'P') {
1751 1745
                     $maxDupCont = 6;
@@ -1767,10 +1761,10 @@  discard block
 block discarded – undo
1767 1761
                 $y -= 9;
1768 1762
                 $linha--;
1769 1763
             }
1770
-            return ($y+$h);
1764
+            return ($y + $h);
1771 1765
         } else {
1772 1766
             $linha = 0;
1773
-            return ($y-2);
1767
+            return ($y - 2);
1774 1768
         }
1775 1769
     } //fim da função faturaDANFE
1776 1770
 
@@ -1882,7 +1876,7 @@  discard block
 block discarded – undo
1882 1876
         }
1883 1877
         $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "V. TOTAL DA NOTA", "vNF");
1884 1878
 
1885
-        return ($y+$h);
1879
+        return ($y + $h);
1886 1880
     } //fim impostoDANFE
1887 1881
 
1888 1882
     /**
@@ -1910,13 +1904,13 @@  discard block
 block discarded – undo
1910 1904
         $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
1911 1905
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1912 1906
         //NOME / RAZÃO SOCIAL
1913
-        $w1 = $maxW*0.29;
1907
+        $w1 = $maxW * 0.29;
1914 1908
         $y += 3;
1915 1909
         $texto = 'NOME / RAZÃO SOCIAL';
1916 1910
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1917 1911
         $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, '');
1918 1912
         if (isset($this->transporta)) {
1919
-            $texto = ! empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue) ?
1913
+            $texto = !empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue) ?
1920 1914
                     $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue : '';
1921 1915
         } else {
1922 1916
             $texto = '';
@@ -1925,11 +1919,11 @@  discard block
 block discarded – undo
1925 1919
         $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, '');
1926 1920
         //FRETE POR CONTA
1927 1921
         $x += $w1;
1928
-        $w2 = $maxW*0.15;
1922
+        $w2 = $maxW * 0.15;
1929 1923
         $texto = 'FRETE POR CONTA';
1930 1924
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1931 1925
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
1932
-        $tipoFrete = ! empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue) ?
1926
+        $tipoFrete = !empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue) ?
1933 1927
                 $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue : '0';
1934 1928
         switch ($tipoFrete) {
1935 1929
             case 0:
@@ -1953,7 +1947,7 @@  discard block
 block discarded – undo
1953 1947
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1954 1948
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
1955 1949
         if (isset($this->veicTransp)) {
1956
-            $texto = ! empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue) ?
1950
+            $texto = !empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue) ?
1957 1951
                     $this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue : '';
1958 1952
         } else {
1959 1953
             $texto = '';
@@ -1966,10 +1960,10 @@  discard block
 block discarded – undo
1966 1960
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1967 1961
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
1968 1962
         if (isset($this->veicTransp)) {
1969
-            $texto = ! empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue) ?
1963
+            $texto = !empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue) ?
1970 1964
                     $this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue : '';
1971 1965
         } elseif (isset($this->reboque)) {
1972
-            $texto = ! empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue) ?
1966
+            $texto = !empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue) ?
1973 1967
                     $this->reboque->getElementsByTagName("placa")->item(0)->nodeValue : '';
1974 1968
         } else {
1975 1969
             $texto = '';
@@ -1978,15 +1972,15 @@  discard block
 block discarded – undo
1978 1972
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
1979 1973
         //UF
1980 1974
         $x += $w2;
1981
-        $w3 = round($maxW*0.04, 0);
1975
+        $w3 = round($maxW * 0.04, 0);
1982 1976
         $texto = 'UF';
1983 1977
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1984 1978
         $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, '');
1985 1979
         if (isset($this->veicTransp)) {
1986
-            $texto = ! empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue) ?
1980
+            $texto = !empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue) ?
1987 1981
                     $this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue : '';
1988 1982
         } elseif (isset($this->reboque)) {
1989
-            $texto = ! empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue) ?
1983
+            $texto = !empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue) ?
1990 1984
                     $this->reboque->getElementsByTagName("UF")->item(0)->nodeValue : '';
1991 1985
         } else {
1992 1986
             $texto = '';
@@ -1995,18 +1989,18 @@  discard block
 block discarded – undo
1995 1989
         $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, '');
1996 1990
         //CNPJ / CPF
1997 1991
         $x += $w3;
1998
-        $w = $maxW-($w1+3*$w2+$w3);
1992
+        $w = $maxW - ($w1 + 3 * $w2 + $w3);
1999 1993
         $texto = 'CNPJ / CPF';
2000 1994
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2001 1995
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
2002 1996
         if (isset($this->transporta)) {
2003
-            $texto = ! empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
1997
+            $texto = !empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
2004 1998
                     $this->pFormat(
2005 1999
                         $this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,
2006 2000
                         "##.###.###/####-##"
2007 2001
                     ) : '';
2008 2002
             if ($texto == '') {
2009
-                $texto = ! empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue) ?
2003
+                $texto = !empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue) ?
2010 2004
                         $this->pFormat(
2011 2005
                             $this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue,
2012 2006
                             "###.###.###-##"
@@ -2022,12 +2016,12 @@  discard block
 block discarded – undo
2022 2016
         $y += $h;
2023 2017
         $x = $oldX;
2024 2018
         $h = 7;
2025
-        $w1 = $maxW*0.44;
2019
+        $w1 = $maxW * 0.44;
2026 2020
         $texto = 'ENDEREÇO';
2027 2021
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2028 2022
         $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, '');
2029 2023
         if (isset($this->transporta)) {
2030
-            $texto = ! empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) ?
2024
+            $texto = !empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) ?
2031 2025
                     $this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue : '';
2032 2026
         } else {
2033 2027
             $texto = '';
@@ -2036,12 +2030,12 @@  discard block
 block discarded – undo
2036 2030
         $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, '');
2037 2031
         //MUNICÍPIO
2038 2032
         $x += $w1;
2039
-        $w2 = round($maxW*0.30, 0);
2033
+        $w2 = round($maxW * 0.30, 0);
2040 2034
         $texto = 'MUNICÍPIO';
2041 2035
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2042 2036
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
2043 2037
         if (isset($this->transporta)) {
2044
-            $texto = ! empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue) ?
2038
+            $texto = !empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue) ?
2045 2039
                     $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue : '';
2046 2040
         } else {
2047 2041
             $texto = '';
@@ -2050,12 +2044,12 @@  discard block
 block discarded – undo
2050 2044
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
2051 2045
         //UF
2052 2046
         $x += $w2;
2053
-        $w3 = round($maxW*0.04, 0);
2047
+        $w3 = round($maxW * 0.04, 0);
2054 2048
         $texto = 'UF';
2055 2049
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2056 2050
         $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, '');
2057 2051
         if (isset($this->transporta)) {
2058
-            $texto = ! empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) ?
2052
+            $texto = !empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) ?
2059 2053
                     $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue : '';
2060 2054
         } else {
2061 2055
             $texto = '';
@@ -2064,13 +2058,13 @@  discard block
 block discarded – undo
2064 2058
         $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, '');
2065 2059
         //INSCRIÇÃO ESTADUAL
2066 2060
         $x += $w3;
2067
-        $w = $maxW-($w1+$w2+$w3);
2061
+        $w = $maxW - ($w1 + $w2 + $w3);
2068 2062
         $texto = 'INSCRIÇÃO ESTADUAL';
2069 2063
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2070 2064
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
2071 2065
         $texto = '';
2072 2066
         if (isset($this->transporta)) {
2073
-            if (! empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) {
2067
+            if (!empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) {
2074 2068
                 $texto = $this->transporta->getElementsByTagName("IE")->item(0)->nodeValue;
2075 2069
             }
2076 2070
         }
@@ -2083,16 +2077,16 @@  discard block
 block discarded – undo
2083 2077
         $marca = '';
2084 2078
         $numero = '';
2085 2079
         $texto = '';
2086
-        $pesoBruto=0;
2087
-        $pesoLiquido=0;
2080
+        $pesoBruto = 0;
2081
+        $pesoLiquido = 0;
2088 2082
         foreach ($volumes as $volume) {
2089
-            $quantidade += ! empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ?
2083
+            $quantidade += !empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ?
2090 2084
                     $volume->getElementsByTagName("qVol")->item(0)->nodeValue : 0;
2091
-            $pesoBruto += ! empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ?
2085
+            $pesoBruto += !empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ?
2092 2086
                     $volume->getElementsByTagName("pesoB")->item(0)->nodeValue : 0;
2093
-            $pesoLiquido += ! empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ?
2087
+            $pesoLiquido += !empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ?
2094 2088
                     $volume->getElementsByTagName("pesoL")->item(0)->nodeValue : 0;
2095
-            $texto = ! empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ?
2089
+            $texto = !empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ?
2096 2090
                     $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : '';
2097 2091
             if ($texto != $especie && $especie != '') {
2098 2092
                 //tem várias especies
@@ -2100,7 +2094,7 @@  discard block
 block discarded – undo
2100 2094
             } else {
2101 2095
                 $especie = $texto;
2102 2096
             }
2103
-            $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2097
+            $texto = !empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2104 2098
                     $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : '';
2105 2099
             if ($texto != $marca && $marca != '') {
2106 2100
                 //tem várias especies
@@ -2108,7 +2102,7 @@  discard block
 block discarded – undo
2108 2102
             } else {
2109 2103
                 $marca = $texto;
2110 2104
             }
2111
-            $texto = ! empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue) ?
2105
+            $texto = !empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue) ?
2112 2106
                     $this->transp->getElementsByTagName("nVol")->item(0)->nodeValue : '';
2113 2107
             if ($texto != $numero && $numero != '') {
2114 2108
                 //tem várias especies
@@ -2123,7 +2117,7 @@  discard block
 block discarded – undo
2123 2117
         $y += $h;
2124 2118
         $x = $oldX;
2125 2119
         $h = 7;
2126
-        $w1 = round($maxW*0.10, 0);
2120
+        $w1 = round($maxW * 0.10, 0);
2127 2121
         $texto = 'QUANTIDADE';
2128 2122
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2129 2123
         $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, '');
@@ -2134,7 +2128,7 @@  discard block
 block discarded – undo
2134 2128
         }
2135 2129
         //ESPÉCIE
2136 2130
         $x += $w1;
2137
-        $w2 = round($maxW*0.17, 0);
2131
+        $w2 = round($maxW * 0.17, 0);
2138 2132
         $texto = 'ESPÉCIE';
2139 2133
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2140 2134
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
@@ -2146,7 +2140,7 @@  discard block
 block discarded – undo
2146 2140
         $texto = 'MARCA';
2147 2141
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2148 2142
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
2149
-        $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2143
+        $texto = !empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2150 2144
                 $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : '';
2151 2145
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
2152 2146
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
@@ -2160,7 +2154,7 @@  discard block
 block discarded – undo
2160 2154
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
2161 2155
         //PESO BRUTO
2162 2156
         $x += $w2;
2163
-        $w3 = round($maxW*0.20, 0);
2157
+        $w3 = round($maxW * 0.20, 0);
2164 2158
         $texto = 'PESO BRUTO';
2165 2159
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2166 2160
         $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, '');
@@ -2173,7 +2167,7 @@  discard block
 block discarded – undo
2173 2167
         $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'R', 0, '');
2174 2168
         //PESO LÍQUIDO
2175 2169
         $x += $w3;
2176
-        $w = $maxW -($w1+3*$w2+$w3);
2170
+        $w = $maxW - ($w1 + 3 * $w2 + $w3);
2177 2171
         $texto = 'PESO LÍQUIDO';
2178 2172
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2179 2173
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
@@ -2184,7 +2178,7 @@  discard block
 block discarded – undo
2184 2178
         }
2185 2179
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
2186 2180
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
2187
-        return ($y+$h);
2181
+        return ($y + $h);
2188 2182
     } //fim transporteDANFE
2189 2183
 
2190 2184
 
@@ -2196,7 +2190,7 @@  discard block
 block discarded – undo
2196 2190
             return "";
2197 2191
         }
2198 2192
         $valor_original = $valor_original->nodeValue;
2199
-        $valor = ! empty($valor_original) ? number_format($valor_original, 2, ",", ".") : '';
2193
+        $valor = !empty($valor_original) ? number_format($valor_original, 2, ",", ".") : '';
2200 2194
 
2201 2195
         if ($valor != "") {
2202 2196
             return sprintf($formato, $valor);
@@ -2234,13 +2228,13 @@  discard block
 block discarded – undo
2234 2228
             $impostos .= $this->pDescricaoProdutoHelper($ICMSUFDest, "vICMSUFDest", " vICMSUFDest=%s");
2235 2229
             $impostos .= $this->pDescricaoProdutoHelper($ICMSUFDest, "vICMSUFRemet", " vICMSUFRemet=%s");
2236 2230
         }
2237
-        $infAdProd = ! empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue) ?
2231
+        $infAdProd = !empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue) ?
2238 2232
                 substr($this->pAnfavea($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue), 0, 500) : '';
2239
-        if (! empty($infAdProd)) {
2233
+        if (!empty($infAdProd)) {
2240 2234
             $infAdProd = trim($infAdProd);
2241 2235
             $infAdProd .= ' ';
2242 2236
         }
2243
-        $medTxt='';
2237
+        $medTxt = '';
2244 2238
         $med = $prod->getElementsByTagName("med");
2245 2239
         if (isset($med)) {
2246 2240
             $i = 0;
@@ -2253,14 +2247,14 @@  discard block
 block discarded – undo
2253 2247
                 $i++;
2254 2248
             }
2255 2249
             if ($medTxt != '') {
2256
-                $medTxt.= ' ';
2250
+                $medTxt .= ' ';
2257 2251
             }
2258 2252
         }
2259 2253
         //NT2013.006 FCI
2260
-        $nFCI = (! empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ?
2261
-                ' FCI:'.$itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : '';
2262
-        $tmp_ad=$infAdProd . ($this->descProdInfoComplemento ? $medTxt . $impostos . $nFCI : '');
2263
-        $texto = $prod->getElementsByTagName("xProd")->item(0)->nodeValue . (strlen($tmp_ad)!=0?"\n    ".$tmp_ad:'');
2254
+        $nFCI = (!empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ?
2255
+                ' FCI:' . $itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : '';
2256
+        $tmp_ad = $infAdProd . ($this->descProdInfoComplemento ? $medTxt . $impostos . $nFCI : '');
2257
+        $texto = $prod->getElementsByTagName("xProd")->item(0)->nodeValue . (strlen($tmp_ad) != 0 ? "\n    " . $tmp_ad : '');
2264 2258
         if ($this->descProdQuebraLinha) {
2265 2259
             $texto = str_replace(";", "\n", $texto);
2266 2260
         }
@@ -2308,104 +2302,104 @@  discard block
 block discarded – undo
2308 2302
         // cabecalho LOOP COM OS DADOS DOS PRODUTOS
2309 2303
         //CÓDIGO PRODUTO
2310 2304
         $texto = "CÓDIGO PRODUTO";
2311
-        $w1 = round($w*0.09, 0);
2305
+        $w1 = round($w * 0.09, 0);
2312 2306
         $h = 4;
2313 2307
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2314 2308
         $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2315
-        $this->pdf->Line($x+$w1, $y, $x+$w1, $y+$hmax);
2309
+        $this->pdf->Line($x + $w1, $y, $x + $w1, $y + $hmax);
2316 2310
         //DESCRIÇÃO DO PRODUTO / SERVIÇO
2317 2311
         $x += $w1;
2318
-        $w2 = round($w*0.28, 0);
2312
+        $w2 = round($w * 0.28, 0);
2319 2313
         $texto = 'DESCRIÇÃO DO PRODUTO / SERVIÇO';
2320 2314
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2321 2315
         $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2322
-        $this->pdf->Line($x+$w2, $y, $x+$w2, $y+$hmax);
2316
+        $this->pdf->Line($x + $w2, $y, $x + $w2, $y + $hmax);
2323 2317
         //NCM/SH
2324 2318
         $x += $w2;
2325
-        $w3 = round($w*0.06, 0);
2319
+        $w3 = round($w * 0.06, 0);
2326 2320
         $texto = 'NCM/SH';
2327 2321
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2328 2322
         $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2329
-        $this->pdf->Line($x+$w3, $y, $x+$w3, $y+$hmax);
2323
+        $this->pdf->Line($x + $w3, $y, $x + $w3, $y + $hmax);
2330 2324
         //O/CST ou O/CSOSN
2331 2325
         $x += $w3;
2332
-        $w4 = round($w*0.05, 0);
2333
-        $texto = 'O/CSOSN';//Regime do Simples CRT = 1 ou CRT = 2
2326
+        $w4 = round($w * 0.05, 0);
2327
+        $texto = 'O/CSOSN'; //Regime do Simples CRT = 1 ou CRT = 2
2334 2328
         if ($this->pSimpleGetValue($this->emit, 'CRT') == '3') {
2335
-             $texto = 'O/CST';//Regime Normal
2329
+             $texto = 'O/CST'; //Regime Normal
2336 2330
         }
2337 2331
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2338 2332
         $this->pTextBox($x, $y, $w4, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2339
-        $this->pdf->Line($x+$w4, $y, $x+$w4, $y+$hmax);
2333
+        $this->pdf->Line($x + $w4, $y, $x + $w4, $y + $hmax);
2340 2334
         //CFOP
2341 2335
         $x += $w4;
2342
-        $w5 = round($w*0.04, 0);
2336
+        $w5 = round($w * 0.04, 0);
2343 2337
         $texto = 'CFOP';
2344 2338
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2345 2339
         $this->pTextBox($x, $y, $w5, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2346
-        $this->pdf->Line($x+$w5, $y, $x+$w5, $y+$hmax);
2340
+        $this->pdf->Line($x + $w5, $y, $x + $w5, $y + $hmax);
2347 2341
         //UN
2348 2342
         $x += $w5;
2349
-        $w6 = round($w*0.03, 0);
2343
+        $w6 = round($w * 0.03, 0);
2350 2344
         $texto = 'UN';
2351 2345
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2352 2346
         $this->pTextBox($x, $y, $w6, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2353
-        $this->pdf->Line($x+$w6, $y, $x+$w6, $y+$hmax);
2347
+        $this->pdf->Line($x + $w6, $y, $x + $w6, $y + $hmax);
2354 2348
         //QUANT
2355 2349
         $x += $w6;
2356
-        $w7 = round($w*0.07, 0);
2350
+        $w7 = round($w * 0.07, 0);
2357 2351
         $texto = 'QUANT';
2358 2352
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2359 2353
         $this->pTextBox($x, $y, $w7, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2360
-        $this->pdf->Line($x+$w7, $y, $x+$w7, $y+$hmax);
2354
+        $this->pdf->Line($x + $w7, $y, $x + $w7, $y + $hmax);
2361 2355
         //VALOR UNIT
2362 2356
         $x += $w7;
2363
-        $w8 = round($w*0.06, 0);
2357
+        $w8 = round($w * 0.06, 0);
2364 2358
         $texto = 'VALOR UNIT';
2365 2359
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2366 2360
         $this->pTextBox($x, $y, $w8, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2367
-        $this->pdf->Line($x+$w8, $y, $x+$w8, $y+$hmax);
2361
+        $this->pdf->Line($x + $w8, $y, $x + $w8, $y + $hmax);
2368 2362
         //VALOR TOTAL
2369 2363
         $x += $w8;
2370
-        $w9 = round($w*0.06, 0);
2364
+        $w9 = round($w * 0.06, 0);
2371 2365
         $texto = 'VALOR TOTAL';
2372 2366
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2373 2367
         $this->pTextBox($x, $y, $w9, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2374
-        $this->pdf->Line($x+$w9, $y, $x+$w9, $y+$hmax);
2368
+        $this->pdf->Line($x + $w9, $y, $x + $w9, $y + $hmax);
2375 2369
         //B.CÁLC ICMS
2376 2370
         $x += $w9;
2377
-        $w10 = round($w*0.06, 0);
2371
+        $w10 = round($w * 0.06, 0);
2378 2372
         $texto = 'B.CÁLC ICMS';
2379 2373
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2380 2374
         $this->pTextBox($x, $y, $w10, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2381
-        $this->pdf->Line($x+$w10, $y, $x+$w10, $y+$hmax);
2375
+        $this->pdf->Line($x + $w10, $y, $x + $w10, $y + $hmax);
2382 2376
         //VALOR ICMS
2383 2377
         $x += $w10;
2384
-        $w11 = round($w*0.06, 0);
2378
+        $w11 = round($w * 0.06, 0);
2385 2379
         $texto = 'VALOR ICMS';
2386 2380
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2387 2381
         $this->pTextBox($x, $y, $w11, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2388
-        $this->pdf->Line($x+$w11, $y, $x+$w11, $y+$hmax);
2382
+        $this->pdf->Line($x + $w11, $y, $x + $w11, $y + $hmax);
2389 2383
         //VALOR IPI
2390 2384
         $x += $w11;
2391
-        $w12 = round($w*0.05, 0);
2385
+        $w12 = round($w * 0.05, 0);
2392 2386
         $texto = 'VALOR IPI';
2393 2387
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2394 2388
         $this->pTextBox($x, $y, $w12, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2395
-        $this->pdf->Line($x+$w12, $y, $x+$w12, $y+$hmax);
2389
+        $this->pdf->Line($x + $w12, $y, $x + $w12, $y + $hmax);
2396 2390
         //ALÍQ. ICMS
2397 2391
         $x += $w12;
2398
-        $w13 = round($w*0.035, 0);
2392
+        $w13 = round($w * 0.035, 0);
2399 2393
         $texto = 'ALÍQ. ICMS';
2400 2394
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2401 2395
         $this->pTextBox($x, $y, $w13, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2402
-        $this->pdf->Line($x+$w13, $y, $x+$w13, $y+$hmax);
2396
+        $this->pdf->Line($x + $w13, $y, $x + $w13, $y + $hmax);
2403 2397
         //ALÍQ. IPI
2404 2398
         $x += $w13;
2405
-        $w14 = $w-($w1+$w2+$w3+$w4+$w5+$w6+$w7+$w8+$w9+$w10+$w11+$w12+$w13);
2399
+        $w14 = $w - ($w1 + $w2 + $w3 + $w4 + $w5 + $w6 + $w7 + $w8 + $w9 + $w10 + $w11 + $w12 + $w13);
2406 2400
         $texto = 'ALÍQ. IPI';
2407 2401
         $this->pTextBox($x, $y, $w14, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2408
-        $this->pdf->Line($oldX, $y+$h+1, $oldX + $w, $y+$h+1);
2402
+        $this->pdf->Line($oldX, $y + $h + 1, $oldX + $w, $y + $h + 1);
2409 2403
         $y += 5;
2410 2404
         //##################################################################################
2411 2405
         // LOOP COM OS DADOS DOS PRODUTOS
@@ -2422,7 +2416,7 @@  discard block
 block discarded – undo
2422 2416
                 $IPI  = $imposto->getElementsByTagName("IPI")->item(0);
2423 2417
                 $textoProduto = $this->pDescricaoProduto($thisItem);
2424 2418
                 $linhaDescr = $this->pGetNumLines($textoProduto, $w2, $aFont);
2425
-                $h = round(($linhaDescr * $this->pdf->fontSize)+ ($linhaDescr * 0.5), 2);
2419
+                $h = round(($linhaDescr * $this->pdf->fontSize) + ($linhaDescr * 0.5), 2);
2426 2420
                 $hUsado += $h;
2427 2421
                 if ($pag != $totpag) {
2428 2422
                     if ($hUsado >= $hmax && $i < $totItens) {
@@ -2432,11 +2426,11 @@  discard block
 block discarded – undo
2432 2426
                         break;
2433 2427
                     }
2434 2428
                 }
2435
-                $y_linha=$y+$h;
2429
+                $y_linha = $y + $h;
2436 2430
                 // linha entre itens
2437 2431
                 $this->pdf->DashedHLine($oldX, $y_linha, $w, 0.1, 120);
2438 2432
                 //corrige o x
2439
-                $x=$oldX;
2433
+                $x = $oldX;
2440 2434
                 //codigo do produto
2441 2435
                 $texto = $prod->getElementsByTagName("cProd")->item(0)->nodeValue;
2442 2436
                 $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'C', 0, '');
@@ -2449,16 +2443,16 @@  discard block
 block discarded – undo
2449 2443
                 }
2450 2444
                 $x += $w2;
2451 2445
                 //NCM
2452
-                $texto = ! empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ?
2446
+                $texto = !empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ?
2453 2447
                         $prod->getElementsByTagName("NCM")->item(0)->nodeValue : '';
2454 2448
                 $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'C', 0, '');
2455 2449
                 $x += $w3;
2456 2450
                 //CST
2457 2451
                 if (isset($ICMS)) {
2458
-                    $origem =  $this->pSimpleGetValue($ICMS, "orig");
2459
-                    $cst =  $this->pSimpleGetValue($ICMS, "CST");
2460
-                    $csosn =  $this->pSimpleGetValue($ICMS, "CSOSN");
2461
-                    $texto = $origem.$cst.$csosn;
2452
+                    $origem = $this->pSimpleGetValue($ICMS, "orig");
2453
+                    $cst = $this->pSimpleGetValue($ICMS, "CST");
2454
+                    $csosn = $this->pSimpleGetValue($ICMS, "CSOSN");
2455
+                    $texto = $origem . $cst . $csosn;
2462 2456
                     $this->pTextBox($x, $y, $w4, $h, $texto, $aFont, 'T', 'C', 0, '');
2463 2457
                 }
2464 2458
                 //CFOP
@@ -2492,7 +2486,7 @@  discard block
 block discarded – undo
2492 2486
                 //Valor da Base de calculo
2493 2487
                 $x += $w9;
2494 2488
                 if (isset($ICMS)) {
2495
-                    $texto = ! empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2489
+                    $texto = !empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2496 2490
                             number_format(
2497 2491
                                 $ICMS->getElementsByTagName("vBC")->item(0)->nodeValue,
2498 2492
                                 2,
@@ -2504,7 +2498,7 @@  discard block
 block discarded – undo
2504 2498
                 //Valor do ICMS
2505 2499
                 $x += $w10;
2506 2500
                 if (isset($ICMS)) {
2507
-                    $texto = ! empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2501
+                    $texto = !empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2508 2502
                             number_format(
2509 2503
                                 $ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue,
2510 2504
                                 2,
@@ -2516,8 +2510,8 @@  discard block
 block discarded – undo
2516 2510
                 //Valor do IPI
2517 2511
                 $x += $w11;
2518 2512
                 if (isset($IPI)) {
2519
-                    $texto = ! empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue) ?
2520
-                            number_format($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue, 2, ",", ".") :'';
2513
+                    $texto = !empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue) ?
2514
+                            number_format($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue, 2, ",", ".") : '';
2521 2515
                 } else {
2522 2516
                     $texto = '';
2523 2517
                 }
@@ -2525,7 +2519,7 @@  discard block
 block discarded – undo
2525 2519
                 // %ICMS
2526 2520
                 $x += $w12;
2527 2521
                 if (isset($ICMS)) {
2528
-                    $texto = ! empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2522
+                    $texto = !empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2529 2523
                             number_format(
2530 2524
                                 $ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue,
2531 2525
                                 2,
@@ -2537,7 +2531,7 @@  discard block
 block discarded – undo
2537 2531
                 //%IPI
2538 2532
                 $x += $w13;
2539 2533
                 if (isset($IPI)) {
2540
-                    $texto = ! empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue) ?
2534
+                    $texto = !empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue) ?
2541 2535
                             number_format($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue, 2, ",", ".") : '';
2542 2536
                 } else {
2543 2537
                     $texto = '';
@@ -2551,7 +2545,7 @@  discard block
 block discarded – undo
2551 2545
                 $i++;
2552 2546
             }
2553 2547
         }
2554
-        return $oldY+$hmax;
2548
+        return $oldY + $hmax;
2555 2549
     }
2556 2550
 
2557 2551
     /**
@@ -2575,12 +2569,12 @@  discard block
 block discarded – undo
2575 2569
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2576 2570
         //INSCRIÇÃO MUNICIPAL
2577 2571
         $y += 3;
2578
-        $w = round($this->wPrint*0.23, 0);
2572
+        $w = round($this->wPrint * 0.23, 0);
2579 2573
         $texto = 'INSCRIÇÃO MUNICIPAL';
2580 2574
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2581 2575
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
2582 2576
         //inscrição municipal
2583
-        $texto = ! empty($this->emit->getElementsByTagName("IM")->item(0)->nodeValue) ?
2577
+        $texto = !empty($this->emit->getElementsByTagName("IM")->item(0)->nodeValue) ?
2584 2578
                 $this->emit->getElementsByTagName("IM")->item(0)->nodeValue : '';
2585 2579
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
2586 2580
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
@@ -2590,7 +2584,7 @@  discard block
 block discarded – undo
2590 2584
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2591 2585
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
2592 2586
         if (isset($this->ISSQNtot)) {
2593
-            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ?
2587
+            $texto = !empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ?
2594 2588
                     $this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : '';
2595 2589
             $texto = number_format($texto, 2, ",", ".");
2596 2590
         } else {
@@ -2604,9 +2598,9 @@  discard block
 block discarded – undo
2604 2598
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2605 2599
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
2606 2600
         if (isset($this->ISSQNtot)) {
2607
-            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2601
+            $texto = !empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2608 2602
                     $this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue : '';
2609
-            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
2603
+            $texto = !empty($texto) ? number_format($texto, 2, ",", ".") : '';
2610 2604
         } else {
2611 2605
             $texto = '';
2612 2606
         }
@@ -2617,21 +2611,21 @@  discard block
 block discarded – undo
2617 2611
         if ($this->orientacao == 'P') {
2618 2612
             $w = $this->wPrint - (3 * $w);
2619 2613
         } else {
2620
-            $w = $this->wPrint - (3 * $w)-$this->wCanhoto;
2614
+            $w = $this->wPrint - (3 * $w) - $this->wCanhoto;
2621 2615
         }
2622 2616
         $texto = 'VALOR TOTAL DO ISSQN';
2623 2617
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2624 2618
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
2625 2619
         if (isset($this->ISSQNtot)) {
2626
-            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ?
2620
+            $texto = !empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ?
2627 2621
                     $this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue : '';
2628
-            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
2622
+            $texto = !empty($texto) ? number_format($texto, 2, ",", ".") : '';
2629 2623
         } else {
2630 2624
             $texto = '';
2631 2625
         }
2632 2626
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
2633 2627
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
2634
-        return ($y+$h+1);
2628
+        return ($y + $h + 1);
2635 2629
     }
2636 2630
 
2637 2631
     /**
@@ -2652,7 +2646,7 @@  discard block
 block discarded – undo
2652 2646
         if ($this->orientacao == 'P') {
2653 2647
               $w = $this->wPrint;
2654 2648
         } else {
2655
-              $w = $this->wPrint-$this->wCanhoto;
2649
+              $w = $this->wPrint - $this->wCanhoto;
2656 2650
         }
2657 2651
         $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
2658 2652
         $this->pTextBox($x, $y, $w, 8, $texto, $aFont, 'T', 'L', 0, '');
@@ -2668,15 +2662,15 @@  discard block
 block discarded – undo
2668 2662
         //$this->textoAdic com o texto completo do campo
2669 2663
         $y += 1;
2670 2664
         $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
2671
-        $this->pTextBox($x, $y+2, $w-2, $h-3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
2665
+        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
2672 2666
         //RESERVADO AO FISCO
2673 2667
         $texto = "RESERVADO AO FISCO";
2674 2668
         $x += $w;
2675 2669
         $y -= 1;
2676 2670
         if ($this->orientacao == 'P') {
2677
-            $w = $this->wPrint-$w;
2671
+            $w = $this->wPrint - $w;
2678 2672
         } else {
2679
-            $w = $this->wPrint-$w-$this->wCanhoto;
2673
+            $w = $this->wPrint - $w - $this->wCanhoto;
2680 2674
         }
2681 2675
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'B');
2682 2676
         $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
@@ -2715,8 +2709,8 @@  discard block
 block discarded – undo
2715 2709
         }
2716 2710
         $y += 2;
2717 2711
         $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
2718
-        $this->pTextBox($x, $y, $w-2, $h-3, $texto, $aFont, 'T', 'L', 0, '', false);
2719
-        return $y+$h;
2712
+        $this->pTextBox($x, $y, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
2713
+        return $y + $h;
2720 2714
     }
2721 2715
 
2722 2716
     /**
@@ -2734,13 +2728,13 @@  discard block
 block discarded – undo
2734 2728
         if ($this->orientacao == 'P') {
2735 2729
               $w = $this->wPrint;
2736 2730
         } else {
2737
-              $w = $this->wPrint-$this->wCanhoto;
2731
+              $w = $this->wPrint - $this->wCanhoto;
2738 2732
               $x = $this->wCanhoto;
2739 2733
         }
2740 2734
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I');
2741
-        $texto = "Impresso em ". date('d/m/Y') . " as " . date('H:i:s');
2735
+        $texto = "Impresso em " . date('d/m/Y') . " as " . date('H:i:s');
2742 2736
         $this->pTextBox($x, $y, $w, 0, $texto, $aFont, 'T', 'L', false);
2743
-        $texto = $this->creditos .  "  Powered by NFePHP";
2737
+        $texto = $this->creditos . "  Powered by NFePHP";
2744 2738
         $this->pTextBox($x, $y, $w, 0, $texto, $aFont, 'T', 'R', false, '');
2745 2739
     }
2746 2740
 
@@ -2793,9 +2787,9 @@  discard block
 block discarded – undo
2793 2787
         } else {
2794 2788
             //linha separadora do canhoto - 238
2795 2789
             //posicao altura
2796
-            $y = $this->wPrint-85;
2790
+            $y = $this->wPrint - 85;
2797 2791
             //altura
2798
-            $w = $this->wPrint-85-24;
2792
+            $w = $this->wPrint - 85 - 24;
2799 2793
         }
2800 2794
         $h = 10;
2801 2795
         //desenha caixa
@@ -2818,21 +2812,21 @@  discard block
 block discarded – undo
2818 2812
             $texto .= "AO LADO";
2819 2813
         }
2820 2814
         $texto .= ". EMISSÃO: ";
2821
-        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
2815
+        $dEmi = !empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
2822 2816
                 $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
2823 2817
         if ($dEmi == '') {
2824
-            $dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
2818
+            $dEmi = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
2825 2819
                     $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
2826 2820
             $aDemi = explode('T', $dEmi);
2827 2821
             $dEmi = $aDemi[0];
2828 2822
         }
2829
-        $texto .= $this->pYmd2dmy($dEmi) ." ";
2823
+        $texto .= $this->pYmd2dmy($dEmi) . " ";
2830 2824
         $texto .= "VALOR TOTAL: R$ ";
2831 2825
         $texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " ";
2832 2826
         $texto .= "DESTINATÁRIO: ";
2833 2827
         $texto .= $destinatario;
2834 2828
         if ($this->orientacao == 'P') {
2835
-            $this->pTextBox($x, $y, $w-1, $h, $texto, $aFont, 'C', 'L', 0, '', false);
2829
+            $this->pTextBox($x, $y, $w - 1, $h, $texto, $aFont, 'C', 'L', 0, '', false);
2836 2830
             $x1 = $x + $w;
2837 2831
             $w1 = $this->wPrint - $w;
2838 2832
             $texto = "NF-e";
@@ -2845,12 +2839,12 @@  discard block
 block discarded – undo
2845 2839
             //DATA DE RECEBIMENTO
2846 2840
             $texto = "DATA DE RECEBIMENTO";
2847 2841
             $y += $h;
2848
-            $w2 = round($this->wPrint*0.17, 0); //35;
2842
+            $w2 = round($this->wPrint * 0.17, 0); //35;
2849 2843
             $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2850 2844
             $this->pTextBox($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, '');
2851 2845
             //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
2852 2846
             $x += $w2;
2853
-            $w3 = $w-$w2;
2847
+            $w3 = $w - $w2;
2854 2848
             $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
2855 2849
             $this->pTextBox($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, '');
2856 2850
             $x = $oldX;
@@ -2860,7 +2854,7 @@  discard block
 block discarded – undo
2860 2854
             return $y;
2861 2855
         } else {
2862 2856
             $x--;
2863
-            $x = $this->pTextBox90($x, $y, $w-1, $h, $texto, $aFontSmall, 'C', 'L', 0, '', false);
2857
+            $x = $this->pTextBox90($x, $y, $w - 1, $h, $texto, $aFontSmall, 'C', 'L', 0, '', false);
2864 2858
             //NUMERO DA NOTA FISCAL LOGO NFE
2865 2859
             $w1 = 16;
2866 2860
             $x1 = $oldX;
@@ -2874,18 +2868,18 @@  discard block
 block discarded – undo
2874 2868
             $this->pTextBox($x1, $y, $w1, 18, $texto, $aFont, 'C', 'C', 1, '');
2875 2869
             //DATA DO RECEBIMENTO
2876 2870
             $texto = "DATA DO RECEBIMENTO";
2877
-            $y = $this->wPrint-85;
2871
+            $y = $this->wPrint - 85;
2878 2872
             $x = 12;
2879
-            $w2 = round($this->wPrint*0.17, 0); //35;
2873
+            $w2 = round($this->wPrint * 0.17, 0); //35;
2880 2874
             $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
2881 2875
             $this->pTextBox90($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, '');
2882 2876
             //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
2883 2877
             $y -= $w2;
2884
-            $w3 = $w-$w2;
2878
+            $w3 = $w - $w2;
2885 2879
             $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
2886 2880
             $aFont = array('font'=>$this->fontePadrao, 'size'=>5.7, 'style'=>'');
2887 2881
             $x = $this->pTextBox90($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, '');
2888
-            $this->pdf->DashedVLine(23, $oldY, 0.1, $this->wPrint-20, 67);
2882
+            $this->pdf->DashedVLine(23, $oldY, 0.1, $this->wPrint - 20, 67);
2889 2883
             return $x;
2890 2884
         }
2891 2885
     }
@@ -2902,13 +2896,13 @@  discard block
 block discarded – undo
2902 2896
     {
2903 2897
         $saida = "";
2904 2898
         if (isset($this->compra)) {
2905
-            if (! empty($this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue)) {
2899
+            if (!empty($this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue)) {
2906 2900
                 $saida .= " Nota de Empenho: " . $this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue;
2907 2901
             }
2908
-            if (! empty($this->compra->getElementsByTagName("xPed")->item(0)->nodeValue)) {
2902
+            if (!empty($this->compra->getElementsByTagName("xPed")->item(0)->nodeValue)) {
2909 2903
                 $saida .= " Pedido: " . $this->compra->getElementsByTagName("xPed")->item(0)->nodeValue;
2910 2904
             }
2911
-            if (! empty($this->compra->getElementsByTagName("xCont")->item(0)->nodeValue)) {
2905
+            if (!empty($this->compra->getElementsByTagName("xCont")->item(0)->nodeValue)) {
2912 2906
                 $saida .= " Contrato: " . $this->compra->getElementsByTagName("xCont")->item(0)->nodeValue;
2913 2907
             }
2914 2908
         }
@@ -2934,21 +2928,21 @@  discard block
 block discarded – undo
2934 2928
         if ($vICMS > 0) {
2935 2929
             $vICMS = 1;
2936 2930
         }
2937
-        $icmss  = $this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue;
2931
+        $icmss = $this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue;
2938 2932
         if ($icmss > 0) {
2939 2933
             $icmss = 1;
2940 2934
         }
2941
-        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
2935
+        $dEmi = !empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
2942 2936
                 $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
2943 2937
         if ($dEmi == '') {
2944
-            $dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
2938
+            $dEmi = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
2945 2939
                     $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
2946 2940
             $aDemi = explode('T', $dEmi);
2947 2941
             $dEmi = $aDemi[0];
2948 2942
         }
2949 2943
         $dd  = $dEmi;
2950 2944
         $rpos = strrpos($dd, '-');
2951
-        $dd  = substr($dd, $rpos +1);
2945
+        $dd  = substr($dd, $rpos + 1);
2952 2946
         $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vNF, $vICMS, $icmss, $dd);
2953 2947
         $chave = $chave . $this->pModulo11($chave);
2954 2948
         return $chave;
@@ -2969,7 +2963,7 @@  discard block
 block discarded – undo
2969 2963
         $formaNfRef = "\r\nNF  Ref.: série:%d numero:%d emit:%s em %s modelo: %d";
2970 2964
         $formaECFRef = "\r\nECF Ref.: modelo: %s ECF:%d COO:%d";
2971 2965
         $formaNfpRef = "\r\nNFP Ref.: série:%d número:%d emit:%s em %s modelo: %d IE:%s";
2972
-        $saida='';
2966
+        $saida = '';
2973 2967
         $nfRefs = $this->ide->getElementsByTagName('NFref');
2974 2968
         if (0 === $nfRefs->length) {
2975 2969
             return $saida;
@@ -2982,7 +2976,7 @@  discard block
 block discarded – undo
2982 2976
             foreach ($refNFe as $chave_acessoRef) {
2983 2977
                 $chave_acesso = $chave_acessoRef->nodeValue;
2984 2978
                 $chave_acessoF = $this->pFormat($chave_acesso, $this->formatoChave);
2985
-                $data = substr($chave_acesso, 4, 2)."/20".substr($chave_acesso, 2, 2);
2979
+                $data = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
2986 2980
                 $cnpj = $this->pFormat(substr($chave_acesso, 6, 14), "##.###.###/####-##");
2987 2981
                 $serie  = substr($chave_acesso, 22, 3);
2988 2982
                 $numero = substr($chave_acesso, 25, 9);
@@ -3003,7 +2997,7 @@  discard block
 block discarded – undo
3003 2997
             foreach ($refCTe as $chave_acessoRef) {
3004 2998
                 $chave_acesso = $chave_acessoRef->nodeValue;
3005 2999
                 $chave_acessoF = $this->pFormat($chave_acesso, $this->formatoChave);
3006
-                $data = substr($chave_acesso, 4, 2)."/20".substr($chave_acesso, 2, 2);
3000
+                $data = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2);
3007 3001
                 $cnpj = $this->pFormat(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3008 3002
                 $serie  = substr($chave_acesso, 22, 3);
3009 3003
                 $numero = substr($chave_acesso, 25, 9);
@@ -3019,10 +3013,9 @@  discard block
 block discarded – undo
3019 3013
             $refNFP = $nfRef->getElementsByTagName('refNFP');
3020 3014
             foreach ($refNFP as $umaRefNFe) {
3021 3015
                 $data = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3022
-                $cnpj = ! empty($umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue) ?
3023
-                    $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue :
3024
-                    '';
3025
-                $cpf = ! empty($umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue) ?
3016
+                $cnpj = !empty($umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue) ?
3017
+                    $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue : '';
3018
+                $cpf = !empty($umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue) ?
3026 3019
                         $umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue : '';
3027 3020
                 $mod = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3028 3021
                 $serie = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
Please login to merge, or discard this patch.
src/Legacy/FPDF/Fpdf.php 1 patch
Spacing   +356 added lines, -356 removed lines patch added patch discarded remove patch
@@ -12,64 +12,64 @@  discard block
 block discarded – undo
12 12
 {
13 13
     const FPDF_VERSION = '1.6';
14 14
     
15
-    public $page;               //current page number
16
-    public $n;                  //current object number
17
-    public $offsets;            //array of object offsets
18
-    public $buffer;             //buffer holding in-memory PDF
19
-    public $pages;              //array containing pages
20
-    public $state;              //current document state
21
-    public $compress;           //compression flag
22
-    public $k;                  //scale factor (number of points in user unit)
23
-    public $defOrientation;     //default orientation
24
-    public $curOrientation;     //current orientation
25
-    public $pageFormats;        //available page formats
26
-    public $defPageFormat;      //default page format
27
-    public $curPageFormat;      //current page format
28
-    public $pageSizes;          //array storing non-default page sizes
15
+    public $page; //current page number
16
+    public $n; //current object number
17
+    public $offsets; //array of object offsets
18
+    public $buffer; //buffer holding in-memory PDF
19
+    public $pages; //array containing pages
20
+    public $state; //current document state
21
+    public $compress; //compression flag
22
+    public $k; //scale factor (number of points in user unit)
23
+    public $defOrientation; //default orientation
24
+    public $curOrientation; //current orientation
25
+    public $pageFormats; //available page formats
26
+    public $defPageFormat; //default page format
27
+    public $curPageFormat; //current page format
28
+    public $pageSizes; //array storing non-default page sizes
29 29
     public $wPt;
30
-    public $hPt;           //dimensions of current page in points
30
+    public $hPt; //dimensions of current page in points
31 31
     public $w;
32
-    public $h;               //dimensions of current page in user unit
33
-    public $lMargin;            //left margin
34
-    public $tMargin;            //top margin
35
-    public $rMargin;            //right margin
36
-    public $bMargin;            //page break margin
37
-    public $cMargin;            //cell margin
32
+    public $h; //dimensions of current page in user unit
33
+    public $lMargin; //left margin
34
+    public $tMargin; //top margin
35
+    public $rMargin; //right margin
36
+    public $bMargin; //page break margin
37
+    public $cMargin; //cell margin
38 38
     public $x;
39
-    public $y;               //current position in user unit
40
-    public $lasth;              //height of last printed cell
41
-    public $lineWidth;          //line width in user unit
42
-    public $coreFonts;          //array of standard font names
43
-    public $fonts;              //array of used fonts
44
-    public $fontFiles;          //array of font files
45
-    public $diffs;              //array of encoding differences
46
-    public $fontFamily;         //current font family
47
-    public $fontStyle;          //current font style
48
-    public $underline;          //underlining flag
49
-    public $currentFont;        //current font info
50
-    public $fontSizePt;         //current font size in points
51
-    public $fontSize;           //current font size in user unit
52
-    public $drawColor;          //commands for drawing color
53
-    public $fillColor;          //commands for filling color
54
-    public $textColor;          //commands for text color
55
-    public $colorFlag;          //indicates whether fill and text colors are different
56
-    public $ws;                 //word spacing
57
-    public $images;             //array of used images
58
-    public $PageLinks;          //array of links in pages
59
-    public $links;              //array of internal links
60
-    public $autoPageBreak;      //automatic page breaking
61
-    public $pageBreakTrigger;   //threshold used to trigger page breaks
62
-    public $inHeader;           //flag set when processing header
63
-    public $inFooter;           //flag set when processing footer
64
-    public $zoomMode;           //zoom display mode
65
-    public $layoutMode;         //layout display mode
66
-    public $title;              //title
67
-    public $subject;            //subject
68
-    public $author;             //author
69
-    public $keywords;           //keywords
70
-    public $creator;            //creator
71
-    public $aliasNbPages;       //alias for total number of pages
72
-    public $pdfVersion;         //PDF version number
39
+    public $y; //current position in user unit
40
+    public $lasth; //height of last printed cell
41
+    public $lineWidth; //line width in user unit
42
+    public $coreFonts; //array of standard font names
43
+    public $fonts; //array of used fonts
44
+    public $fontFiles; //array of font files
45
+    public $diffs; //array of encoding differences
46
+    public $fontFamily; //current font family
47
+    public $fontStyle; //current font style
48
+    public $underline; //underlining flag
49
+    public $currentFont; //current font info
50
+    public $fontSizePt; //current font size in points
51
+    public $fontSize; //current font size in user unit
52
+    public $drawColor; //commands for drawing color
53
+    public $fillColor; //commands for filling color
54
+    public $textColor; //commands for text color
55
+    public $colorFlag; //indicates whether fill and text colors are different
56
+    public $ws; //word spacing
57
+    public $images; //array of used images
58
+    public $PageLinks; //array of links in pages
59
+    public $links; //array of internal links
60
+    public $autoPageBreak; //automatic page breaking
61
+    public $pageBreakTrigger; //threshold used to trigger page breaks
62
+    public $inHeader; //flag set when processing header
63
+    public $inFooter; //flag set when processing footer
64
+    public $zoomMode; //zoom display mode
65
+    public $layoutMode; //layout display mode
66
+    public $title; //title
67
+    public $subject; //subject
68
+    public $author; //author
69
+    public $keywords; //keywords
70
+    public $creator; //creator
71
+    public $aliasNbPages; //alias for total number of pages
72
+    public $pdfVersion; //PDF version number
73 73
     
74 74
     public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4')
75 75
     {
@@ -120,21 +120,21 @@  discard block
 block discarded – undo
120 120
         if ($unit == 'pt') {
121 121
             $this->k = 1;
122 122
         } elseif ($unit == 'mm') {
123
-            $this->k = 72/25.4;
123
+            $this->k = 72 / 25.4;
124 124
         } elseif ($unit == 'cm') {
125
-            $this->k = 72/2.54;
125
+            $this->k = 72 / 2.54;
126 126
         } elseif ($unit == 'in') {
127 127
             $this->k = 72;
128 128
         } else {
129
-            $this->error('Incorrect unit: '.$unit);
129
+            $this->error('Incorrect unit: ' . $unit);
130 130
         }
131 131
         //Page format
132 132
         $this->pageFormats = array(
133
-            'a3' => array(841.89,1190.55),
134
-            'a4' => array(595.28,841.89),
135
-            'a5' => array(420.94,595.28),
136
-            'letter' => array(612,792),
137
-            'legal' => array(612,1008)
133
+            'a3' => array(841.89, 1190.55),
134
+            'a4' => array(595.28, 841.89),
135
+            'a5' => array(420.94, 595.28),
136
+            'letter' => array(612, 792),
137
+            'legal' => array(612, 1008)
138 138
         );
139 139
         if (is_string($format)) {
140 140
             $format = $this->getpageformat($format);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         //Page orientation
145 145
         $orientation = strtolower($orientation);
146 146
         if ($orientation == 'p' || $orientation == 'portrait') {
147
-            $this->defOrientation='P';
147
+            $this->defOrientation = 'P';
148 148
             $this->w = $this->defPageFormat[0];
149 149
             $this->h = $this->defPageFormat[1];
150 150
         } elseif ($orientation == 'l' || $orientation == 'landscape') {
@@ -152,26 +152,26 @@  discard block
 block discarded – undo
152 152
             $this->w = $this->defPageFormat[1];
153 153
             $this->h = $this->defPageFormat[0];
154 154
         } else {
155
-            $this->error('Incorrect orientation: '.$orientation);
155
+            $this->error('Incorrect orientation: ' . $orientation);
156 156
         }
157 157
         $this->curOrientation = $this->defOrientation;
158
-        $this->wPt = $this->w*$this->k;
159
-        $this->hPt = $this->h*$this->k;
158
+        $this->wPt = $this->w * $this->k;
159
+        $this->hPt = $this->h * $this->k;
160 160
         //Page margins (1 cm)
161
-        $margin = 28.35/$this->k;
161
+        $margin = 28.35 / $this->k;
162 162
         $this->setMargins($margin, $margin);
163 163
         //Interior cell margin (1 mm)
164
-        $this->cMargin = $margin/10;
164
+        $this->cMargin = $margin / 10;
165 165
         //Line width (0.2 mm)
166
-        $this->lineWidth = .567/$this->k;
166
+        $this->lineWidth = .567 / $this->k;
167 167
         //Automatic page break
168
-        $this->setAutoPageBreak(true, 2*$margin);
168
+        $this->setAutoPageBreak(true, 2 * $margin);
169 169
         //Full width display mode
170 170
         $this->setDisplayMode('fullwidth');
171 171
         //Enable compression
172 172
         $this->setCompression(true);
173 173
         //Set default PDF version number
174
-        $this->pdfVersion='1.3';
174
+        $this->pdfVersion = '1.3';
175 175
     }
176 176
 
177 177
     public function setMargins($left, $top, $right = null)
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
         if ($right === null) {
183 183
             $right = $left;
184 184
         }
185
-        $this->rMargin=$right;
185
+        $this->rMargin = $right;
186 186
     }
187 187
 
188 188
     public function setLeftMargin($margin)
189 189
     {
190 190
         //Set left margin
191 191
         $this->lMargin = $margin;
192
-        if ($this->page>0 && $this->x<$margin) {
192
+        if ($this->page > 0 && $this->x < $margin) {
193 193
             $this->x = $margin;
194 194
         }
195 195
     }
@@ -211,21 +211,21 @@  discard block
 block discarded – undo
211 211
         //Set auto page break mode and triggering margin
212 212
         $this->autoPageBreak = $auto;
213 213
         $this->bMargin = $margin;
214
-        $this->pageBreakTrigger = $this->h-$margin;
214
+        $this->pageBreakTrigger = $this->h - $margin;
215 215
     }
216 216
 
217 217
     public function setDisplayMode($zoom, $layout = 'continuous')
218 218
     {
219 219
         //Set display mode in viewer
220
-        if ($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) {
220
+        if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom)) {
221 221
             $this->zoomMode = $zoom;
222 222
         } else {
223
-            $this->error('Incorrect zoom display mode: '.$zoom);
223
+            $this->error('Incorrect zoom display mode: ' . $zoom);
224 224
         }
225
-        if ($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') {
225
+        if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default') {
226 226
             $this->layoutMode = $layout;
227 227
         } else {
228
-            $this->error('Incorrect layout display mode: '.$layout);
228
+            $this->error('Incorrect layout display mode: ' . $layout);
229 229
         }
230 230
     }
231 231
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         if ($isUTF8) {
264 264
             $author = $this->utf8Toutf16($author);
265 265
         }
266
-        $this->author=$author;
266
+        $this->author = $author;
267 267
     }
268 268
 
269 269
     public function setKeywords($keywords, $isUTF8 = false)
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     public function aliasNbPages($alias = '{nb}')
288 288
     {
289 289
         //Define an alias for total number of pages
290
-        $this->aliasNbPages=$alias;
290
+        $this->aliasNbPages = $alias;
291 291
     }
292 292
 
293 293
     public function error($msg)
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
     public function addPage($orientation = '', $format = '')
324 324
     {
325 325
         //Start a new page
326
-        if ($this->state==0) {
326
+        if ($this->state == 0) {
327 327
             $this->open();
328 328
         }
329 329
         $family = $this->fontFamily;
330
-        $style = $this->fontStyle.($this->underline ? 'U' : '');
330
+        $style = $this->fontStyle . ($this->underline ? 'U' : '');
331 331
         $size = $this->fontSizePt;
332 332
         $lw = $this->lineWidth;
333 333
         $dc = $this->drawColor;
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
         $this->out('2 J');
349 349
         //Set line width
350 350
         $this->lineWidth = $lw;
351
-        $this->out(sprintf('%.2F w', $lw*$this->k));
351
+        $this->out(sprintf('%.2F w', $lw * $this->k));
352 352
         //Set font
353 353
         if ($family) {
354 354
             $this->setFont($family, $style, $size);
355 355
         }
356 356
         //Set colors
357 357
         $this->drawColor = $dc;
358
-        if ($dc!='0 G') {
358
+        if ($dc != '0 G') {
359 359
             $this->out($dc);
360 360
         }
361 361
         $this->fillColor = $fc;
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         //Restore line width
372 372
         if ($this->lineWidth != $lw) {
373 373
             $this->lineWidth = $lw;
374
-            $this->out(sprintf('%.2F w', $lw*$this->k));
374
+            $this->out(sprintf('%.2F w', $lw * $this->k));
375 375
         }
376 376
         //Restore font
377 377
         if ($family) {
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
     public function setDrawColor($r, $g = null, $b = null)
410 410
     {
411 411
         //Set color for all stroking operations
412
-        if (($r==0 && $g==0 && $b==0) || $g===null) {
413
-            $this->drawColor = sprintf('%.3F G', $r/255);
412
+        if (($r == 0 && $g == 0 && $b == 0) || $g === null) {
413
+            $this->drawColor = sprintf('%.3F G', $r / 255);
414 414
         } else {
415
-            $this->drawColor = sprintf('%.3F %.3F %.3F RG', $r/255, $g/255, $b/255);
415
+            $this->drawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255);
416 416
         }
417 417
         if ($this->page > 0) {
418 418
             $this->out($this->drawColor);
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
     public function setFillColor($r, $g = null, $b = null)
423 423
     {
424 424
         //Set color for all filling operations
425
-        if (($r==0 && $g==0 && $b==0) || $g===null) {
426
-            $this->fillColor = sprintf('%.3F g', $r/255);
425
+        if (($r == 0 && $g == 0 && $b == 0) || $g === null) {
426
+            $this->fillColor = sprintf('%.3F g', $r / 255);
427 427
         } else {
428
-            $this->fillColor = sprintf('%.3F %.3F %.3F rg', $r/255, $g/255, $b/255);
428
+            $this->fillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
429 429
         }
430 430
         $this->colorFlag = ($this->fillColor != $this->textColor);
431 431
         if ($this->page > 0) {
@@ -436,10 +436,10 @@  discard block
 block discarded – undo
436 436
     public function settextColor($r, $g = null, $b = null)
437 437
     {
438 438
         //Set color for text
439
-        if (($r==0 && $g==0 && $b==0) || $g===null) {
440
-            $this->textColor = sprintf('%.3F g', $r/255);
439
+        if (($r == 0 && $g == 0 && $b == 0) || $g === null) {
440
+            $this->textColor = sprintf('%.3F g', $r / 255);
441 441
         } else {
442
-            $this->textColor = sprintf('%.3F %.3F %.3F rg', $r/255, $g/255, $b/255);
442
+            $this->textColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
443 443
         }
444 444
         $this->colorFlag = ($this->fillColor != $this->textColor);
445 445
     }
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
     public function getStringWidth($s)
448 448
     {
449 449
         //Get width of a string in the current font
450
-        $s = (string)$s;
451
-        $cw =& $this->currentFont['cw'];
450
+        $s = (string) $s;
451
+        $cw = & $this->currentFont['cw'];
452 452
         $w = 0;
453 453
         $l = strlen($s);
454
-        for ($i=0; $i<$l; $i++) {
454
+        for ($i = 0; $i < $l; $i++) {
455 455
             $w += $cw[$s[$i]];
456 456
         }
457
-        return $w*$this->fontSize/1000;
457
+        return $w * $this->fontSize / 1000;
458 458
     }
459 459
 
460 460
     public function setLineWidth($width)
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         //Set line width
463 463
         $this->lineWidth = $width;
464 464
         if ($this->page > 0) {
465
-            $this->out(sprintf('%.2F w', $width*$this->k));
465
+            $this->out(sprintf('%.2F w', $width * $this->k));
466 466
         }
467 467
     }
468 468
 
@@ -472,10 +472,10 @@  discard block
 block discarded – undo
472 472
         $this->out(
473 473
             sprintf(
474 474
                 '%.2F %.2F m %.2F %.2F l S',
475
-                $x1*$this->k,
476
-                ($this->h-$y1)*$this->k,
477
-                $x2*$this->k,
478
-                ($this->h-$y2)*$this->k
475
+                $x1 * $this->k,
476
+                ($this->h - $y1) * $this->k,
477
+                $x2 * $this->k,
478
+                ($this->h - $y2) * $this->k
479 479
             )
480 480
         );
481 481
     }
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
         $this->out(
494 494
             sprintf(
495 495
                 '%.2F %.2F %.2F %.2F re %s',
496
-                $x*$this->k,
497
-                ($this->h-$y)*$this->k,
498
-                $w*$this->k,
499
-                -$h*$this->k,
496
+                $x * $this->k,
497
+                ($this->h - $y) * $this->k,
498
+                $w * $this->k,
499
+                -$h * $this->k,
500 500
                 $op
501 501
             )
502 502
         );
@@ -507,24 +507,24 @@  discard block
 block discarded – undo
507 507
         //Add a TrueType or Type1 font
508 508
         $family = strtolower($family);
509 509
         if ($file == '') {
510
-            $file = str_replace(' ', '', $family).strtolower($style).'.php';
510
+            $file = str_replace(' ', '', $family) . strtolower($style) . '.php';
511 511
         }
512
-        if ($family=='arial') {
513
-            $family='helvetica';
512
+        if ($family == 'arial') {
513
+            $family = 'helvetica';
514 514
         }
515 515
         $style = strtoupper($style);
516 516
         if ($style == 'IB') {
517 517
             $style = 'BI';
518 518
         }
519
-        $fontkey = $family.$style;
519
+        $fontkey = $family . $style;
520 520
         if (isset($this->fonts[$fontkey])) {
521 521
             return;
522 522
         }
523
-        include $this->getFontPath().$file;
523
+        include $this->getFontPath() . $file;
524 524
         if (!isset($name)) {
525 525
             $this->error('Could not include font definition file');
526 526
         }
527
-        $i = count($this->fonts)+1;
527
+        $i = count($this->fonts) + 1;
528 528
         $this->fonts[$fontkey] = [
529 529
             'i'=>$i,
530 530
             'type'=>$type,
@@ -540,20 +540,20 @@  discard block
 block discarded – undo
540 540
             //Search existing encodings
541 541
             $d = 0;
542 542
             $nb = count($this->diffs);
543
-            for ($i=1; $i<=$nb; $i++) {
543
+            for ($i = 1; $i <= $nb; $i++) {
544 544
                 if ($this->diffs[$i] == $diff) {
545 545
                     $d = $i;
546 546
                     break;
547 547
                 }
548 548
             }
549 549
             if ($d == 0) {
550
-                $d = $nb+1;
550
+                $d = $nb + 1;
551 551
                 $this->diffs[$d] = $diff;
552 552
             }
553 553
             $this->fonts[$fontkey]['diff'] = $d;
554 554
         }
555 555
         if ($file) {
556
-            if ($type=='TrueType') {
556
+            if ($type == 'TrueType') {
557 557
                 $this->fontFiles[$file] = array('length1'=>$originalsize);
558 558
             } else {
559 559
                 $this->fontFiles[$file] = array('length1'=>$size1, 'length2'=>$size2);
@@ -588,39 +588,39 @@  discard block
 block discarded – undo
588 588
             $size = $this->fontSizePt;
589 589
         }
590 590
         //Test if font is already selected
591
-        if ($this->fontFamily==$family && $this->fontStyle==$style && $this->fontSizePt==$size) {
591
+        if ($this->fontFamily == $family && $this->fontStyle == $style && $this->fontSizePt == $size) {
592 592
             return;
593 593
         }
594 594
         //Test if used for the first time
595
-        $fontkey = $family.$style;
595
+        $fontkey = $family . $style;
596 596
         if (!isset($this->fonts[$fontkey])) {
597 597
             //Check if one of the standard fonts
598 598
             if (isset($this->coreFonts[$fontkey])) {
599 599
                 if (!isset($fpdf_charwidths[$fontkey])) {
600 600
                     //Load metric file
601
-                    $file=$family;
602
-                    if ($family=='times' || $family=='helvetica') {
601
+                    $file = $family;
602
+                    if ($family == 'times' || $family == 'helvetica') {
603 603
                         $file .= strtolower($style);
604 604
                     }
605
-                    include $this->getFontPath().$file.'.php';
605
+                    include $this->getFontPath() . $file . '.php';
606 606
                     if (!isset($fpdf_charwidths[$fontkey])) {
607 607
                         $this->error('Could not include font metric file');
608 608
                     }
609 609
                 }
610
-                $i = count($this->fonts)+1;
610
+                $i = count($this->fonts) + 1;
611 611
                 $name = $this->coreFonts[$fontkey];
612 612
                 $cw = $fpdf_charwidths[$fontkey];
613 613
                 $this->fonts[$fontkey] = ['i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw];
614 614
             } else {
615
-                $this->error('Undefined font: '.$family.' '.$style);
615
+                $this->error('Undefined font: ' . $family . ' ' . $style);
616 616
             }
617 617
         }
618 618
         //Select it
619 619
         $this->fontFamily = $family;
620 620
         $this->fontStyle = $style;
621 621
         $this->fontSizePt = $size;
622
-        $this->fontSize = $size/$this->k;
623
-        $this->currentFont =& $this->fonts[$fontkey];
622
+        $this->fontSize = $size / $this->k;
623
+        $this->currentFont = & $this->fonts[$fontkey];
624 624
         if ($this->page > 0) {
625 625
             $this->out(sprintf('BT /F%d %.2F Tf ET', $this->currentFont['i'], $this->fontSizePt));
626 626
         }
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
             return;
634 634
         }
635 635
         $this->fontSizePt = $size;
636
-        $this->fontSize = $size/$this->k;
636
+        $this->fontSize = $size / $this->k;
637 637
         if ($this->page > 0) {
638 638
             $this->out(sprintf('BT /F%d %.2F Tf ET', $this->currentFont['i'], $this->fontSizePt));
639 639
         }
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
     public function addlink()
643 643
     {
644 644
         //Create a new internal link
645
-        $n = count($this->links)+1;
645
+        $n = count($this->links) + 1;
646 646
         $this->links[$n] = array(0, 0);
647 647
         return $n;
648 648
     }
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
     {
664 664
         //Put a link on the page
665 665
         $this->PageLinks[$this->page][] = [
666
-            $x*$this->k,
667
-            $this->hPt-$y*$this->k,
668
-            $w*$this->k,
669
-            $h*$this->k,
666
+            $x * $this->k,
667
+            $this->hPt - $y * $this->k,
668
+            $w * $this->k,
669
+            $h * $this->k,
670 670
             $link
671 671
         ];
672 672
     }
@@ -674,12 +674,12 @@  discard block
 block discarded – undo
674 674
     public function text($x, $y, $txt)
675 675
     {
676 676
         //Output a string
677
-        $s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x*$this->k, ($this->h-$y)*$this->k, $this->escape($txt));
678
-        if ($this->underline && $txt!='') {
679
-            $s .= ' '.$this->doUnderLine($x, $y, $txt);
677
+        $s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->escape($txt));
678
+        if ($this->underline && $txt != '') {
679
+            $s .= ' ' . $this->doUnderLine($x, $y, $txt);
680 680
         }
681 681
         if ($this->colorFlag) {
682
-            $s = 'q '.$this->textColor.' '.$s.' Q';
682
+            $s = 'q ' . $this->textColor . ' ' . $s . ' Q';
683 683
         }
684 684
         $this->out($s);
685 685
     }
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
     {
695 695
         //Output a cell
696 696
         $k = $this->k;
697
-        if ($this->y+$h > $this->PageBreakTrigger
697
+        if ($this->y + $h > $this->PageBreakTrigger
698 698
             && !$this->InHeader
699 699
             && !$this->InFooter
700 700
             && $this->acceptPageBreak()
@@ -710,77 +710,77 @@  discard block
 block discarded – undo
710 710
             $this->x = $x;
711 711
             if ($ws > 0) {
712 712
                 $this->ws = $ws;
713
-                $this->out(sprintf('%.3F Tw', $ws*$k));
713
+                $this->out(sprintf('%.3F Tw', $ws * $k));
714 714
             }
715 715
         }
716 716
         if ($w == 0) {
717
-            $w = $this->w-$this->rMargin-$this->x;
717
+            $w = $this->w - $this->rMargin - $this->x;
718 718
         }
719
-        $s='';
720
-        if ($fill || $border==1) {
719
+        $s = '';
720
+        if ($fill || $border == 1) {
721 721
             if ($fill) {
722
-                $op=($border==1) ? 'B' : 'f';
722
+                $op = ($border == 1) ? 'B' : 'f';
723 723
             } else {
724
-                $op='S';
724
+                $op = 'S';
725 725
             }
726
-            $s=sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x*$k, ($this->h-$this->y)*$k, $w*$k, -$h*$k, $op);
726
+            $s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
727 727
         }
728 728
         if (is_string($border)) {
729 729
             $x = $this->x;
730 730
             $y = $this->y;
731 731
             if (strpos($border, 'L') !== false) {
732
-                $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x*$k, ($this->h-$y)*$k, $x*$k, ($this->h-($y+$h))*$k);
732
+                $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
733 733
             }
734 734
             if (strpos($border, 'T') !== false) {
735
-                $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x*$k, ($this->h-$y)*$k, ($x+$w)*$k, ($this->h-$y)*$k);
735
+                $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
736 736
             }
737 737
             if (strpos($border, 'R') !== false) {
738 738
                 $s .= sprintf(
739 739
                     '%.2F %.2F m %.2F %.2F l S ',
740
-                    ($x+$w)*$k,
741
-                    ($this->h-$y)*$k,
742
-                    ($x+$w)*$k,
743
-                    ($this->h-($y+$h))*$k
740
+                    ($x + $w) * $k,
741
+                    ($this->h - $y) * $k,
742
+                    ($x + $w) * $k,
743
+                    ($this->h - ($y + $h)) * $k
744 744
                 );
745 745
             }
746 746
             if (strpos($border, 'B') !== false) {
747 747
                 $s .= sprintf(
748 748
                     '%.2F %.2F m %.2F %.2F l S ',
749
-                    $x*$k,
750
-                    ($this->h-($y+$h))*$k,
751
-                    ($x+$w)*$k,
752
-                    ($this->h-($y+$h))*$k
749
+                    $x * $k,
750
+                    ($this->h - ($y + $h)) * $k,
751
+                    ($x + $w) * $k,
752
+                    ($this->h - ($y + $h)) * $k
753 753
                 );
754 754
             }
755 755
         }
756 756
         if ($txt !== '') {
757 757
             if ($align == 'R') {
758
-                $dx = $w-$this->cMargin-$this->getStringWidth($txt);
758
+                $dx = $w - $this->cMargin - $this->getStringWidth($txt);
759 759
             } elseif ($align == 'C') {
760
-                $dx = ($w-$this->getStringWidth($txt))/2;
760
+                $dx = ($w - $this->getStringWidth($txt)) / 2;
761 761
             } else {
762 762
                 $dx = $this->cMargin;
763 763
             }
764 764
             if ($this->colorFlag) {
765
-                $s .= 'q '.$this->textColor.' ';
765
+                $s .= 'q ' . $this->textColor . ' ';
766 766
             }
767 767
             $txt2 = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt)));
768 768
             $s .= sprintf(
769 769
                 'BT %.2F %.2F Td (%s) Tj ET',
770
-                ($this->x+$dx)*$k,
771
-                ($this->h-($this->y+.5*$h+.3*$this->fontSize))*$k,
770
+                ($this->x + $dx) * $k,
771
+                ($this->h - ($this->y + .5 * $h + .3 * $this->fontSize)) * $k,
772 772
                 $txt2
773 773
             );
774 774
             if ($this->underline) {
775
-                $s .= ' '.$this->doUnderLine($this->x+$dx, $this->y+.5*$h+.3*$this->fontSize, $txt);
775
+                $s .= ' ' . $this->doUnderLine($this->x + $dx, $this->y + .5 * $h + .3 * $this->fontSize, $txt);
776 776
             }
777 777
             if ($this->colorFlag) {
778
-                $s.=' Q';
778
+                $s .= ' Q';
779 779
             }
780 780
             if ($link) {
781 781
                 $this->link(
782
-                    $this->x+$dx,
783
-                    $this->y+.5*$h-.5*$this->fontSize,
782
+                    $this->x + $dx,
783
+                    $this->y + .5 * $h - .5 * $this->fontSize,
784 784
                     $this->getStringWidth($txt),
785 785
                     $this->fontSize,
786 786
                     $link
@@ -805,14 +805,14 @@  discard block
 block discarded – undo
805 805
     public function multicell($w, $h, $txt, $border = 0, $align = 'J', $fill = false)
806 806
     {
807 807
         //Output text with automatic or explicit line breaks
808
-        $cw =& $this->currentFont['cw'];
808
+        $cw = & $this->currentFont['cw'];
809 809
         if ($w == 0) {
810
-            $w = $this->w-$this->rMargin-$this->x;
810
+            $w = $this->w - $this->rMargin - $this->x;
811 811
         }
812
-        $wmax = ($w-2*$this->cMargin)*1000/$this->fontSize;
812
+        $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize;
813 813
         $s = str_replace("\r", '', $txt);
814 814
         $nb = strlen($s);
815
-        if ($nb>0 && $s[$nb-1] == "\n") {
815
+        if ($nb > 0 && $s[$nb - 1] == "\n") {
816 816
             $nb--;
817 817
         }
818 818
         $b = 0;
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
                 if (strpos($border, 'R') !== false) {
830 830
                     $b2 .= 'R';
831 831
                 }
832
-                $b=(strpos($border, 'T') !== false) ? $b2.'T' : $b2;
832
+                $b = (strpos($border, 'T') !== false) ? $b2 . 'T' : $b2;
833 833
             }
834 834
         }
835 835
         $sep = -1;
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
         $l = 0;
839 839
         $ns = 0;
840 840
         $nl = 1;
841
-        while ($i<$nb) {
841
+        while ($i < $nb) {
842 842
             //Get next character
843 843
             $c = $s[$i];
844 844
             if ($c == "\n") {
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
                     $this->ws = 0;
848 848
                     $this->out('0 Tw');
849 849
                 }
850
-                $this->cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill);
850
+                $this->cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
851 851
                 $i++;
852 852
                 $sep = -1;
853 853
                 $j = $i;
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
                 $ns = 0;
856 856
                 $nl++;
857 857
                 if ($border && $nl == 2) {
858
-                    $b=$b2;
858
+                    $b = $b2;
859 859
                 }
860 860
                 continue;
861 861
             }
@@ -875,14 +875,14 @@  discard block
 block discarded – undo
875 875
                         $this->ws = 0;
876 876
                         $this->out('0 Tw');
877 877
                     }
878
-                    $this->cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill);
878
+                    $this->cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
879 879
                 } else {
880
-                    if ($align=='J') {
881
-                        $this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->fontSize/($ns-1) : 0;
882
-                        $this->out(sprintf('%.3F Tw', $this->ws*$this->k));
880
+                    if ($align == 'J') {
881
+                        $this->ws = ($ns > 1) ? ($wmax - $ls) / 1000 * $this->fontSize / ($ns - 1) : 0;
882
+                        $this->out(sprintf('%.3F Tw', $this->ws * $this->k));
883 883
                     }
884
-                    $this->cell($w, $h, substr($s, $j, $sep-$j), $b, 2, $align, $fill);
885
-                    $i = $sep+1;
884
+                    $this->cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill);
885
+                    $i = $sep + 1;
886 886
                 }
887 887
                 $sep = -1;
888 888
                 $j = $i;
@@ -901,19 +901,19 @@  discard block
 block discarded – undo
901 901
             $this->ws = 0;
902 902
             $this->out('0 Tw');
903 903
         }
904
-        if ($border && strpos($border, 'B')!==false) {
904
+        if ($border && strpos($border, 'B') !== false) {
905 905
             $b .= 'B';
906 906
         }
907
-        $this->cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill);
907
+        $this->cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
908 908
         $this->x = $this->lMargin;
909 909
     }
910 910
 
911 911
     public function write($h, $txt, $link = '')
912 912
     {
913 913
         //Output text in flowing mode
914
-        $cw =& $this->currentFont['cw'];
915
-        $w = $this->w-$this->rMargin-$this->x;
916
-        $wmax = ($w-2*$this->cMargin)*1000/$this->fontSize;
914
+        $cw = & $this->currentFont['cw'];
915
+        $w = $this->w - $this->rMargin - $this->x;
916
+        $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize;
917 917
         $s = str_replace("\r", '', $txt);
918 918
         $nb = strlen($s);
919 919
         $sep = -1;
@@ -923,18 +923,18 @@  discard block
 block discarded – undo
923 923
         $nl = 1;
924 924
         while ($i < $nb) {
925 925
             //Get next character
926
-            $c=$s[$i];
927
-            if ($c=="\n") {
926
+            $c = $s[$i];
927
+            if ($c == "\n") {
928 928
                 //Explicit line break
929
-                $this->cell($w, $h, substr($s, $j, $i-$j), 0, 2, '', 0, $link);
929
+                $this->cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
930 930
                 $i++;
931 931
                 $sep = -1;
932 932
                 $j = $i;
933 933
                 $l = 0;
934 934
                 if ($nl == 1) {
935 935
                     $this->x = $this->lMargin;
936
-                    $w = $this->w-$this->rMargin-$this->x;
937
-                    $wmax = ($w-2*$this->cMargin)*1000/$this->fontSize;
936
+                    $w = $this->w - $this->rMargin - $this->x;
937
+                    $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize;
938 938
                 }
939 939
                 $nl++;
940 940
                 continue;
@@ -950,8 +950,8 @@  discard block
 block discarded – undo
950 950
                         //Move to next line
951 951
                         $this->x = $this->lMargin;
952 952
                         $this->y += $h;
953
-                        $w = $this->w-$this->rMargin-$this->x;
954
-                        $wmax = ($w-2*$this->cMargin)*1000/$this->fontSize;
953
+                        $w = $this->w - $this->rMargin - $this->x;
954
+                        $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize;
955 955
                         $i++;
956 956
                         $nl++;
957 957
                         continue;
@@ -959,18 +959,18 @@  discard block
 block discarded – undo
959 959
                     if ($i == $j) {
960 960
                         $i++;
961 961
                     }
962
-                    $this->cell($w, $h, substr($s, $j, $i-$j), 0, 2, '', 0, $link);
962
+                    $this->cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
963 963
                 } else {
964
-                    $this->cell($w, $h, substr($s, $j, $sep-$j), 0, 2, '', 0, $link);
965
-                    $i = $sep+1;
964
+                    $this->cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link);
965
+                    $i = $sep + 1;
966 966
                 }
967 967
                 $sep = -1;
968 968
                 $j = $i;
969 969
                 $l = 0;
970 970
                 if ($nl == 1) {
971 971
                     $this->x = $this->lMargin;
972
-                    $w = $this->w-$this->rMargin-$this->x;
973
-                    $wmax = ($w-2*$this->cMargin)*1000/$this->fontSize;
972
+                    $w = $this->w - $this->rMargin - $this->x;
973
+                    $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->fontSize;
974 974
                 }
975 975
                 $nl++;
976 976
             } else {
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
         }
980 980
         //Last chunk
981 981
         if ($i != $j) {
982
-            $this->cell($l/1000*$this->fontSize, $h, substr($s, $j), 0, 0, '', 0, $link);
982
+            $this->cell($l / 1000 * $this->fontSize, $h, substr($s, $j), 0, 0, '', 0, $link);
983 983
         }
984 984
     }
985 985
 
@@ -1002,20 +1002,20 @@  discard block
 block discarded – undo
1002 1002
             if ($type == '') {
1003 1003
                 $pos = strrpos($file, '.');
1004 1004
                 if (!$pos) {
1005
-                    $this->error('Image file has no extension and no type was specified: '.$file);
1005
+                    $this->error('Image file has no extension and no type was specified: ' . $file);
1006 1006
                 }
1007
-                $type = substr($file, $pos+1);
1007
+                $type = substr($file, $pos + 1);
1008 1008
             }
1009 1009
             $type = strtolower($type);
1010 1010
             if ($type == 'jpeg') {
1011 1011
                 $type = 'jpg';
1012 1012
             }
1013
-            $mtd = 'parse'.strtoupper($type);
1013
+            $mtd = 'parse' . strtoupper($type);
1014 1014
             if (!method_exists($this, $mtd)) {
1015
-                $this->error('Unsupported image type: '.$type);
1015
+                $this->error('Unsupported image type: ' . $type);
1016 1016
             }
1017 1017
             $info = $this->$mtd($file);
1018
-            $info['i'] = count($this->images)+1;
1018
+            $info['i'] = count($this->images) + 1;
1019 1019
             $this->images[$file] = $info;
1020 1020
         } else {
1021 1021
             $info = $this->images[$file];
@@ -1023,16 +1023,16 @@  discard block
 block discarded – undo
1023 1023
         //Automatic width and height calculation if needed
1024 1024
         if ($w == 0 && $h == 0) {
1025 1025
             //Put image at 72 dpi
1026
-            $w = $info['w']/$this->k;
1027
-            $h = $info['h']/$this->k;
1026
+            $w = $info['w'] / $this->k;
1027
+            $h = $info['h'] / $this->k;
1028 1028
         } elseif ($w == 0) {
1029
-            $w = $h*$info['w']/$info['h'];
1029
+            $w = $h * $info['w'] / $info['h'];
1030 1030
         } elseif ($h == 0) {
1031
-            $h = $w*$info['h']/$info['w'];
1031
+            $h = $w * $info['h'] / $info['w'];
1032 1032
         }
1033 1033
         //Flowing mode
1034 1034
         if ($y === null) {
1035
-            if ($this->y+$h > $this->pageBreakTrigger
1035
+            if ($this->y + $h > $this->pageBreakTrigger
1036 1036
                 && !$this->inHeader
1037 1037
                 && !$this->inFooter
1038 1038
                 && $this->acceptPageBreak()
@@ -1051,10 +1051,10 @@  discard block
 block discarded – undo
1051 1051
         $this->out(
1052 1052
             sprintf(
1053 1053
                 'q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',
1054
-                $w*$this->k,
1055
-                $h*$this->k,
1056
-                $x*$this->k,
1057
-                ($this->h-($y+$h))*$this->k,
1054
+                $w * $this->k,
1055
+                $h * $this->k,
1056
+                $x * $this->k,
1057
+                ($this->h - ($y + $h)) * $this->k,
1058 1058
                 $info['i']
1059 1059
             )
1060 1060
         );
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
         if ($x >= 0) {
1076 1076
             $this->x = $x;
1077 1077
         } else {
1078
-            $this->x = $this->w+$x;
1078
+            $this->x = $this->w + $x;
1079 1079
         }
1080 1080
     }
1081 1081
 
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
         if ($y >= 0) {
1093 1093
             $this->y = $y;
1094 1094
         } else {
1095
-            $this->y = $this->h+$y;
1095
+            $this->y = $this->h + $y;
1096 1096
         }
1097 1097
     }
1098 1098
 
@@ -1138,8 +1138,8 @@  discard block
 block discarded – undo
1138 1138
                     if (headers_sent()) {
1139 1139
                         $this->error('Some data has already been output, can\'t send PDF file');
1140 1140
                     }
1141
-                    header('Content-Length: '.strlen($this->buffer));
1142
-                    header('Content-Disposition: inline; filename="'.$name.'"');
1141
+                    header('Content-Length: ' . strlen($this->buffer));
1142
+                    header('Content-Disposition: inline; filename="' . $name . '"');
1143 1143
                     header('Cache-Control: private, max-age=0, must-revalidate');
1144 1144
                     header('Pragma: public');
1145 1145
                     ini_set('zlib.output_compression', '0');
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
                 if (headers_sent()) {
1156 1156
                     $this->error('Some data has already been output, can\'t send PDF file');
1157 1157
                 }
1158
-                header('Content-Length: '.strlen($this->buffer));
1159
-                header('Content-Disposition: attachment; filename="'.$name.'"');
1158
+                header('Content-Length: ' . strlen($this->buffer));
1159
+                header('Content-Disposition: attachment; filename="' . $name . '"');
1160 1160
                 header('Cache-Control: private, max-age=0, must-revalidate');
1161 1161
                 header('Pragma: public');
1162 1162
                 ini_set('zlib.output_compression', '0');
@@ -1164,9 +1164,9 @@  discard block
 block discarded – undo
1164 1164
                 break;
1165 1165
             case 'F':
1166 1166
                 //Save to local file
1167
-                $f=fopen($name, 'wb');
1167
+                $f = fopen($name, 'wb');
1168 1168
                 if (!$f) {
1169
-                    $this->error('Unable to create output file: '.$name);
1169
+                    $this->error('Unable to create output file: ' . $name);
1170 1170
                 }
1171 1171
                 fwrite($f, $this->buffer, strlen($this->buffer));
1172 1172
                 fclose($f);
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
                 //Return as a string
1176 1176
                 return $this->buffer;
1177 1177
             default:
1178
-                $this->error('Incorrect output destination: '.$dest);
1178
+                $this->error('Incorrect output destination: ' . $dest);
1179 1179
         }
1180 1180
         return '';
1181 1181
     }
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
     protected function dochecks()
1184 1184
     {
1185 1185
         //Check availability of %F
1186
-        if (sprintf('%.1F', 1.0)!='1.0') {
1186
+        if (sprintf('%.1F', 1.0) != '1.0') {
1187 1187
             $this->error('This version of PHP is not supported');
1188 1188
         }
1189 1189
         //Check mbstring overloading
@@ -1198,18 +1198,18 @@  discard block
 block discarded – undo
1198 1198
 
1199 1199
     protected function getpageformat($format)
1200 1200
     {
1201
-        $format=strtolower($format);
1201
+        $format = strtolower($format);
1202 1202
         if (!isset($this->pageFormats[$format])) {
1203
-            $this->error('Unknown page format: '.$format);
1203
+            $this->error('Unknown page format: ' . $format);
1204 1204
         }
1205
-        $a=$this->pageFormats[$format];
1206
-        return array($a[0]/$this->k, $a[1]/$this->k);
1205
+        $a = $this->pageFormats[$format];
1206
+        return array($a[0] / $this->k, $a[1] / $this->k);
1207 1207
     }
1208 1208
 
1209 1209
     protected function getFontPath()
1210 1210
     {
1211
-        if (!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) {
1212
-            define('FPDF_FONTPATH', dirname(__FILE__).'/font/');
1211
+        if (!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__) . '/font')) {
1212
+            define('FPDF_FONTPATH', dirname(__FILE__) . '/font/');
1213 1213
         }
1214 1214
         return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
1215 1215
     }
@@ -1232,12 +1232,12 @@  discard block
 block discarded – undo
1232 1232
             $format = $this->defPageFormat;
1233 1233
         } else {
1234 1234
             if (is_string($format)) {
1235
-                $format=$this->getpageformat($format);
1235
+                $format = $this->getpageformat($format);
1236 1236
             }
1237 1237
         }
1238 1238
         if ($orientation != $this->curOrientation
1239
-            || $format[0]!=$this->curPageFormat[0]
1240
-            || $format[1]!=$this->curPageFormat[1]
1239
+            || $format[0] != $this->curPageFormat[0]
1240
+            || $format[1] != $this->curPageFormat[1]
1241 1241
         ) {
1242 1242
             //New size
1243 1243
             if ($orientation == 'P') {
@@ -1247,9 +1247,9 @@  discard block
 block discarded – undo
1247 1247
                 $this->w = $format[1];
1248 1248
                 $this->h = $format[0];
1249 1249
             }
1250
-            $this->wPt = $this->w*$this->k;
1251
-            $this->hPt = $this->h*$this->k;
1252
-            $this->pageBreakTrigger = $this->h-$this->bMargin;
1250
+            $this->wPt = $this->w * $this->k;
1251
+            $this->hPt = $this->h * $this->k;
1252
+            $this->pageBreakTrigger = $this->h - $this->bMargin;
1253 1253
             $this->curOrientation = $orientation;
1254 1254
             $this->curPageFormat = $format;
1255 1255
         }
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
     protected function textString($s)
1280 1280
     {
1281 1281
         //Format a text string
1282
-        return '('.$this->escape($s).')';
1282
+        return '(' . $this->escape($s) . ')';
1283 1283
     }
1284 1284
 
1285 1285
     protected function utf8Toutf16($s)
@@ -1294,16 +1294,16 @@  discard block
 block discarded – undo
1294 1294
                 //3-byte character
1295 1295
                 $c2 = ord($s[$i++]);
1296 1296
                 $c3 = ord($s[$i++]);
1297
-                $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1298
-                $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1297
+                $res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2));
1298
+                $res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F));
1299 1299
             } elseif ($c1 >= 192) {
1300 1300
                 //2-byte character
1301 1301
                 $c2 = ord($s[$i++]);
1302
-                $res .= chr(($c1 & 0x1C)>>2);
1303
-                $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1302
+                $res .= chr(($c1 & 0x1C) >> 2);
1303
+                $res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F));
1304 1304
             } else {
1305 1305
                 //Single-byte character
1306
-                $res .= "\0".chr($c1);
1306
+                $res .= "\0" . chr($c1);
1307 1307
             }
1308 1308
         }
1309 1309
         return $res;
@@ -1314,13 +1314,13 @@  discard block
 block discarded – undo
1314 1314
         //Underline text
1315 1315
         $up = $this->currentFont['up'];
1316 1316
         $ut = $this->currentFont['ut'];
1317
-        $w = $this->getStringWidth($txt)+$this->ws*substr_count($txt, ' ');
1317
+        $w = $this->getStringWidth($txt) + $this->ws * substr_count($txt, ' ');
1318 1318
         return sprintf(
1319 1319
             '%.2F %.2F %.2F %.2F re f',
1320
-            $x*$this->k,
1321
-            ($this->h-($y-$up/1000*$this->fontSize))*$this->k,
1322
-            $w*$this->k,
1323
-            -$ut/1000*$this->fontSizePt
1320
+            $x * $this->k,
1321
+            ($this->h - ($y - $up / 1000 * $this->fontSize)) * $this->k,
1322
+            $w * $this->k,
1323
+            -$ut / 1000 * $this->fontSizePt
1324 1324
         );
1325 1325
     }
1326 1326
 
@@ -1329,17 +1329,17 @@  discard block
 block discarded – undo
1329 1329
         //Extract info from a JPEG file
1330 1330
         $a = getImageSize($file);
1331 1331
         if (!$a) {
1332
-            $this->error('Missing or incorrect image file: '.$file);
1332
+            $this->error('Missing or incorrect image file: ' . $file);
1333 1333
         }
1334
-        if ($a[2]!=2) {
1335
-            $this->error('Not a JPEG file: '.$file);
1334
+        if ($a[2] != 2) {
1335
+            $this->error('Not a JPEG file: ' . $file);
1336 1336
         }
1337 1337
         if (!isset($a['channels']) || $a['channels'] == 3) {
1338 1338
             $colspace = 'DeviceRGB';
1339 1339
         } elseif ($a['channels'] == 4) {
1340 1340
             $colspace = 'DeviceCMYK';
1341 1341
         } else {
1342
-            $colspace='DeviceGray';
1342
+            $colspace = 'DeviceGray';
1343 1343
         }
1344 1344
         $bpc = isset($a['bits']) ? $a['bits'] : 8;
1345 1345
         //Read whole file
@@ -1357,22 +1357,22 @@  discard block
 block discarded – undo
1357 1357
         //Extract info from a PNG file
1358 1358
         $f = fopen($file, 'rb');
1359 1359
         if (!$f) {
1360
-            $this->error('Can\'t open image file: '.$file);
1360
+            $this->error('Can\'t open image file: ' . $file);
1361 1361
         }
1362 1362
         //Check signature
1363
-        if ($this->readstream($f, 8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
1364
-            $this->error('Not a PNG file: '.$file);
1363
+        if ($this->readstream($f, 8) != chr(137) . 'PNG' . chr(13) . chr(10) . chr(26) . chr(10)) {
1364
+            $this->error('Not a PNG file: ' . $file);
1365 1365
         }
1366 1366
         //Read header chunk
1367 1367
         $this->readstream($f, 4);
1368
-        if ($this->readstream($f, 4)!='IHDR') {
1369
-            $this->error('Incorrect PNG file: '.$file);
1368
+        if ($this->readstream($f, 4) != 'IHDR') {
1369
+            $this->error('Incorrect PNG file: ' . $file);
1370 1370
         }
1371 1371
         $w = $this->readint($f);
1372 1372
         $h = $this->readint($f);
1373 1373
         $bpc = ord($this->readstream($f, 1));
1374
-        if ($bpc>8) {
1375
-            $this->error('16-bit depth not supported: '.$file);
1374
+        if ($bpc > 8) {
1375
+            $this->error('16-bit depth not supported: ' . $file);
1376 1376
         }
1377 1377
         $ct = ord($this->readstream($f, 1));
1378 1378
         if ($ct == 0) {
@@ -1382,20 +1382,20 @@  discard block
 block discarded – undo
1382 1382
         } elseif ($ct == 3) {
1383 1383
             $colspace = 'Indexed';
1384 1384
         } else {
1385
-            $this->error('Alpha channel not supported: '.$file);
1385
+            $this->error('Alpha channel not supported: ' . $file);
1386 1386
         }
1387 1387
         if (ord($this->readstream($f, 1)) != 0) {
1388
-            $this->error('Unknown compression method: '.$file);
1388
+            $this->error('Unknown compression method: ' . $file);
1389 1389
         }
1390 1390
         if (ord($this->readstream($f, 1)) != 0) {
1391
-            $this->error('Unknown filter method: '.$file);
1391
+            $this->error('Unknown filter method: ' . $file);
1392 1392
         }
1393 1393
         if (ord($this->readstream($f, 1)) != 0) {
1394
-            $this->error('Interlacing not supported: '.$file);
1394
+            $this->error('Interlacing not supported: ' . $file);
1395 1395
         }
1396 1396
         $this->readstream($f, 4);
1397 1397
         $parms = '/DecodeParms <</Predictor 15 /Colors '
1398
-            . ($ct==2 ? 3 : 1)
1398
+            . ($ct == 2 ? 3 : 1)
1399 1399
             . ' /BitsPerComponent '
1400 1400
             . $bpc
1401 1401
             . ' /Columns '
@@ -1433,11 +1433,11 @@  discard block
 block discarded – undo
1433 1433
             } elseif ($type == 'IEND') {
1434 1434
                 break;
1435 1435
             } else {
1436
-                $this->readstream($f, $n+4);
1436
+                $this->readstream($f, $n + 4);
1437 1437
             }
1438 1438
         } while ($n);
1439 1439
         if ($colspace == 'Indexed' && empty($pal)) {
1440
-            $this->error('Missing palette in '.$file);
1440
+            $this->error('Missing palette in ' . $file);
1441 1441
         }
1442 1442
         fclose($f);
1443 1443
         return [
@@ -1456,9 +1456,9 @@  discard block
 block discarded – undo
1456 1456
     protected function readstream($f, $n)
1457 1457
     {
1458 1458
         //Read n bytes from stream
1459
-        $res='';
1459
+        $res = '';
1460 1460
         while ($n > 0 && !feof($f)) {
1461
-            $s=fread($f, $n);
1461
+            $s = fread($f, $n);
1462 1462
             if ($s === false) {
1463 1463
                 $this->error('Error while reading stream');
1464 1464
             }
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
         }
1490 1490
         $im = imagecreatefromgif($file);
1491 1491
         if (!$im) {
1492
-            $this->error('Missing or incorrect image file: '.$file);
1492
+            $this->error('Missing or incorrect image file: ' . $file);
1493 1493
         }
1494 1494
         imageinterlace($im, 0);
1495 1495
         $tmp = tempnam('.', 'gif');
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
             $this->error('Error while saving to temporary file');
1501 1501
         }
1502 1502
         imagedestroy($im);
1503
-        $info=$this->parsePNG($tmp);
1503
+        $info = $this->parsePNG($tmp);
1504 1504
         unlink($tmp);
1505 1505
         return $info;
1506 1506
     }
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
         //Begin a new object
1511 1511
         $this->n++;
1512 1512
         $this->offsets[$this->n] = strlen($this->buffer);
1513
-        $this->out($this->n.' 0 obj');
1513
+        $this->out($this->n . ' 0 obj');
1514 1514
     }
1515 1515
 
1516 1516
     protected function putStream($s)
@@ -1524,9 +1524,9 @@  discard block
 block discarded – undo
1524 1524
     {
1525 1525
         //Add a line to the document
1526 1526
         if ($this->state == 2) {
1527
-            $this->pages[$this->page].=$s."\n";
1527
+            $this->pages[$this->page] .= $s . "\n";
1528 1528
         } else {
1529
-            $this->buffer .= $s."\n";
1529
+            $this->buffer .= $s . "\n";
1530 1530
         }
1531 1531
     }
1532 1532
 
@@ -1535,19 +1535,19 @@  discard block
 block discarded – undo
1535 1535
         $nb = $this->page;
1536 1536
         if (!empty($this->aliasNbPages)) {
1537 1537
             //Replace number of pages
1538
-            for ($n=1; $n<=$nb; $n++) {
1538
+            for ($n = 1; $n <= $nb; $n++) {
1539 1539
                 $this->pages[$n] = str_replace($this->aliasNbPages, $nb, $this->pages[$n]);
1540 1540
             }
1541 1541
         }
1542 1542
         if ($this->defOrientation == 'P') {
1543
-            $wPt = $this->defPageFormat[0]*$this->k;
1544
-            $hPt = $this->defPageFormat[1]*$this->k;
1543
+            $wPt = $this->defPageFormat[0] * $this->k;
1544
+            $hPt = $this->defPageFormat[1] * $this->k;
1545 1545
         } else {
1546
-            $wPt = $this->defPageFormat[1]*$this->k;
1547
-            $hPt = $this->defPageFormat[0]*$this->k;
1546
+            $wPt = $this->defPageFormat[1] * $this->k;
1547
+            $hPt = $this->defPageFormat[0] * $this->k;
1548 1548
         }
1549 1549
         $filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1550
-        for ($n=1; $n<=$nb; $n++) {
1550
+        for ($n = 1; $n <= $nb; $n++) {
1551 1551
             //Page
1552 1552
             $this->newObj();
1553 1553
             $this->out('<</Type /Page');
@@ -1560,37 +1560,37 @@  discard block
 block discarded – undo
1560 1560
                 //Links
1561 1561
                 $annots = '/Annots [';
1562 1562
                 foreach ($this->PageLinks[$n] as $pl) {
1563
-                    $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0]+$pl[2], $pl[1]-$pl[3]);
1564
-                    $annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1563
+                    $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]);
1564
+                    $annots .= '<</Type /Annot /Subtype /Link /Rect [' . $rect . '] /Border [0 0 0] ';
1565 1565
                     if (is_string($pl[4])) {
1566
-                        $annots .= '/A <</S /URI /URI '.$this->textString($pl[4]).'>>>>';
1566
+                        $annots .= '/A <</S /URI /URI ' . $this->textString($pl[4]) . '>>>>';
1567 1567
                     } else {
1568 1568
                         $l = $this->links[$pl[4]];
1569 1569
                         $h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
1570
-                        $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', 1+2*$l[0], $h-$l[1]*$this->k);
1570
+                        $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', 1 + 2 * $l[0], $h - $l[1] * $this->k);
1571 1571
                     }
1572 1572
                 }
1573
-                $this->out($annots.']');
1573
+                $this->out($annots . ']');
1574 1574
             }
1575
-            $this->out('/Contents '.($this->n+1).' 0 R>>');
1575
+            $this->out('/Contents ' . ($this->n + 1) . ' 0 R>>');
1576 1576
             $this->out('endobj');
1577 1577
             //Page content
1578
-            $p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
1578
+            $p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
1579 1579
             $this->newObj();
1580
-            $this->out('<<'.$filter.'/Length '.strlen($p).'>>');
1580
+            $this->out('<<' . $filter . '/Length ' . strlen($p) . '>>');
1581 1581
             $this->putStream($p);
1582 1582
             $this->out('endobj');
1583 1583
         }
1584 1584
         //Pages root
1585
-        $this->offsets[1]=strlen($this->buffer);
1585
+        $this->offsets[1] = strlen($this->buffer);
1586 1586
         $this->out('1 0 obj');
1587 1587
         $this->out('<</Type /Pages');
1588 1588
         $kids = '/Kids [';
1589
-        for ($i=0; $i<$nb; $i++) {
1590
-            $kids .= (3+2*$i).' 0 R ';
1589
+        for ($i = 0; $i < $nb; $i++) {
1590
+            $kids .= (3 + 2 * $i) . ' 0 R ';
1591 1591
         }
1592
-        $this->out($kids.']');
1593
-        $this->out('/Count '.$nb);
1592
+        $this->out($kids . ']');
1593
+        $this->out('/Count ' . $nb);
1594 1594
         $this->out(sprintf('/MediaBox [0 0 %.2F %.2F]', $wPt, $hPt));
1595 1595
         $this->out('>>');
1596 1596
         $this->out('endobj');
@@ -1602,41 +1602,41 @@  discard block
 block discarded – undo
1602 1602
         foreach ($this->diffs as $diff) {
1603 1603
             //Encodings
1604 1604
             $this->newObj();
1605
-            $this->out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
1605
+            $this->out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [' . $diff . ']>>');
1606 1606
             $this->out('endobj');
1607 1607
         }
1608 1608
         foreach ($this->fontFiles as $file => $info) {
1609 1609
             //Font file embedding
1610 1610
             $this->newObj();
1611
-            $this->fontFiles[$file]['n']=$this->n;
1612
-            $font='';
1613
-            $f = fopen($this->getFontPath().$file, 'rb', 1);
1611
+            $this->fontFiles[$file]['n'] = $this->n;
1612
+            $font = '';
1613
+            $f = fopen($this->getFontPath() . $file, 'rb', 1);
1614 1614
             if (!$f) {
1615 1615
                 $this->error('Font file not found');
1616 1616
             }
1617 1617
             while (!feof($f)) {
1618
-                $font.=fread($f, 8192);
1618
+                $font .= fread($f, 8192);
1619 1619
             }
1620 1620
             fclose($f);
1621
-            $compressed = (substr($file, -2)=='.z');
1621
+            $compressed = (substr($file, -2) == '.z');
1622 1622
             if (!$compressed && isset($info['length2'])) {
1623
-                $header = (ord($font[0])==128);
1623
+                $header = (ord($font[0]) == 128);
1624 1624
                 if ($header) {
1625 1625
                     //Strip first binary header
1626 1626
                     $font = substr($font, 6);
1627 1627
                 }
1628 1628
                 if ($header && ord($font[$info['length1']]) == 128) {
1629 1629
                     //Strip second binary header
1630
-                    $font = substr($font, 0, $info['length1']).substr($font, $info['length1']+6);
1630
+                    $font = substr($font, 0, $info['length1']) . substr($font, $info['length1'] + 6);
1631 1631
                 }
1632 1632
             }
1633
-            $this->out('<</Length '.strlen($font));
1633
+            $this->out('<</Length ' . strlen($font));
1634 1634
             if ($compressed) {
1635 1635
                 $this->out('/Filter /FlateDecode');
1636 1636
             }
1637
-            $this->out('/Length1 '.$info['length1']);
1637
+            $this->out('/Length1 ' . $info['length1']);
1638 1638
             if (isset($info['length2'])) {
1639
-                $this->out('/Length2 '.$info['length2'].' /Length3 0');
1639
+                $this->out('/Length2 ' . $info['length2'] . ' /Length3 0');
1640 1640
             }
1641 1641
             $this->out('>>');
1642 1642
             $this->putStream($font);
@@ -1644,32 +1644,32 @@  discard block
 block discarded – undo
1644 1644
         }
1645 1645
         foreach ($this->fonts as $k => $font) {
1646 1646
             //Font objects
1647
-            $this->fonts[$k]['n']=$this->n+1;
1647
+            $this->fonts[$k]['n'] = $this->n + 1;
1648 1648
             $type = $font['type'];
1649 1649
             $name = $font['name'];
1650 1650
             if ($type == 'core') {
1651 1651
                 //Standard font
1652 1652
                 $this->newObj();
1653 1653
                 $this->out('<</Type /Font');
1654
-                $this->out('/BaseFont /'.$name);
1654
+                $this->out('/BaseFont /' . $name);
1655 1655
                 $this->out('/Subtype /Type1');
1656 1656
                 if ($name != 'Symbol' && $name != 'ZapfDingbats') {
1657 1657
                     $this->out('/Encoding /WinAnsiEncoding');
1658 1658
                 }
1659 1659
                 $this->out('>>');
1660 1660
                 $this->out('endobj');
1661
-            } elseif ($type=='Type1' || $type=='TrueType') {
1661
+            } elseif ($type == 'Type1' || $type == 'TrueType') {
1662 1662
                 //Additional Type1 or TrueType font
1663 1663
                 $this->newObj();
1664 1664
                 $this->out('<</Type /Font');
1665
-                $this->out('/BaseFont /'.$name);
1666
-                $this->out('/Subtype /'.$type);
1665
+                $this->out('/BaseFont /' . $name);
1666
+                $this->out('/Subtype /' . $type);
1667 1667
                 $this->out('/FirstChar 32 /LastChar 255');
1668
-                $this->out('/Widths '.($this->n+1).' 0 R');
1669
-                $this->out('/FontDescriptor '.($this->n+2).' 0 R');
1668
+                $this->out('/Widths ' . ($this->n + 1) . ' 0 R');
1669
+                $this->out('/FontDescriptor ' . ($this->n + 2) . ' 0 R');
1670 1670
                 if ($font['enc']) {
1671 1671
                     if (isset($font['diff'])) {
1672
-                        $this->out('/Encoding '.($nf+$font['diff']).' 0 R');
1672
+                        $this->out('/Encoding ' . ($nf + $font['diff']) . ' 0 R');
1673 1673
                     } else {
1674 1674
                         $this->out('/Encoding /WinAnsiEncoding');
1675 1675
                     }
@@ -1678,30 +1678,30 @@  discard block
 block discarded – undo
1678 1678
                 $this->out('endobj');
1679 1679
                 //Widths
1680 1680
                 $this->newObj();
1681
-                $cw =& $font['cw'];
1681
+                $cw = & $font['cw'];
1682 1682
                 $s = '[';
1683
-                for ($i=32; $i<=255; $i++) {
1684
-                    $s .= $cw[chr($i)].' ';
1683
+                for ($i = 32; $i <= 255; $i++) {
1684
+                    $s .= $cw[chr($i)] . ' ';
1685 1685
                 }
1686
-                $this->out($s.']');
1686
+                $this->out($s . ']');
1687 1687
                 $this->out('endobj');
1688 1688
                 //Descriptor
1689 1689
                 $this->newObj();
1690
-                $s='<</Type /FontDescriptor /FontName /'.$name;
1690
+                $s = '<</Type /FontDescriptor /FontName /' . $name;
1691 1691
                 foreach ($font['desc'] as $k => $v) {
1692
-                    $s .= ' /'.$k.' '.$v;
1692
+                    $s .= ' /' . $k . ' ' . $v;
1693 1693
                 }
1694
-                $file=$font['file'];
1694
+                $file = $font['file'];
1695 1695
                 if ($file) {
1696
-                    $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->fontFiles[$file]['n'].' 0 R';
1696
+                    $s .= ' /FontFile' . ($type == 'Type1' ? '' : '2') . ' ' . $this->fontFiles[$file]['n'] . ' 0 R';
1697 1697
                 }
1698
-                $this->out($s.'>>');
1698
+                $this->out($s . '>>');
1699 1699
                 $this->out('endobj');
1700 1700
             } else {
1701 1701
                 //Allow for additional types
1702
-                $mtd='_put'.strtolower($type);
1702
+                $mtd = '_put' . strtolower($type);
1703 1703
                 if (!method_exists($this, $mtd)) {
1704
-                    $this->error('Unsupported font type: '.$type);
1704
+                    $this->error('Unsupported font type: ' . $type);
1705 1705
                 }
1706 1706
                 $this->$mtd($font);
1707 1707
             }
@@ -1723,39 +1723,39 @@  discard block
 block discarded – undo
1723 1723
         $info['n'] = $this->n;
1724 1724
         $this->out('<</Type /XObject');
1725 1725
         $this->out('/Subtype /Image');
1726
-        $this->out('/Width '.$info['w']);
1727
-        $this->out('/Height '.$info['h']);
1728
-        if ($info['cs']=='Indexed') {
1729
-            $this->out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1726
+        $this->out('/Width ' . $info['w']);
1727
+        $this->out('/Height ' . $info['h']);
1728
+        if ($info['cs'] == 'Indexed') {
1729
+            $this->out('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->n + 1) . ' 0 R]');
1730 1730
         } else {
1731
-            $this->out('/ColorSpace /'.$info['cs']);
1732
-            if ($info['cs']=='DeviceCMYK') {
1731
+            $this->out('/ColorSpace /' . $info['cs']);
1732
+            if ($info['cs'] == 'DeviceCMYK') {
1733 1733
                 $this->out('/Decode [1 0 1 0 1 0 1 0]');
1734 1734
             }
1735 1735
         }
1736
-        $this->out('/BitsPerComponent '.$info['bpc']);
1736
+        $this->out('/BitsPerComponent ' . $info['bpc']);
1737 1737
         if (isset($info['f'])) {
1738
-            $this->out('/Filter /'.$info['f']);
1738
+            $this->out('/Filter /' . $info['f']);
1739 1739
         }
1740 1740
         if (isset($info['dp'])) {
1741
-            $this->out('/DecodeParms <<'.$info['dp'].'>>');
1741
+            $this->out('/DecodeParms <<' . $info['dp'] . '>>');
1742 1742
         }
1743 1743
         if (isset($info['trns']) && is_array($info['trns'])) {
1744 1744
             $trns = '';
1745
-            for ($i=0; $i<count($info['trns']); $i++) {
1746
-                $trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
1745
+            for ($i = 0; $i < count($info['trns']); $i++) {
1746
+                $trns .= $info['trns'][$i] . ' ' . $info['trns'][$i] . ' ';
1747 1747
             }
1748
-            $this->out('/Mask ['.$trns.']');
1748
+            $this->out('/Mask [' . $trns . ']');
1749 1749
         }
1750 1750
         if (isset($info['smask'])) {
1751
-            $this->out('/SMask '.($this->n+1).' 0 R');
1751
+            $this->out('/SMask ' . ($this->n + 1) . ' 0 R');
1752 1752
         }
1753
-        $this->out('/Length '.strlen($info['data']).'>>');
1753
+        $this->out('/Length ' . strlen($info['data']) . '>>');
1754 1754
         $this->putstream($info['data']);
1755 1755
         $this->out('endobj');
1756 1756
     // Soft mask
1757 1757
         if (isset($info['smask'])) {
1758
-            $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w'];
1758
+            $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns ' . $info['w'];
1759 1759
             $smask = [
1760 1760
                 'w'=>$info['w'],
1761 1761
                 'h'=>$info['h'],
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
             $this->putimage($smask);
1769 1769
         }
1770 1770
     // Palette
1771
-        if ($info['cs']=='Indexed') {
1771
+        if ($info['cs'] == 'Indexed') {
1772 1772
             $this->putstreamobject($info['pal']);
1773 1773
         }
1774 1774
     }
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
     protected function putXobjectDict()
1826 1826
     {
1827 1827
         foreach ($this->images as $image) {
1828
-            $this->out('/I'.$image['i'].' '.$image['n'].' 0 R');
1828
+            $this->out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
1829 1829
         }
1830 1830
     }
1831 1831
 
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
         $this->out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1835 1835
         $this->out('/Font <<');
1836 1836
         foreach ($this->fonts as $font) {
1837
-            $this->out('/F'.$font['i'].' '.$font['n'].' 0 R');
1837
+            $this->out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
1838 1838
         }
1839 1839
         $this->out('>>');
1840 1840
         $this->out('/XObject <<');
@@ -1857,57 +1857,57 @@  discard block
 block discarded – undo
1857 1857
 
1858 1858
     protected function putInfo()
1859 1859
     {
1860
-        $this->out('/Producer '.$this->textString('FPDF '. self::FPDF_VERSION));
1860
+        $this->out('/Producer ' . $this->textString('FPDF ' . self::FPDF_VERSION));
1861 1861
         if (!empty($this->title)) {
1862
-            $this->out('/Title '.$this->textString($this->title));
1862
+            $this->out('/Title ' . $this->textString($this->title));
1863 1863
         }
1864 1864
         if (!empty($this->subject)) {
1865
-            $this->out('/Subject '.$this->textString($this->subject));
1865
+            $this->out('/Subject ' . $this->textString($this->subject));
1866 1866
         }
1867 1867
         if (!empty($this->author)) {
1868
-            $this->out('/Author '.$this->textString($this->author));
1868
+            $this->out('/Author ' . $this->textString($this->author));
1869 1869
         }
1870 1870
         if (!empty($this->keywords)) {
1871
-            $this->out('/Keywords '.$this->textString($this->keywords));
1871
+            $this->out('/Keywords ' . $this->textString($this->keywords));
1872 1872
         }
1873 1873
         if (!empty($this->creator)) {
1874
-            $this->out('/Creator '.$this->textString($this->creator));
1874
+            $this->out('/Creator ' . $this->textString($this->creator));
1875 1875
         }
1876
-        $this->out('/CreationDate '.$this->textString('D:'.@date('YmdHis')));
1876
+        $this->out('/CreationDate ' . $this->textString('D:' . @date('YmdHis')));
1877 1877
     }
1878 1878
 
1879 1879
     protected function putCatalog()
1880 1880
     {
1881 1881
         $this->out('/Type /Catalog');
1882 1882
         $this->out('/Pages 1 0 R');
1883
-        if ($this->zoomMode=='fullpage') {
1883
+        if ($this->zoomMode == 'fullpage') {
1884 1884
             $this->out('/OpenAction [3 0 R /Fit]');
1885
-        } elseif ($this->zoomMode=='fullwidth') {
1885
+        } elseif ($this->zoomMode == 'fullwidth') {
1886 1886
             $this->out('/OpenAction [3 0 R /FitH null]');
1887
-        } elseif ($this->zoomMode=='real') {
1887
+        } elseif ($this->zoomMode == 'real') {
1888 1888
             $this->out('/OpenAction [3 0 R /XYZ null null 1]');
1889 1889
         } elseif (!is_string($this->zoomMode)) {
1890
-            $this->out('/OpenAction [3 0 R /XYZ null null '.($this->zoomMode/100).']');
1890
+            $this->out('/OpenAction [3 0 R /XYZ null null ' . ($this->zoomMode / 100) . ']');
1891 1891
         }
1892
-        if ($this->layoutMode=='single') {
1892
+        if ($this->layoutMode == 'single') {
1893 1893
             $this->out('/PageLayout /SinglePage');
1894
-        } elseif ($this->layoutMode=='continuous') {
1894
+        } elseif ($this->layoutMode == 'continuous') {
1895 1895
             $this->out('/PageLayout /OneColumn');
1896
-        } elseif ($this->layoutMode=='two') {
1896
+        } elseif ($this->layoutMode == 'two') {
1897 1897
             $this->out('/PageLayout /TwoColumnLeft');
1898 1898
         }
1899 1899
     }
1900 1900
 
1901 1901
     protected function putHeader()
1902 1902
     {
1903
-        $this->out('%PDF-'.$this->pdfVersion);
1903
+        $this->out('%PDF-' . $this->pdfVersion);
1904 1904
     }
1905 1905
 
1906 1906
     protected function putTrailer()
1907 1907
     {
1908
-        $this->out('/Size '.($this->n+1));
1909
-        $this->out('/Root '.$this->n.' 0 R');
1910
-        $this->out('/Info '.($this->n-1).' 0 R');
1908
+        $this->out('/Size ' . ($this->n + 1));
1909
+        $this->out('/Root ' . $this->n . ' 0 R');
1910
+        $this->out('/Info ' . ($this->n - 1) . ' 0 R');
1911 1911
     }
1912 1912
 
1913 1913
     protected function endDoc()
@@ -1928,11 +1928,11 @@  discard block
 block discarded – undo
1928 1928
         $this->out('>>');
1929 1929
         $this->out('endobj');
1930 1930
         //Cross-ref
1931
-        $o=strlen($this->buffer);
1931
+        $o = strlen($this->buffer);
1932 1932
         $this->out('xref');
1933
-        $this->out('0 '.($this->n+1));
1933
+        $this->out('0 ' . ($this->n + 1));
1934 1934
         $this->out('0000000000 65535 f ');
1935
-        for ($i=1; $i<=$this->n; $i++) {
1935
+        for ($i = 1; $i <= $this->n; $i++) {
1936 1936
             $this->out(sprintf('%010d 00000 n ', $this->offsets[$i]));
1937 1937
         }
1938 1938
         //Trailer
@@ -1943,6 +1943,6 @@  discard block
 block discarded – undo
1943 1943
         $this->out('startxref');
1944 1944
         $this->out($o);
1945 1945
         $this->out('%%EOF');
1946
-        $this->state=3;
1946
+        $this->state = 3;
1947 1947
     }
1948 1948
 }
Please login to merge, or discard this patch.