Convert Php billet to PDF

I need to convert HTML generated PHP billets to PDF.

Codeigniter-ticket

I tried to use the DomPDF library, as well as FPDF and finally, MPDF (the latter, from what I read in some forums, would be better, for CSS compatibility issues).

My work is being in the CodeIgniter framework.

Someone, please, who has already experienced this problem can help me solve this problem, since I am getting the errors below:

Message: Cannot modify header information - headers already sent by (output started at C:\Program Files(x86)\VertrigoServ\www\material\application\libraries\boleto\include \ layout_bb.php: 494)

MPDF error: Some data has already been output to browser, can't send PDF file

And I am not able to generate the PDF.

public function index()
{
    $dados = array(
        // Informações necessárias para todos os bancos
        'dias_de_prazo_para_pagamento' => 5,
        'taxa_boleto'                  => 1,
        'pedido'                       => array(
            'nome'           => 'Serviços de Desenvolvimento Web',
            'quantidade'     => '10',
            'valor_unitario' => '80',
            'numero'         => 10000000025,
            'aceite'         => 'N',
            'especie'        => 'R$',
            'especie_doc'    => 'DM',
        ),
        'sacado'                       => array(
            'nome'     => 'João da Silva',
            'endereco' => 'Av. Meninas Bonitas, 777',
            'cidade'   => 'Sapiranga',
            'uf'       => 'RS',
            'cep'      => '93816-630',
        ),
        // Informações necessárias que são específicas do Banco do Brasil
        'variacao_carteira'            => '019',
        'contrato'                     => 999999,
        'convenio'                     => 7777777,
    );

    // Gera o boleto
    //$this->boleto->bb($dados);
    
    $this->load->helper('mpdf');
    $html = ($this->boleto->bb($dados));
    pdf_create($html, 'boleto' . date('d/m/y'), TRUE);
}
Author: Comunidade, 2019-01-28