Esempio n. 1
0
 private function _render($dest = '', $filename = '')
 {
     $un = 72 / 25.4;
     $wFourAreas = $this->pdf->w;
     $hFourAreas = $this->pdf->h;
     //-Menos 1.5CM porque algumas impressoras não conseguem imprimir nos ultimos 1cm da página
     $tMarginFourAreas = 0;
     $rMarginFourAreas = 0;
     $bMarginFourAreas = 0;
     $lMarginFourAreas = 0;
     $wInnerFourAreas = $wFourAreas - $lMarginFourAreas - $rMarginFourAreas;
     $hInnerFourAreas = 0;
     $margins = array(array('l' => $lMarginFourAreas, 'r' => $wFourAreas - $rMarginFourAreas, 't' => $tMarginFourAreas, 'b' => $hFourAreas - $bMarginFourAreas), array('l' => $wFourAreas + $lMarginFourAreas, 'r' => $wFourAreas * 2 - $rMarginFourAreas, 't' => $tMarginFourAreas, 'b' => $hFourAreas - $bMarginFourAreas), array('l' => $lMarginFourAreas, 'r' => $wFourAreas - $rMarginFourAreas, 't' => $hFourAreas + $tMarginFourAreas, 'b' => $hFourAreas * 2 - $bMarginFourAreas), array('l' => $wFourAreas + $lMarginFourAreas, 'r' => $wFourAreas * 2 - $rMarginFourAreas, 't' => $hFourAreas + $tMarginFourAreas, 'b' => $hFourAreas * 2 - $bMarginFourAreas));
     $objetosPostais = $this->plp->getEncomendas();
     $total = count($objetosPostais);
     while (count($objetosPostais)) {
         $this->pdf->AddPage();
         if (Bootstrap::getConfig()->getSimular()) {
             $this->pdf->SetFont('Arial', 'B', 50);
             $this->pdf->SetTextColor(240, 240, 240);
             $this->pdf->SetXY($lMarginFourAreas, $hFourAreas - $this->pdf->getLineHeigth());
             $this->pdf->MultiCellXp($this->pdf->w - $this->pdf->lMargin - $this->pdf->rMargin, "Simulação Documento sem valor", null, 0, 'C');
             $this->pdf->SetXY($lMarginFourAreas, $margins[2]['t'] + $hFourAreas - $this->pdf->getLineHeigth());
             $this->pdf->MultiCellXp($this->pdf->w - $this->pdf->lMargin - $this->pdf->rMargin, "Simulação Documento sem valor", null, 0, 'C');
             $this->pdf->SetTextColor(0, 0, 0);
         }
         //            $crossMargin = 50;
         //            $this->pdf->SetDrawColor(200, 200, 200);
         //            for ($lineY = $crossMargin; $lineY < $this->pdf->h - $crossMargin; $lineY += 10) {
         //                $this->pdf->Line($wFourAreas, $lineY, $wFourAreas, $lineY + 3);
         //            }
         //            for ($lineX = $crossMargin; $lineX < $this->pdf->w - $crossMargin; $lineX += 10) {
         //                $this->pdf->Line($lineX, $hFourAreas, $lineX + 3, $hFourAreas);
         //            }
         $this->pdf->SetDrawColor(0, 0, 0);
         for ($area = 0; $area < 1; $area++) {
             if (!count($objetosPostais)) {
                 break;
             }
             /** @var $objetoPostal \PhpSigep\Model\ObjetoPostal */
             $objetoPostal = array_shift($objetosPostais);
             $lPosFourAreas = $margins[$area]['l'];
             $rPosFourAreas = $margins[$area]['r'];
             $tPosFourAreas = $margins[$area]['t'];
             $bPosFourAreas = $margins[$area]['b'];
             // Logo
             $this->pdf->SetXY($lPosFourAreas, $tPosFourAreas);
             $this->setFillColor(222, 222, 222);
             $headerColWidth = $wInnerFourAreas / 3;
             $headerHeigth = 106;
             if ($this->logoFile) {
                 $this->pdf->Image($this->logoFile, 3, 0, 25);
             }
             // Chancela
             $this->pdf->SetXY(66, $this->pdf->GetY() + 3);
             $this->setFillColor(150, 150, 200);
             $wChancela = 101.5;
             $hChancela = 72.5;
             $lPosChancela = 66;
             $tPosChancela = $this->pdf->GetY();
             $servicoDePostagem = $objetoPostal->getServicoDePostagem();
             $nomeRemetente = $this->plp->getRemetente()->getNome();
             $accessData = $this->plp->getAccessData();
             switch ($servicoDePostagem->getCodigo()) {
                 case ServicoDePostagem::SERVICE_PAC_41068:
                 case ServicoDePostagem::SERVICE_PAC_41106:
                 case ServicoDePostagem::SERVICE_PAC_GRANDES_FORMATOS:
                     if ($this->layoutPac === CartaoDePostagem::TYPE_CHANCELA_PAC) {
                         $chancela = new Pac($lPosChancela, $tPosChancela, $nomeRemetente, $accessData);
                     } else {
                         $chancela = new Pac2016($lPosChancela, $tPosChancela, $nomeRemetente, $accessData);
                     }
                     break;
                 case ServicoDePostagem::SERVICE_E_SEDEX_STANDARD:
                     if ($this->layoutSedex === CartaoDePostagem::TYPE_CHANCELA_SEDEX) {
                         $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_E_SEDEX, $accessData);
                     } else {
                         $chancela = new Sedex2016($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_E_SEDEX, $accessData);
                     }
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_40096:
                 case ServicoDePostagem::SERVICE_SEDEX_40436:
                 case ServicoDePostagem::SERVICE_SEDEX_40444:
                 case ServicoDePostagem::SERVICE_SEDEX_A_VISTA:
                 case ServicoDePostagem::SERVICE_SEDEX_VAREJO_A_COBRAR:
                 case ServicoDePostagem::SERVICE_SEDEX_PAGAMENTO_NA_ENTREGA:
                 case ServicoDePostagem::SERVICE_SEDEX_AGRUPADO:
                     if ($this->layoutSedex === CartaoDePostagem::TYPE_CHANCELA_SEDEX) {
                         $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX, $accessData);
                     } else {
                         $chancela = new Sedex2016($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX, $accessData);
                     }
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_12:
                     if ($this->layoutSedex === CartaoDePostagem::TYPE_CHANCELA_SEDEX) {
                         $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX_12, $accessData);
                     } else {
                         $chancela = new Sedex2016($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX_12, $accessData);
                     }
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_10:
                 case ServicoDePostagem::SERVICE_SEDEX_10_PACOTE:
                     if ($this->layoutSedex === CartaoDePostagem::TYPE_CHANCELA_SEDEX) {
                         $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX_10, $accessData);
                     } else {
                         $chancela = new Sedex2016($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX_10, $accessData);
                     }
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_HOJE_40290:
                 case ServicoDePostagem::SERVICE_SEDEX_HOJE_40878:
                     if ($this->layoutSedex === CartaoDePostagem::TYPE_CHANCELA_SEDEX) {
                         $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX_HOJE, $accessData);
                     } else {
                         $chancela = new Sedex2016($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX_HOJE, $accessData);
                     }
                     break;
                 case ServicoDePostagem::SERVICE_CARTA_COMERCIAL_A_FATURAR:
                 case ServicoDePostagem::SERVICE_CARTA_REGISTRADA:
                     if ($this->layoutCarta === CartaoDePostagem::TYPE_CHANCELA_CARTA) {
                         $chancela = new Carta($lPosChancela, $tPosChancela, $nomeRemetente, $accessData);
                     } else {
                         $chancela = new Carta2016($lPosChancela, $tPosChancela, $nomeRemetente, $accessData);
                     }
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_REVERSO:
                 default:
                     $chancela = null;
                     break;
             }
             if ($chancela) {
                 $chancela->draw($this->pdf);
             }
             // Título da etiqueta
             if ($this->idPlpCorreios > 0) {
                 $lPosHeaderCol2 = $headerColWidth + $lPosFourAreas;
                 // $this->pdf->SetXY($lPosHeaderCol2, $tPosFourAreas);
                 // $this->setFillColor(200, 200, 200);
                 // $this->pdf->SetFontSize(12);
                 // $this->pdf->SetFont('', 'B');
                 // $this->t($headerColWidth, 'Cartão de Postagem', 2, 'C');
                 // Número da plp
                 $this->pdf->SetXY($lPosHeaderCol2, $tPosFourAreas + 32);
                 $this->setFillColor(150, 200, 200);
                 $this->pdf->SetFont('', '');
                 $this->pdf->SetFontSize(9);
                 $this->t($headerColWidth * 3, 'PLP: ' . $this->idPlpCorreios, 0, 'C');
             }
             // Volume
             $this->setFillColor(100, 150, 200);
             $this->pdf->SetXY(0, 30);
             $nf = (double) $objetoPostal->getDestino()->getNumeroNotaFiscal();
             if ($nf > 0) {
                 $nf = '    NF: ' . $nf;
             }
             $numeroPedido = trim($objetoPostal->getDestino()->getNumeroPedido());
             if (!empty($numeroPedido)) {
                 $numeroPedido = '    Pedido: ' . $numeroPedido;
             }
             $this->pdf->SetFontSize(7);
             $this->t($this->pdf->w, 'Volume: 1/1    ' . 'Peso(kg): ' . (double) $objetoPostal->getPeso() . $nf . $numeroPedido, 1, 'C', null);
             // Número da etiqueta
             $this->setFillColor(100, 100, 200);
             $this->pdf->SetXY(0, $this->pdf->GetY() + 1);
             $this->pdf->SetFontSize(9);
             $this->pdf->SetFont('', 'B');
             $etiquetaComDv = $objetoPostal->getEtiqueta()->getEtiquetaComDv();
             $this->t($wInnerFourAreas, $etiquetaComDv, 1, 'C');
             // Código de barras da etiqueta
             $this->setFillColor(0, 0, 0);
             $tPosEtiquetaBarCode = $this->pdf->GetY();
             $hEtiquetaBarCode = 22;
             $wEtiquetaBarCode = 78;
             $code128 = new \PhpSigep\Pdf\Script\BarCode128();
             $code128->draw($this->pdf, ($this->pdf->w - $wEtiquetaBarCode) / 2, $tPosEtiquetaBarCode, $etiquetaComDv, $wEtiquetaBarCode, $hEtiquetaBarCode);
             // Nome legivel, doc e rubrica
             //
             $this->pdf->SetFontSize(7);
             $this->pdf->SetXY(1, $this->pdf->GetY() + 23);
             $this->t(0, 'Nome Legível:___________________________________________', 1, 'L', null);
             $this->pdf->SetXY(1, $this->pdf->GetY() + 1);
             $this->t(0, 'Documento:_______________________Rubrica:_____________________', 1, 'L', null);
             // Destinatário
             $wAddressLeftCol = $this->pdf->w - 5;
             $tPosAfterNameBlock = 71;
             $t = $this->writeDestinatario($lPosFourAreas, $tPosAfterNameBlock, $wAddressLeftCol, $objetoPostal);
             $destino = $objetoPostal->getDestino();
             if ($destino instanceof \PhpSigep\Model\DestinoNacional) {
                 // Número do CEP
                 $cep = $destino->getCep();
                 $cep = preg_replace('/[^\\d]/', '', $cep);
                 $tPosCepBarCode = $t + 1;
                 // Etiqueta do CEP
                 $hCepBarCode = 22;
                 $wCepBarCode = 47;
                 $this->setFillColor(0, 0, 0);
                 $code128->draw($this->pdf, 6, $tPosCepBarCode, $cep, $wCepBarCode, $hCepBarCode);
                 $valorDeclarado = null;
                 $sSer = "";
                 foreach ($objetoPostal->getServicosAdicionais() as $servicoAdicional) {
                     if ($servicoAdicional->is(ServicoAdicional::SERVICE_AVISO_DE_RECEBIMENTO)) {
                         $temAr = true;
                         $sSer = $sSer . "01";
                     } else {
                         if ($servicoAdicional->is(ServicoAdicional::SERVICE_MAO_PROPRIA)) {
                             $temMp = true;
                             $sSer = $sSer . "02";
                         } else {
                             if ($servicoAdicional->is(ServicoAdicional::SERVICE_VALOR_DECLARADO)) {
                                 $temVd = true;
                                 $sSer = $sSer . "19";
                                 $valorDeclarado = $servicoAdicional->getValorDeclarado();
                             } else {
                                 if ($servicoAdicional->is(ServicoAdicional::SERVICE_REGISTRO)) {
                                     $temRe = true;
                                     $sSer = $sSer . "25";
                                 }
                             }
                         }
                     }
                 }
                 while (strlen($sSer) < 12) {
                     $sSer = $sSer . "00";
                 }
                 $sM2Dtext = $this->getM2Dstr($cep, $objetoPostal->getDestinatario()->getNumero(), $this->plp->getRemetente()->getCep(), $this->plp->getRemetente()->getNumero(), $etiquetaComDv, $sSer, $this->plp->getAccessData()->getCartaoPostagem(), $objetoPostal->getServicoDePostagem()->getCodigo(), $valorDeclarado, $objetoPostal->getDestinatario()->getTelefone());
                 require_once 'Semacode.php';
                 $semacode = new \Semacode();
                 $semaCodeGD = $semacode->asGDImage($sM2Dtext);
                 $this->setFillColor(222, 222, 222);
                 $this->pdf->gdImage($semaCodeGD, 35, 3, 25);
                 imagedestroy($semaCodeGD);
             }
             $this->writeRemetente(0, $this->pdf->GetY() + $hCepBarCode + 5, $wAddressLeftCol, $this->plp->getRemetente());
         }
     }
     if ($dest == 'S') {
         return $this->pdf->Output($filename, $dest);
     } else {
         $this->pdf->Output($filename, $dest);
     }
 }
Esempio n. 2
0
/**
 * Build a semacode from given URL parameters
 *
 * Parameters:
 *
 * text - the text to encode (limited charset)
 * type - the wanted outoput: svg, png or table
 * size - for png type only: width of the image
 */
require_once 'semacode.php';
$text = $_REQUEST['text'];
$type = $_REQUEST['type'];
$size = (int) $_REQUEST['size'];
if (!$size) {
    $size = 160;
}
// strip non-supported chars (is this correct?)
$text = preg_replace('/[^\\w!\\"#$%&\'()*+,\\-\\.\\/:;<=>?@[\\_\\]\\[{\\|}~\\r*]+ /', '', $text);
// encode
$semacode = new Semacode();
if ($type == 'png') {
    $semacode->sendPNG($text, $size);
} elseif ($type == 'svg') {
    header('Content-Type: image/svg');
    echo $semacode->asSVG($text);
} else {
    echo '<html><body>';
    echo $semacode->asHTMLTable($text);
    echo '</body></html>';
}
Esempio n. 3
0
 private function _render()
 {
     $un = 72 / 25.4;
     $wFourAreas = $this->pdf->w / 2;
     $hFourAreas = ($this->pdf->h - $un * 15) / 2;
     //-Menos 1.5CM porque algumas impressoras não conseguem imprimir nos ultimos 1cm da página
     $tMarginFourAreas = $un * 5;
     $rMarginFourAreas = $un * 5;
     $bMarginFourAreas = $un * 5;
     $lMarginFourAreas = $un * 5;
     $wInnerFourAreas = $wFourAreas - $lMarginFourAreas - $rMarginFourAreas;
     $hInnerFourAreas = $hFourAreas - $tMarginFourAreas - $bMarginFourAreas;
     $margins = array(array('l' => $lMarginFourAreas, 'r' => $wFourAreas - $rMarginFourAreas, 't' => $tMarginFourAreas, 'b' => $hFourAreas - $bMarginFourAreas), array('l' => $wFourAreas + $lMarginFourAreas, 'r' => $wFourAreas * 2 - $rMarginFourAreas, 't' => $tMarginFourAreas, 'b' => $hFourAreas - $bMarginFourAreas), array('l' => $lMarginFourAreas, 'r' => $wFourAreas - $rMarginFourAreas, 't' => $hFourAreas + $tMarginFourAreas, 'b' => $hFourAreas * 2 - $bMarginFourAreas), array('l' => $wFourAreas + $lMarginFourAreas, 'r' => $wFourAreas * 2 - $rMarginFourAreas, 't' => $hFourAreas + $tMarginFourAreas, 'b' => $hFourAreas * 2 - $bMarginFourAreas));
     $objetosPostais = $this->plp->getEncomendas();
     $total = count($objetosPostais);
     while (count($objetosPostais)) {
         $this->pdf->AddPage();
         if (Bootstrap::getConfig()->getSimular()) {
             $this->pdf->SetFont('Arial', 'B', 50);
             $this->pdf->SetTextColor(240, 240, 240);
             $this->pdf->SetXY($lMarginFourAreas, $hFourAreas / 2 - $this->pdf->getLineHeigth() / 2);
             $this->pdf->MultiCellXp($this->pdf->w - $this->pdf->lMargin - $this->pdf->rMargin, "Simulação Documento sem valor", null, 0, 'C');
             $this->pdf->SetXY($lMarginFourAreas, $margins[2]['t'] + $hFourAreas / 2 - $this->pdf->getLineHeigth() / 2);
             $this->pdf->MultiCellXp($this->pdf->w - $this->pdf->lMargin - $this->pdf->rMargin, "Simulação Documento sem valor", null, 0, 'C');
             $this->pdf->SetTextColor(0, 0, 0);
         }
         $crossMargin = 50;
         $this->pdf->SetDrawColor(200, 200, 200);
         for ($lineY = $crossMargin; $lineY < $this->pdf->h - $crossMargin; $lineY += 10) {
             $this->pdf->Line($wFourAreas, $lineY, $wFourAreas, $lineY + 3);
         }
         for ($lineX = $crossMargin; $lineX < $this->pdf->w - $crossMargin; $lineX += 10) {
             $this->pdf->Line($lineX, $hFourAreas, $lineX + 3, $hFourAreas);
         }
         $this->pdf->SetDrawColor(0, 0, 0);
         for ($area = 0; $area < 4; $area++) {
             if (!count($objetosPostais)) {
                 break;
             }
             /** @var $objetoPostal \PhpSigep\Model\ObjetoPostal */
             $objetoPostal = array_shift($objetosPostais);
             $lPosFourAreas = $margins[$area]['l'];
             $rPosFourAreas = $margins[$area]['r'];
             $tPosFourAreas = $margins[$area]['t'];
             $bPosFourAreas = $margins[$area]['b'];
             // Logo
             $this->pdf->SetXY($lPosFourAreas, $tPosFourAreas);
             $this->setFillColor(222, 222, 222);
             $headerColWidth = $wInnerFourAreas / 3;
             $headerHeigth = 106;
             if ($this->logoFile) {
                 $this->pdf->Image($this->logoFile);
             }
             //$this->pdf->Line($lPosFourAreas, $tPosFourAreas, $lPosFourAreas, $bPosFourAreas);
             //$this->pdf->Line($lPosFourAreas, $tPosFourAreas, $rPosFourAreas, $tPosFourAreas);
             //$this->pdf->Line($rPosFourAreas, $tPosFourAreas, $rPosFourAreas, $bPosFourAreas);
             //$this->pdf->Line($lPosFourAreas, $bPosFourAreas, $rPosFourAreas, $bPosFourAreas);
             //				$this->t($headerColWidth, 'Logo', 0, 'C', $headerHeigth);
             //$this->pdf->Line(
             //    $headerColWidth + $lPosFourAreas,
             //    $tPosFourAreas,
             //    $headerColWidth + $lPosFourAreas,
             //    $tPosFourAreas + $headerHeigth
             //);
             //$this->pdf->Line(
             //    $lPosFourAreas,
             //    $tPosFourAreas + $headerHeigth,
             //    $lPosFourAreas + $headerColWidth,
             //    $tPosFourAreas + $headerHeigth
             //);
             // Título da etiqueta
             if ($this->idPlpCorreios > 0) {
                 $lPosHeaderCol2 = $headerColWidth + $lPosFourAreas;
                 $this->pdf->SetXY($lPosHeaderCol2, $tPosFourAreas);
                 $this->setFillColor(200, 200, 200);
                 $this->pdf->SetFontSize(15);
                 $this->pdf->SetFont('', 'B');
                 $this->t($headerColWidth * 2, 'Cartão de Postagem', 2, 'C');
                 // Número da plp
                 $this->setFillColor(150, 200, 200);
                 $this->pdf->SetFont('', '');
                 $this->pdf->SetFontSize(10);
                 $this->t($headerColWidth * 2, $this->idPlpCorreios, 0, 'C');
             }
             // Chancela
             $this->setFillColor(150, 150, 200);
             $wChancela = 101.5;
             $hChancela = 72.5;
             $lPosChancela = $rPosFourAreas - $wChancela;
             $bPosHeader = $tPosFourAreas + $headerHeigth;
             $tPosChancela = $bPosHeader - $hChancela - 20 + 22;
             $this->pdf->SetXY($lPosChancela, $tPosChancela);
             //$this->t($wChancela, 'Chancela', 0, 'C', $hChancela);
             $servicoDePostagem = $objetoPostal->getServicoDePostagem();
             $nomeRemetente = $this->plp->getRemetente()->getNome();
             $accessData = $this->plp->getAccessData();
             switch ($servicoDePostagem->getCodigo()) {
                 case ServicoDePostagem::SERVICE_PAC_41068:
                 case ServicoDePostagem::SERVICE_PAC_41106:
                 case ServicoDePostagem::SERVICE_PAC_GRANDES_FORMATOS:
                     $chancela = new Pac($lPosChancela, $tPosChancela, $nomeRemetente, $accessData);
                     break;
                 case ServicoDePostagem::SERVICE_E_SEDEX_STANDARD:
                     $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_E_SEDEX, $accessData);
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_40096:
                 case ServicoDePostagem::SERVICE_SEDEX_40436:
                 case ServicoDePostagem::SERVICE_SEDEX_40444:
                 case ServicoDePostagem::SERVICE_SEDEX_A_VISTA:
                 case ServicoDePostagem::SERVICE_SEDEX_VAREJO_A_COBRAR:
                 case ServicoDePostagem::SERVICE_SEDEX_PAGAMENTO_NA_ENTREGA:
                 case ServicoDePostagem::SERVICE_SEDEX_AGRUPADO:
                     $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX, $accessData);
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_12:
                     $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX_12, $accessData);
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_10:
                 case ServicoDePostagem::SERVICE_SEDEX_10_PACOTE:
                     $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX_10, $accessData);
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_HOJE_40290:
                 case ServicoDePostagem::SERVICE_SEDEX_HOJE_40878:
                     $chancela = new Sedex($lPosChancela, $tPosChancela, $nomeRemetente, Sedex::SERVICE_SEDEX_HOJE, $accessData);
                     break;
                 case ServicoDePostagem::SERVICE_CARTA_COMERCIAL_A_FATURAR:
                 case ServicoDePostagem::SERVICE_CARTA_REGISTRADA:
                     $chancela = new Carta($lPosChancela, $tPosChancela, $nomeRemetente, $accessData);
                     break;
                 case ServicoDePostagem::SERVICE_SEDEX_REVERSO:
                 default:
                     $chancela = null;
                     break;
             }
             if ($chancela) {
                 $chancela->draw($this->pdf);
             }
             // Peso
             //                $this->setFillColor(100, 150, 200);
             //                $this->pdf->SetFontSize(9);
             //                $lineHeigth = $this->pdf->getLineHeigth(100 / $this->pdf->k);
             //                $this->pdf->SetXY($lPosHeaderCol2, ($bPosHeader - $lineHeigth * 2) + 10);
             //                $this->t(
             //                    $lPosChancela - $lPosHeaderCol2,
             //                    'Peso: ' . ((float)$objetoPostal->getPeso()) . 'kg',
             //                    2,
             //                    'C',
             //                    $lineHeigth
             //                );
             // Volume
             $this->setFillColor(100, 150, 200);
             $this->pdf->SetXY($lPosFourAreas + 43, $bPosHeader + 15);
             //				$this->t($lPosChancela - $lPosHeaderCol2, 'Volume: ' . ($total - count($objetosPostais)) . '/' . $total, 0, 'C', $lineHeigth);
             $nf = (double) $objetoPostal->getDestino()->getNumeroNotaFiscal();
             if ($nf > 0) {
                 $nf = '    NF: ' . $nf;
             }
             $this->t($lPosChancela, 'Volume: 1/1    ' . 'Peso(kg): ' . (double) $objetoPostal->getPeso() . $nf, 1, 'C', null);
             // Número da etiqueta
             $this->setFillColor(100, 100, 200);
             $this->pdf->SetXY($lPosFourAreas, $bPosHeader + 35);
             $this->pdf->SetFontSize(10);
             $this->pdf->SetFont('', 'B');
             $etiquetaComDv = $objetoPostal->getEtiqueta()->getEtiquetaComDv();
             $this->t($wInnerFourAreas, $etiquetaComDv, 1, 'C');
             // Código de barras da etiqueta
             $this->setFillColor(0, 0, 0);
             $hEtiquetaBarCode = 40;
             $tPosEtiquetaBarCode = $this->pdf->GetY();
             $wEtiquetaBarCode = $un * 65.44;
             $code128 = new \PhpSigep\Pdf\Script\BarCode128();
             $code128->draw($this->pdf, $lPosFourAreas + $wInnerFourAreas / 2 - $wEtiquetaBarCode / 2, $tPosEtiquetaBarCode, $etiquetaComDv, $wEtiquetaBarCode, $hEtiquetaBarCode);
             // Destinatário
             $wAddressLeftCol = $wInnerFourAreas / 4 * 2.2;
             $wAddressRightCol = $wInnerFourAreas - $wAddressLeftCol;
             $lAddressRigthCol = $wAddressLeftCol + $lPosFourAreas;
             $tPosAfterBarCode = $tPosEtiquetaBarCode + $hEtiquetaBarCode + 5;
             $t = $this->writeDestinatario($lPosFourAreas, $tPosAfterBarCode, $wAddressLeftCol, $objetoPostal);
             $t += $this->pdf->getLineHeigth() / 2;
             $this->writeRemetente($lPosFourAreas, $t, $wAddressLeftCol, $this->plp->getRemetente());
             $destino = $objetoPostal->getDestino();
             $hCepBarCode = 0;
             if ($destino instanceof \PhpSigep\Model\DestinoNacional) {
                 // Número do CEP
                 $cep = $destino->getCep();
                 $cep = preg_replace('/[^\\d]/', '', $cep);
                 $this->setFillColor(215, 115, 15);
                 $this->pdf->SetXY($lAddressRigthCol, $tPosAfterBarCode + 15);
                 $this->t($wAddressRightCol, $cep, 2, 'C');
                 $tPosCepBarCode = $this->pdf->GetY();
                 // Etiqueta do CEP
                 $hCepBarCode = 25;
                 $wCepBarCode = $un * 38.44;
                 $this->setFillColor(0, 0, 0);
                 $code128->draw($this->pdf, $lAddressRigthCol + $wAddressRightCol / 2 - $wCepBarCode / 2, $tPosCepBarCode, $cep, $wCepBarCode, $hCepBarCode);
                 $valorDeclarado = null;
                 $sSer = "";
                 foreach ($objetoPostal->getServicosAdicionais() as $servicoAdicional) {
                     if ($servicoAdicional->is(ServicoAdicional::SERVICE_AVISO_DE_RECEBIMENTO)) {
                         $temAr = true;
                         $sSer = $sSer . "01";
                     } else {
                         if ($servicoAdicional->is(ServicoAdicional::SERVICE_MAO_PROPRIA)) {
                             $temMp = true;
                             $sSer = $sSer . "02";
                         } else {
                             if ($servicoAdicional->is(ServicoAdicional::SERVICE_VALOR_DECLARADO)) {
                                 $temVd = true;
                                 $sSer = $sSer . "19";
                                 $valorDeclarado = $servicoAdicional->getValorDeclarado();
                             } else {
                                 if ($servicoAdicional->is(ServicoAdicional::SERVICE_REGISTRO)) {
                                     $temRe = true;
                                     $sSer = $sSer . "25";
                                 }
                             }
                         }
                     }
                 }
                 while (strlen($sSer) < 12) {
                     $sSer = $sSer . "00";
                 }
                 $sM2Dtext = $this->getM2Dstr($cep, $objetoPostal->getDestinatario()->getNumero(), $this->plp->getRemetente()->getCep(), $this->plp->getRemetente()->getNumero(), $etiquetaComDv, $sSer, $this->plp->getAccessData()->getCartaoPostagem(), $objetoPostal->getServicoDePostagem()->getCodigo(), $valorDeclarado, $objetoPostal->getDestinatario()->getTelefone(), $objetoPostal->getDestinatario()->getComplemento());
                 require_once 'Semacode.php';
                 $semacode = new \Semacode();
                 $semaCodeGD = $semacode->asGDImage($sM2Dtext);
                 $this->setFillColor(222, 222, 222);
                 $this->pdf->gdImage($semaCodeGD, $lPosFourAreas + 108, $tPosFourAreas + 50, 42);
                 imagedestroy($semaCodeGD);
             }
         }
     }
     $this->pdf->Output();
 }