boleto_php_mpdf
Olá, meu nome é Airton Fraga Porto Junior, sou tecnólogo do curso de Internet e Redes, e este é meu primeiro post no blog.fragasoft.com.br.

Vou tentar neste post explicar como salvar um boleto gerado pelo Boleto PHP em PDF utilizando a biblioteca MPDF

Costumamos fazer a implementação do Boleto PHP no site de alguns clientes, neste boleto dávamos somente a opção de impressão do mesmo, mas então um de nossos cliente me questionou se a pessoa que vai imprimir o boleto não estivesse com a impressora preparada no momento e quisesse  salvar este boleto para um pagamento ou impressão futura.

Com este problema na mão comecei a pesquisar entra as varias bibliotecas php para conversão de HML em PDF.

A primeira que tentei foi a fpdf, a segunda dompdf então me deparei com a MPDF.

As bibliotecas fpdf e a dompdf são boas bibliotecas de conversão, mas como sempre tenho o tempo meio corrido e a MPDF me atendeu mais rapidamente.


Faça o download de Boleto PHP.
Faça o download de MPDF.1 º Copie a pasta MPDF5 para dentro de boletophpFicando assim boletophp/ MPDF52º No arquivo  boletophp/include/layout_cef.php, faça um link para salvar o boleto

<a target="_self" HREF=".. /boletophp/boleto_cef_sigcb_PDF.php">
 <img src=".. /boletophp/imagens/disk.png" alt="" style='border: 0px; padding: 1px' border="0"></a>
3º Pegue todas as variáveis do arquivo  boletophp/include/layout_cef.php e salve em variáveis de sessão no final do arquivo.
<?php
 $_SESSION["identificacao"] =  $dadosboleto["identificacao"];
 $_SESSION["linha_digitavel"] =  $dadosboleto["linha_digitavel"];
 $_SESSION["valor_boleto"] =  $dadosboleto["valor_boleto"];
 $_SESSION["identificacao"] =  $dadosboleto["identificacao"];
 $_SESSION["cpf_cnpj"] =  $dadosboleto["cpf_cnpj"];
 $_SESSION["endereco"] =  $dadosboleto["endereco"];
 $_SESSION["endereco"] =  $dadosboleto["cidade_uf"];
 $_SESSION["codigo_banco_com_dv"] =  $dadosboleto["codigo_banco_com_dv"];
 $_SESSION["linha_digitavel"] =  $dadosboleto["linha_digitavel"];
 $_SESSION["cedente"] =  $dadosboleto["cedente"];
 $_SESSION["agencia_codigo"] =  $dadosboleto["agencia_codigo"];
 $_SESSION["agen_cod"] =  $dadosboleto["agencia_codigo"];
 $_SESSION["especie"] =  $dadosboleto["especie"];
 $_SESSION["quantidade"] =  $dadosboleto["quantidade"];
 $_SESSION["nosso_numero"] =  $dadosboleto["nosso_numero"];
 $_SESSION["numero_documento"] =  $dadosboleto["numero_documento"];
 $_SESSION["cpf_cnpj"] =  $dadosboleto["cpf_cnpj"];
 $_SESSION["data_vencimento"] =  $dadosboleto["data_vencimento"];
 $_SESSION["valor_boleto"] =  $dadosboleto["valor_boleto"];
 $_SESSION["sacado"] =  $dadosboleto["sacado"];
 $_SESSION["demonstrativo1"] =  $dadosboleto["demonstrativo1"];
 $_SESSION["demonstrativo2"] =  $dadosboleto["demonstrativo2"];
 $_SESSION["demonstrativo3"] =  $dadosboleto["demonstrativo3"];
 $_SESSION["codigo_banco_com_dv"] =  $dadosboleto["codigo_banco_com_dv"];
 $_SESSION["linha_digitavel"] =  $dadosboleto["linha_digitavel"];
 $_SESSION["data_vencimento"] =  $dadosboleto["data_vencimento"];
 $_SESSION["cedente"] =  $dadosboleto["cedente"];
 $_SESSION["agencia_codigo"] =  $dadosboleto["agencia_codigo"];
 $_SESSION["data_documento"] =  $dadosboleto["data_documento"];
 $_SESSION["numero_documento"] =  $dadosboleto["numero_documento"];
 $_SESSION["especie_doc"] =  $dadosboleto["especie_doc"];
 $_SESSION["aceite"] =  $dadosboleto["aceite"];
 $_SESSION["data_processamento"] =  $dadosboleto["data_processamento"];
 $_SESSION["nosso_numero"] =  $dadosboleto["nosso_numero"];
 $_SESSION["carteira"] =  $dadosboleto["carteira"];
 $_SESSION["especie"] =  $dadosboleto["especie"];
 $_SESSION["quantidade"] =  $dadosboleto["quantidade"];
 $_SESSION["valor_unitario"] =  $dadosboleto["valor_unitario"];
 $_SESSION["valor_boleto"] =  $dadosboleto["valor_boleto"];
 $_SESSION["instrucoes1"] =  $dadosboleto["instrucoes1"];
 $_SESSION["instrucoes2"] =  $dadosboleto["instrucoes2"];
 $_SESSION["instrucoes3"] =  $dadosboleto["instrucoes3"];
 $_SESSION["instrucoes4"] =  $dadosboleto["instrucoes4"];
 $_SESSION["sacado"] =  $dadosboleto["sacado"];
 $_SESSION["cpf_cnpj_"] =  $dadosboleto["cpf_cnpj_"];
 $_SESSION["endereco1"] =  $dadosboleto["endereco1"];
 $_SESSION["endereco2"] =  $dadosboleto["endereco2"];
 $_SESSION["codigo_barras"] =  $dadosboleto["codigo_barras"];
 fbarcode2($dadosboleto["codigo_barras"]);
 ?>
4º Crie o arquivo  boletophp/boleto_cef_sigcb_PDF.php
observe que este arquivo não esta dentro do diretório include5º coloque todo layout de   dentro da variável $html
Alterando a s variáveis $dadosboleto  para $_SESSION.
Assim
 <?php session_start();
 include("MPDF54/mpdf.php");
 $html = '
 <HTML>
 <HEAD>
 <TITLE>'.$_SESSION["identificacao"].'</TITLE>
 <meta http-equiv="Content-Type" content="text/html;  charset=iso-8859-1" />
 <meta name="Generator" content="Projeto BoletoPHP - www.boletophp.com.br - Licença GPL" />
 <style type=text/css>
 <!--
 .cp {
 font: bold 10px Arial;
 color: black
 }
 <!--
 .ti {
 font: 9px Arial, Helvetica, sans-serif
 }
 <!--
 .ld {
 font: bold 15px Arial;
 color: #000000
 }
 <!--
 .ct {
 FONT: 9px "Arial Narrow";
 COLOR: #000033
 }
 <!--
 .cn {
 FONT: 9px Arial;
 COLOR: black
 }
 <!--
 .bc {
 font: bold 20px Arial;
 color: #000000
 }
 <!--
 .ld2 {
 font: bold 12px Arial;
 color: #000000
 }
 -->
 </style>
 </head>
 <BODY onLoad="isReady=true" text=#000000 bgColor=#ffffff topMargin=0 rightMargin=0>
 <table width=666 cellspacing=0 cellpadding=0 border=0>
 <TR>
 <TD width="666" height="38" valign=top>
 &nbsp;&nbsp;&nbsp;&nbsp;<span>Linha Digitável:</span> &nbsp;<span> '.$_SESSION["linha_digitavel"].'</span><br>
 &nbsp;&nbsp;&nbsp;&nbsp;<span>Valor:</span> &nbsp;&nbsp; <span>R$'.$_SESSION["valor_boleto"].'</span></td>
 </tr>
 </table>
 <table cellspacing=0 cellpadding=0 width=666 border=0>
 <TBODY>
 <TR>
 <TD width=666><img height=1 src=imagens/6.png width=665 border=0></TD>
 </TR>
 <TR>
 <TD width=666><b>Recibo
 do Sacado</b></TD>
 </tr>
 </tbody>
 </table>
 <table width=666 cellspacing=5 cellpadding=0 border=0 align=Default>
 <tr>
 <td width=41><IMG SRC=" /imagens/logo.jpg"></td>
 <td width=455><span>'.$_SESSION["identificacao"].''.$_SESSION["cpf_cnpj"].'<br>
 '.$_SESSION["endereco"].'<br>
 '.$_SESSION["cidade_uf"].'</span><br></td>
 <td align=center width=150>&nbsp;</td>
 <td align=center width=150>&nbsp;</td>
 </tr>
 </table>
 <BR>
 <table cellspacing=0 cellpadding=0 width=666 border=0>
 <tr>
 <td width=150><IMG
 src=" imagens/logocaixa.jpg" width="150" height="40"
 border=0></td>
 <td width=3 valign=bottom><img height=22 src=imagens/3.png width=2 border=0></td>
 <td width=58 valign=bottom><font>'.$_SESSION["codigo_banco_com_dv"].'</font></td>
 <td width=3 valign=bottom><img height=22 src=imagens/3.png width=2 border=0></td>
 <td width=453 align=right valign=bottom>'.$_SESSION["linha_digitavel"].'</td>
 </tr>
 <tbody>
 <tr>
 <td colspan=5><img height=2 src=imagens/2.png width=666 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=298 height=13 valign=top>Cedente</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=126 height=13 valign=top>Agência/Código
 do Cedente</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=34 height=13 valign=top>Espécie</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=53 height=13 valign=top>Quantidade</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=120 height=13 valign=top>Nosso
 número</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=298 height=12 valign=top>'.$_SESSION["cedente"].'</td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=126 height=12 valign=top> '.$_SESSION["agen_cod"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=34 height=12 valign=top> '.$_SESSION["especie"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=53 height=12 valign=top> '.$_SESSION["quantidade"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=120 height=12 align=right valign=top> '.$_SESSION["nosso_numero"].' </td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=298 height=1><img height=1 src=imagens/2.png width=298 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=126 height=1><img height=1 src=imagens/2.png width=126 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=34 height=1><img height=1 src=imagens/2.png width=34 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=53 height=1><img height=1 src=imagens/2.png width=53 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=120 height=1><img height=1 src=imagens/2.png width=120 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td height=13 colspan=3 valign=top>Número
 do documento</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=132 height=13 valign=top>CPF/CNPJ</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=134 height=13 valign=top>Vencimento</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>Valor
 documento</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td height=12 colspan=3 valign=top> '.$_SESSION["numero_documento"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=132 height=12 valign=top> '.$_SESSION["cpf_cnpj"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=134 height=12 valign=top> '.$_SESSION["data_vencimento"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=12 align=right valign=top> '.$_SESSION["valor_boleto"].' </td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=113 height=1><img height=1 src=imagens/2.png width=113 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=72 height=1><img height=1 src=imagens/2.png width=72 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=132 height=1><img height=1 src=imagens/2.png width=132 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=134 height=1><img height=1 src=imagens/2.png width=134 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=113 height=13 valign=top>(-)
 Desconto / Abatimentos</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=112 height=13 valign=top>(-)
 Outras deduções</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=113 height=13 valign=top>(+)
 Mora / Multa</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=113 height=13 valign=top>(+)
 Outros acréscimos</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>(=)
 Valor cobrado</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=113 height=12></td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=112 height=12></td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=113 height=12></td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=113 height=12></td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=180 height=12></td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=113 height=1><img height=1 src=imagens/2.png width=113 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=112 height=1><img height=1 src=imagens/2.png width=112 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=113 height=1><img height=1 src=imagens/2.png width=113 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=113 height=1><img height=1 src=imagens/2.png width=113 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=659 height=13 valign=top>Sacado</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=659 height=12 valign=top>'.$_SESSION["sacado"].' </td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=659 height=1><img height=1 src=imagens/2.png width=659 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td  width=7 height=12></td>
 <td  width=564 >Demonstrativo</td>
 <td  width=7 height=12></td>
 <td  width=88 >Autenticação
 mecânica</td>
 </tr>
 <tr>
 <td  width=7 ></td>
 <td width=564 >'.$_SESSION["demonstrativo1"].'<br>
 '.$_SESSION["demonstrativo2"].'<br>
 '.$_SESSION["demonstrativo3"].'<br>
 </td>
 <td  width=7 ></td>
 <td  width=88 ></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 width=666 border=0>
 <tbody>
 <tr>
 <td width=7></td>
 <td  width=500><br>
 <br>
 <br></td>
 <td width=159></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 width=666 border=0>
 <tr>
 <td width=666></td>
 </tr>
 <tbody>
 <tr>
 <td width=666>Corte na linha pontilhada</td>
 </tr>
 <tr>
 <td width=666><img height=1 src=imagens/6.png width=665 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 width=666 border=0>
 <tr>
 <td width=150><IMG
 src="imagens/logocaixa.jpg" width="150" height="40"
 border=0></td>
 <td width=3 valign=bottom><img height=22 src=imagens/3.png width=2 border=0></td>
 <td width=58 valign=bottom><font>'.$_SESSION["codigo_banco_com_dv"].'</font></td>
 <td width=3 valign=bottom><img height=22 src=imagens/3.png width=2 border=0></td>
 <td width=453 align=right valign=bottom>  '.$_SESSION["linha_digitavel"].' </td>
 </tr>
 <tbody>
 <tr>
 <td colspan=5><img height=2 src=imagens/2.png width=666 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=472 height=13 valign=top>Local
 de pagamento</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>Vencimento</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=472 height=12 valign=top>PREFERENCIALMENTE NAS CASAS LOT&Eacute;RICAS E AG&Ecirc;NCIAS DA CAIXA</td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=12 align=right valign=top> '.$_SESSION["data_vencimento"].' </td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=472 height=1><img height=1 src=imagens/2.png width=472 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=472 height=13 valign=top>Cedente</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>Agência/Código
 cedente</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=472 height=12 valign=top> '.$_SESSION["cedente"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=12 align=right valign=top> '.$_SESSION["agen_cod"].' </td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=472 height=1><img height=1 src=imagens/2.png width=472 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=113 height=13 valign=top>Data
 do documento</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=153 height=13 valign=top>N<u>o</u> documento</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=62 height=13 valign=top>Espécie
 doc.</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=34 height=13 valign=top>Aceite</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=82 height=13 valign=top>Data
 processamento</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>Nosso
 número</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=113 height=12 valign=top> '.$_SESSION["data_documento"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=153 height=12 valign=top> '.$_SESSION["numero_documento"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=62 height=12 valign=top> '.$_SESSION["especie_doc"].'  </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=34 height=12 valign=top> '.$_SESSION["aceite"].'  </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=82 height=12 valign=top>  '.$_SESSION["data_processamento"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=12 align=right valign=top>'.$_SESSION["nosso_numero"].' </td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=113 height=1><img height=1 src=imagens/2.png width=113 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=153 height=1><img height=1 src=imagens/2.png width=153 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=62 height=1><img height=1 src=imagens/2.png width=62 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=34 height=1><img height=1 src=imagens/2.png width=34 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=82 height=1><img height=1 src=imagens/2.png width=82 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td height=13 COLSPAN="3" valign=top>Uso
 do banco</td>
 <td valign=top height=13 width=7><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=83 height=13 valign=top>Carteira</td>
 <td valign=top height=13 width=7><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=53 height=13 valign=top>Espécie</td>
 <td valign=top height=13 width=7><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=123 height=13 valign=top>Quantidade</td>
 <td valign=top height=13 width=7><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=72 height=13 valign=top> Valor Documento</td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>(=)
 Valor documento</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top height=12 COLSPAN="3"> </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=83 valign=top> '.$_SESSION["carteira"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=53 valign=top> '.$_SESSION["especie"].'  </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=123 valign=top> '.$_SESSION["quantidade"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td  width=72 valign=top> '.$_SESSION["valor_unitario"].' </td>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=12 align=right valign=top> '.$_SESSION["valor_boleto"].' </td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=75 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=31 height=1><img height=1 src=imagens/2.png width=31 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=83 height=1><img height=1 src=imagens/2.png width=83 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=53 height=1><img height=1 src=imagens/2.png width=53 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=123 height=1><img height=1 src=imagens/2.png width=123 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=72 height=1><img height=1 src=imagens/2.png width=72 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 width=666 border=0>
 <tbody>
 <tr>
 <td align=right width=10><table cellspacing=0 cellpadding=0 border=0 align=left>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=1 border=0></td>
 </tr>
 </tbody>
 </table></td>
 <td valign=top width=468 rowspan=5><font>Instruções
 (Texto de responsabilidade do cedente)</font><br>
 <br>
 <FONT> '.$_SESSION["instrucoes1"].'<br>
 '.$_SESSION["instrucoes2"].'<br>
 '.$_SESSION["instrucoes3"].'<br>
 '.$_SESSION["instrucoes4"].'</FONT><br>
 <br>
 </td>
 <td align=right width=188><table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>(-)
 Desconto / Abatimentos</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=180 height=12></td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table></td>
 </tr>
 <tr>
 <td align=right width=10><table cellspacing=0 cellpadding=0 border=0 align=left>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=1 border=0></td>
 </tr>
 </tbody>
 </table></td>
 <td align=right width=188><table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>(-)
 Outras deduções</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=180 height=12></td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table></td>
 </tr>
 <tr>
 <td align=right width=10><table cellspacing=0 cellpadding=0 border=0 align=left>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=1 border=0></td>
 </tr>
 </tbody>
 </table></td>
 <td align=right width=188><table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>(+)
 Mora / Multa</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=180 height=12></td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table></td>
 </tr>
 <tr>
 <td align=right width=10><table cellspacing=0 cellpadding=0 border=0 align=left>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=1 border=0></td>
 </tr>
 </tbody>
 </table></td>
 <td align=right width=188><table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>(+)
 Outros acréscimos</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=180 height=12></td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table></td>
 </tr>
 <tr>
 <td align=right width=10><table cellspacing=0 cellpadding=0 border=0 align=left>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 </tr>
 </tbody>
 </table></td>
 <td align=right width=188><table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>(=)
 Valor cobrado</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td valign=top align=right width=180 height=12></td>
 </tr>
 </tbody>
 </table></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 width=666 border=0>
 <tbody>
 <tr>
 <td valign=top width=666 height=1><img height=1 src=imagens/2.png width=666 border=0></td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=470 height=13 valign=top>Sacado</td>
 <td width=189 valign=top>CPF/CNPJ do Sacado</td>
 </tr>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td height=12 valign=top>'.$_SESSION["sacado"].' </td>
 <td height=12 valign=top>'.$_SESSION["cpf_cnpj_"].'</td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=12><img height=12 src=imagens/1.png width=1 border=0></td>
 <td width=659 height=12 valign=top> '.$_SESSION["endereco1"].' </td>
 </tr>
 </tbody>
 </table>
 <table cellspacing=0 cellpadding=0 border=0>
 <tbody>
 <tr>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=472 height=13 valign=top> '.$_SESSION["endereco2"].' </td>
 <td valign=top width=7 height=13><img height=13 src=imagens/1.png width=1 border=0></td>
 <td width=180 height=13 valign=top>Cód.
 baixa</td>
 </tr>
 <tr>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=472 height=1><img height=1 src=imagens/2.png width=472 border=0></td>
 <td valign=top width=7 height=1><img height=1 src=imagens/2.png width=7 border=0></td>
 <td valign=top width=180 height=1><img height=1 src=imagens/2.png width=180 border=0></td>
 </tr>
 </tbody>
 </table>
 <TABLE cellSpacing=0 cellPadding=0 border=0 width=666>
 <TBODY>
 <TR>
 <TD  width=7 height=12></TD>
 <TD  width=409 >Sacador/Avalista</TD>
 <TD  width=250 >Autenticação
 mecânica - <b>Ficha de Compensação</b></TD>
 </TR>
 <TR>
 <TD  colspan=3 ></TD>
 </tr>
 </tbody>
 </table>
 <TABLE cellSpacing=0 cellPadding=0 width=666 border=0>
 <TBODY>
 <TR>
 <TD vAlign=bottom align=left height=50>'.$_SESSION['codigo_barras_pronto'].'</TD>
 </tr>
 </tbody>
 </table>
 <TABLE cellSpacing=0 cellPadding=0 width=666 border=0>
 <TR>
 <TD width=666></TD>
 </TR>
 <TBODY>
 <TR>
 <TD width=666>Corte
 na linha pontilhada</TD>
 </TR>
 <TR>
 <TD width=666><img height=1 src=imagens/6.png width=665 border=0></TD>
 </tr>
 </tbody>
 </table>
 </BODY>
 </HTML>
 ';
 $mpdf=new mPDF('c');
 $mpdf->mirrorMargins = true;
 $mpdf->SetDisplayMode('fullpage','two');
 $mpdf->WriteHTML($html);
 $mpdf->Output();
 exit;
 ?>

6º e ultima modificação vamos fazer no arquivo
boletophp/include/ funcoes_cef_sigcb.php

Vamos copiar uma função fbarcode($valor)  existente dar outro nome a ela e fazer algumas pequenas alterações para que se consiga imprimir corretamente o código de barras dentro do PDF.
Ficando mais ou menos assim

 
function fbarcode2($valor){
$fino = 1 ;
 $largo = 3 ;
 $altura = 50 ;
$barcodes[0] = "00110" ;
 $barcodes[1] = "10001" ;
 $barcodes[2] = "01001" ;
 $barcodes[3] = "11000" ;
 $barcodes[4] = "00101" ;
 $barcodes[5] = "10100" ;
 $barcodes[6] = "01100" ;
 $barcodes[7] = "00011" ;
 $barcodes[8] = "10010" ;
 $barcodes[9] = "01010" ;
 for($f1=9;$f1>=0;$f1--){
 for($f2=9;$f2>=0;$f2--){
 $f = ($f1 * 10) + $f2 ;
 $texto = "" ;
 for($i=1;$i<6;$i++){
 $texto .=  substr($barcodes[$f1],($i-1),1) . substr($barcodes[$f2],($i-1),1);
 }
 $barcodes[$f] = $texto;
 $_SESSION['codigo_barras_pronto'] = $texto;
 }
 }
//Desenho da barra
//Guarda inicial
$_SESSION['codigo_barras_pronto']  = '<img src=imagens/p.png width='.$fino.' height='.$altura.' border=0>';
 $_SESSION['codigo_barras_pronto'] .= '<img src=imagens/b.png width='.$fino.' height='.$altura.' border=0>';
 $_SESSION['codigo_barras_pronto'] .= '<img src=imagens/p.png width='.$fino.' height='.$altura.' border=0>';
 $_SESSION['codigo_barras_pronto'] .= '<img src=imagens/b.png width='.$fino.' height='.$altura.' border=0>';
 $_SESSION['codigo_barras_pronto'] .= '<img ';
$texto = $valor ;
 if((strlen($texto) % 2) <> 0){
 $texto = "0" . $texto;
 }
// Draw dos dados
 while (strlen($texto) > 0) {
 $i = round(esquerda($texto,2));
 $texto = direita($texto,strlen($texto)-2);
 $f = $barcodes[$i];
 for($i=1;$i<11;$i+=2){
 if (substr($f,($i-1),1) == "0") {
 $f1 = $fino ;
 }else{
 $f1 = $largo ;
 }
$_SESSION['codigo_barras_pronto'] .= 'src=imagens/p.png width='.$f1.' height='.$altura.' border=0><img ';
if (substr($f,$i,1) == "0") {
 $f2 = $fino ;
 }else{
 $f2 = $largo ;
 }
$_SESSION['codigo_barras_pronto'] .= 'src=imagens/b.png width='.$f2.' height='.$altura.' border=0><img ';
}
 }
// Draw guarda final
$_SESSION['codigo_barras_pronto'] .= 'src=imagens/p.png width='.$largo.' height='.$altura.' border=0>';
 $_SESSION['codigo_barras_pronto'] .= '<img src=imagens/b.png width='.$fino.' height='.$altura.' border=0>';
 $_SESSION['codigo_barras_pronto'] .= '<img src=imagens/p.png width=1 height='.$altura.' border=0>';
 } //Fim da função

 

Bem por enquanto é isso, façam seus testes, o conselho que dou é levar o boleto salvo em PDF até sua agencia bancaria para homologação.