Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kongka opened this issue Jan 18, 2023 · 0 comments
Open

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

kongka opened this issue Jan 18, 2023 · 0 comments

Comments

@kongka
Copy link

kongka commented Jan 18, 2023

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant