1
I need to convert HTML generated PHP boletos to PDF.
I tried to use the Dompdf library, as well as FPDF and finally MPDF (the latter, from what I read on some forums, would be better, for reasons of CSS compatibility).
My work is being in the Codeigniter framework.
Someone, please, who has already been through this problem can help me to 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’m having trouble generating 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);
}
Possible duplicate of Error - "Cannot Modify header information - headers already sent"
– Pedro Augusto
It is not duplicate! I can generate any other type of PDF, but I could not generate using the PHP boleto, maybe someone has gone through this
– Wagner Fillio
Did you just try to generate the boleto on the screen? To see if there is no error.
– Sr. André Baill
On the screen it generates normally, in PDF that does not generate
– Wagner Fillio
Hey, it’s wrong: $html = ($this->boleto->bb($dados)); ... $data['boleto'] = $this->boleto->bb($dados); $html = $this->load->view('boleto', $data);
– Sr. André Baill
The PDF has some particularities, you have the HTML, colococa here tbm
– Sr. André Baill
But why should I call a view?
$this->load->view('boleto', $data);
I don’t have this view. If you look in the https://github.com/natanfelles/codeigniterboletorepository, you don’t need to view– Wagner Fillio