Skip to content

Linux server cannot run direct /usr/bin/wkhtmltopdf #323

@kongka

Description

@kongka

Issue to be enhanced

There is many linux server which don't have any interface and could not run directly the command /usr/bin/wkhtmltopdf which required another command behavior to execute this library by /usr/bin/xvfb-run /usr/bin/wkhtmltopdf.

This is the solution to solve this on Linux servers:

Configure in bootstrap.php to change:

Configure::write('CakePdf', [
	'engine' => [
		'className' => 'CakePdf.WkHtmlToPdf',
		//'binary' => '/usr/bin/wkhtmltopdf', // from this (Normal Linux)
		'binary' => '/usr/bin/xvfb-run /usr/bin/wkhtmltopdf', // to this (many linux server)
		//...
		'skipCheckingExecutableBinary' => true, // add one more configuration here (default is false/null)
	],
	//...
]);

And change to this library src/Pdf/Engine/WkHtmlToPdfEngine.php:

// add this code in method "getBinaryPath" below this line "$binary = $this->getConfig('binary', $this->_binary);"
if ($this->getConfig('skipCheckingExecutableBinary')) {
    return $binary;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions