Pdfgenerator

Download your app items as client branded pdfs

Back to Pdfgenerator Support

bpettis
bpettis

I followed these instructions to create a .env

From http://octobercms.com/docs/setup/configuration#environment-config-extended

Defining a base environment It is often helpful to have different configuration values based on the environment the application is running in. You can do this by setting the APP_ENV >environment variable which by default it is set to production. There are two common ways to change this value:

Set APP_ENV value directly with your webserver.

For example, in Apache this line can be added to the .htaccess or httpd.config file:

SetEnv APP_ENV "dev" Create a .env file in the root directory with the following content:

APP_ENV=dev In both of the above examples, the environment is set to the new value dev. Configuration files can now be created in the path config/dev and will >override the application's base configuration.

Here is my php code:

use Initbiz\Pdfgenerator\Classes\PdfGenerator;

/*
 * OctoberCMS AJAX handler to download PDF
 */
public function onDownloadPdf() {
    $pdfGenerator = new PdfGenerator();

//Set absolute path of the Twig layout
//$pdfGenerator->layout = plugins_path().'/initbiz/exampleplugin/views/pdf/pdflayout.htm';
$pdfGenerator->layout = plugins_path(). '/deltarv/products/views/pdf/part.htm';

//Set filename for downloaded file
$pdfGenerator->filename = "Part PDF";

//Set data which will be sent to the layout
$pdfGenerator->data = ['viewData' => 'Value of viewData'];

$pdfGenerator->generatePdf();

return $pdfGenerator->downloadPdf();
}

Here is the error:

"The exit status code '126' says something went wrong: stderr: "sh: /home/deltarv/public_html/plugins/initbiz/pdfgenerator/vendor/bin/wkhtmltopdf->amd64: Permission denied" ... ETC ETC

Is my .env the problem does it need to point to a specific path?

This is what I got.

APP_ENV=dev

WKHTMLTOPDF_BINARY

inIT
inIT

Hi,

Actually I can see a few problems with your code.

First and foremost, WKHTMLTOPDF_BINARY have to specify absolute path to binary. So for example this must be something like /var/www/project/vendor/bin/wkhtmltopdf-amd64 - the place where the binary is.

Moreover, user that is running your PHP process (or www server, for example www or www-data) has to have permission to execute the wkhtmltopdf binary.

Pro tip:

October has a great tool to create .env file for you. Run in console: php artisan october:env. After that add line similar to:

WKHTMLTOPDF_BINARY=/usr/local/bin/wkhtmltopdf

Last updated

1-2 of 2