Skip to content

pdfwkhtmltopdf , saveAs(); works but not send(); or send('filename'); #289

@alrowaihi

Description

@alrowaihi

hi ,
I've set up the whole environment needed to generate pdf from html resources ,
but when I test the code I find that it works fine with the function saveAs(); and I can find the pdf file and open it successfully ,
but when I use the function send(); it opens the browser as it will show the pdf file but then an error message shows up and says : Failed to load PDF document.

here is the code I'm using


<?php
require 'vendor/autoload.php';
use mikehaertl\wkhtmlto\Pdf;

$pdf = new Pdf(array(
    'binary' => 'wkhtmltopdf',
    'ignoreWarnings' => true,
    'commandOptions' => array(
        'useExec' => true,      // Can help if generation fails without a useful error message
        'procEnv' => array(
            // Check the output of 'locale' on your system to find supported languages
            'LANG' => 'en_US.utf-8',
        ),
    ),
));




$pdf->addPage('test.html'); // a .html file in the root of the site
$pdf->send();

?>

no matter what the array attributes are , it doesn't work even I use

$pdf = new Pdf;
$pdf->addPage('test.html');

I really need help in this as the previous developers used mPDF library but it fails in generating more than 500 records ,, so I've decided to use mkhtmltopdf

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