Open fatstar opened 5 years ago
Could you provide an example of your code, so I can help you debug?
It looks like the problem is with the last slash in the path, before filename, it should be backslash instead.
fopen(C:\wamp64\www\testacb\storage\tmp\0EqoGVGAIMqcft1Q.pdf)
I use 'wamp' server on Windows 10. I usually develop the environment and update to Linux Production server. I believe It is not a problem slash or backslash on Windows.
I use just your sample code as follow;
$merger = \PDFMerger::init();
$merger->addPathToPDF(base_path('/vendor/grofgraf/laravel-pdf-merger/examples/one.pdf'), [2], 'P');
$merger->addPDFString(file_get_contents(base_path('/vendor/grofgraf/laravel-pdf-merger/examples/two.pdf')), 'all', 'L');
$merger->merge();
$merger->save(base_path('/public/pdfs/merged.pdf'));
This is my own code:
$merger = \PDFMerger::init();
for ($i = 0; $i < count($pdffiles); $i++) {
$merger->addPathToPDF($pdffiles[$i], 'all', NULL);
}
$merger->merge();
$merger->save($savepath . '/' . $filename);
Temporary folder is blank.
Thanks
I ran into the same problem with pdf version > 1.4 After looking at the code i noticed that ghostscript is called here by shell_exec() to convert such pdfs: https://github.com/GrofGraf/laravel-pdf-merger/blob/670e84d3157ac8ad831091ae0af72158780952bf/src/PDFMerger.php#L213
Even though my machine has no ghostscript installed i didn't got any error. I guess this command simply does nothing when ghhostscript isn't installed, so there is no file in /tmp which leads to the "no such file" error from fpdf.
After installing ghostscript everything is working now. in my alpine container i did apk add ghostscript
to install.
I have the same issue. Nothing changed after installing ghostscript on my mac. gs command works, but files do not exist.
I'm using Lumen on PHP 7.4 in Browser and 7.3 in Console. Any ideas?
Same problem. Spend about 2 hours hunting this down. Ended up commenting out the if PHP version is 1.4
//if($pdfversion > "1.4"){
// $newFilePath = storage_path('tmp/' . str_random(16) . '.pdf');
// //execute shell script that converts PDF to correct version and saves it to tmp folder
// shell_exec('gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="'. $newFilePath . '" "' . $filePath . '"');
// $this->tmpFiles->push($newFilePath);
// $filePath = $newFilePath;
//}
Everything works as expected
I got error as follow;
fopen(C:\wamp64\www\testacb\storage\tmp/0EqoGVGAIMqcft1Q.pdf): failed to open stream: No such file or directory
I created 'tmp' folder under 'storage' directory. I use WAMP server on Windows 10. - PHP 7.3
How can I fix this problem.
Thanks