Skip to content

Send function not working properly #97

Closed
@carlotrimarchi

Description

@carlotrimarchi

Hi,
I'm trying to generate pdf files in Codeigniter.

I set the library like this:

    $this->load->library('mypdf');
    $this->pdf = new Pdf;
    $options = array(
        'binary' => '/usr/local/bin/wkhtmltopdf'
    );
    $this->pdf->setOptions($options);
    $content = $this->load->view('pdf/test_new_pdf', '', true);
    $this->pdf->addPage($content);
    $this->pdf->send();
    $this->pdf->saveAs('./public/pdf/payment_requests/test.pdf');

I'm using the example code you posted in the documentation as content for the pdf, but when I try to generate a pdf on the browser the error message "Failed to load PDF document" appears. Both on Firefox and Chrome.
The pdf file, though, is generated.

I've found out that to make the "send" command to work I have to remove all the html tags between body, like this:

<!DOCTYPE html>
<html>
<head>
</head>
<body>

        This is an example header.
        Demo
        This is example content
        This is an example footer.

</body>
</html>

Any suggestions?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions