barryvdh / laravel-snappy

Laravel Snappy PDF
MIT License
2.65k stars 292 forks source link

\knp_snappy5bb098d140e970.93058232.pdf' was not created #317

Closed AbhayLodhi closed 4 years ago

AbhayLodhi commented 6 years ago

i am facing this issue need help please Thnx.

inside composer file "barryvdh/laravel-dompdf": "^0.8.3", "barryvdh/laravel-snappy": "^0.4.3", "h4cc/wkhtmltoimage-amd64": "^0.12.4", "h4cc/wkhtmltopdf-amd64": "^0.12.4", "wemersonjanuario/wkhtmltopdf-windows": "0.12.2.3"

snappy config file return array(

'pdf' => array(
    'enabled' => true,
    'binary' => base_path('vendor\wemersonjanuario\wkhtmltopdf-windows\bin\64bit\wkhtmltopdf'),
    'timeout' => false,
    'options' => array(),
    'env'     => array(),
),
'image' => array(
    'enabled' => true,
    'binary'  => 'vendor\h4cc\wkhtmltoimage-amd64',
    'timeout' => false,
    'options' => array(),
    'env'     => array(),
),

);

Print Controller file

$pdf = PDF::loadView('results',['students'=>$students,'school' => $school,'subject'=>$subjects]); return $pdf->download('result.pdf');

RuntimeException The file 'C:\Users\Abhay\AppData\Local\Temp\knp_snappy5bb098d140e970.93058232.pdf' was not created (command: D:\Projects\ResultAssessment\vendor\wemersonjanuario\wkhtmltopdf-windows\bin\64bit\wkhtmltopdf --lowquality "C:\Users\Abhay\AppData\Local\Temp\knp_snappy5bb098d13f12f7.97723818.html" "C:\Users\Abhay\AppData\Local\Temp\knp_snappy5bb098d140e970.93058232.pdf").

milivojsa commented 6 years ago

I am facing the same issue but I am on Ubuntu 18.04.

@AbhayLodhi Have you tried to just output pdf?

I noticed that I can output pdf or even manually save but when I try to call ->save(...) then it throws the exception.

When I run the command manually for example:

wkhtmltopdf 'tmp/knp_snappyXXXXXXXXXXXX.html' 'test.pdf'

I get following error:

Loading pages (1/6) Error: Failed loading page http://tmp/knp_snappyXXXXXXXXXXXX.html (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to network error: HostNotFoundError

I see it tries to access tmp/knp_snappyXXXXXXXXXXXX.html as it is the URL instead of loading local file.

AbhayLodhi commented 6 years ago

hi, i try but fail if you found any solution please let me know and if i found something helpful then i inform you

On Fri, Oct 5, 2018 at 6:57 PM milivojsa notifications@github.com wrote:

I am facing the same issue but I am on Ubuntu 18.04.

@AbhayLodhi https://github.com/AbhayLodhi Have you tried to just output pdf?

I noticed that I can output pdf or even manually save but when I try to call ->save(...) then it throws the exception.

When I run the command manually for example:

wkhtmltopdf 'tmp/knp_snappyXXXXXXXXXXXX.html' 'test.pdf'

I get following error:

Loading pages (1/6) Error: Failed loading page http://tmp/knp_snappyXXXXXXXXXXXX.html (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to network error: HostNotFoundError

I see it tries to access tmp/knp_snappyXXXXXXXXXXXX.html as it is the URL instead of loading local file.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/barryvdh/laravel-snappy/issues/317#issuecomment-427365868, or mute the thread https://github.com/notifications/unsubscribe-auth/AIr31DJcQhapLjNlSxIAFemd7lcRjCCFks5uh15egaJpZM4XA5kQ .

-- Thanks & Regards-

Abhay Kumar Verma

Lucknow Uttar Pradesh

E- abhayver333@gmail.com abhay.verma@mminnovate.com

frijj2k commented 6 years ago

Same problem here...

3Descape commented 6 years ago

I can confirm the same problem

far3ki commented 6 years ago

just try to comment line to binary in snappy config file: pdf' => array( 'enabled' => true, // 'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'), 'timeout' => false, 'options' => array(), 'env' => array(), ),

AbhayLodhi commented 6 years ago

just try to comment line to binary in snappy config file: pdf' => array( 'enabled' => true, // 'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'), 'timeout' => false, 'options' => array(), 'env' => array(), ),

after doing this i get that error. RuntimeException The exit status code '1' says something went wrong: stderr: "The system cannot find the path specified. " stdout: "" command: /usr/local/bin/wkhtmltopdf --lowquality "C:\Users\Abhay\AppData\Local\Temp\knp_snappy5bdaa33d4be445.70437324.html" "C:\Users\Abhay\AppData\Local\Temp\knp_snappy5bdaa33d79a8b1.38742081.pdf".

far3ki commented 6 years ago

In my case it helped, because finally I found out, that wkhtmltopdf is already installed on my hosting and I still was getting similar error message: The file '/tmp/knp_snappy5bdb29ed73ec01.07065997.pdf' was not created (command: /nfsmnt/hosting2_1/f/c/fcc203d9-a9c0-45a7-aae7-99f0743dd350/my_web/my_app/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 --lowquality '/tmp/knp_snappy5bdb29ed73c7a0.60260250.html' '/tmp/knp_snappy5bdb29ed73ec01.07065997.pdf').

When I have commented line in snapy config file as described in my previous post, export to pdf started to work OK. I also wanted to know, where is wkhtmltopdf installed on my hosting so I tried to run command on my hosting: /home/my_web/my_app$ whereis wkhtmltopdf wkhtmltopdf: /usr/bin/wkhtmltopdf

So as you see, wkhtmltopdg was already installed in "/usr/bin/wkhtmltopdf"

Crouxie commented 4 years ago

Still facing this issue on Windows enviroment. I tried different approaches, but nothing works. What I have done:

I disabled removing temporary files in Abstract class -> php code generated temporary html file, so I hardcoded source file into load file. From cmd, everything is working properly, but not from PHP.

I also tried update access rights and set "Full control" to necessary folders, but nothing changed. Package is using fromShellCommandline() from Symfony. Then I tried to hardcode command, but again, no luck. Wkhtmltopdf is included in path enviroment vaue, but running command through shell_exec() is also not working.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/KnpLabs/snappy instead. When having doubts, please try to reproduce the issue with just snappy. If you believe this is an actual issue with the latest version of laravel-snappy, please reply to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.