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

PhpChromeToPdf Timing Out #23

Closed
ZachHandley opened this issue Feb 3, 2018 · 16 comments
Closed

PhpChromeToPdf Timing Out #23

ZachHandley opened this issue Feb 3, 2018 · 16 comments

Comments

@ZachHandley
Copy link

Hey,

Followed install instructions but my web server times out before the application returns a response. I'm only loading ~4 external resources (all on my web server), and I'm not doing anything crazy, so it should work

Any thought as to why it would return that?

Thanks

  • Zach
@daudmalik06
Copy link
Owner

Hello Zach,
can you provide some more information , any POC ?, or how are you using this package?
thanks

@ZachHandley
Copy link
Author

ZachHandley commented Feb 3, 2018 via email

@daudmalik06
Copy link
Owner

please try that with very simple html page like hey
and check if it takes time or not ,
but if it has problem with memory there should be an error ,
and also make sure you have installed the chrome properly and it's working without this package ,

e.g
chrome --headless --disable-gpu --print-to-pdf=github.pdf https://github.com/

@ZachHandley
Copy link
Author

I believe that it's google-chrome right? And has the code been updated to reflect Chrome's new bug with headless mode? It no longer allows from root if --no-sandbox is not enabled so that could be it too

karma-runner/karma-chrome-launcher#158

@daudmalik06
Copy link
Owner

yeah that's google-chrome , and did you try to run that above command from shell?
try with or without that sandbox flag and let me know if that works,

in case it works try passing that argument to chromePdf as following

$chrome->setArgument('--no-sandbox','')

@ZachHandley
Copy link
Author

I tried it in my console for github and it worked flawlessly, about 4 seconds, but in browser even with --no-sandbox it still doesn't work

@daudmalik06
Copy link
Owner

daudmalik06 commented Feb 3, 2018 via email

@ZachHandley
Copy link
Author

$Chrome = new Chrome(NULL, '/usr/bin/google-chrome');
          $Chrome->setWindowSize($width=1024, $height=768);
          $Chrome->setArgument('--no-sandbox','');
          $HTML = view('downloadProfile')->render();
          $Chrome->useHTML($HTML);
          $Path = $Chrome->getPdf(public_path().'/'.Auth::user()->id.'/').PHP_EOL;
          return response()->download($Path, 'Resume.pdf')->deleteFileAfterSend(true);

@daudmalik06
Copy link
Owner

daudmalik06 commented Feb 4, 2018 via email

@ZachHandley
Copy link
Author

It was in the documentation so I thought it was necessary, my apologies

@ZachHandley
Copy link
Author

Still timing out even after removing the PHP_EOL

@daudmalik06
Copy link
Owner

can you try with simplest html as i mentioned above

$Chrome = new Chrome(NULL, '/usr/bin/google-chrome');

$Chrome->setWindowSize($width=1024, $height=768);

$Chrome->setArgument('--no-sandbox','');

$HTML = '<html>hey</html>';

$Chrome->useHTML($HTML);

$Path = $Chrome->getPdf(public_path().'/'.Auth::user()->id.'/');

return response()->download($Path, 'Resume.pdf')->deleteFileAfterSend(true);

@ZachHandley
Copy link
Author

I did try that, it still timed out

@daudmalik06
Copy link
Owner

if you don't see any error it might be memory issue but try this way,

remove deleteFileAfterSend and verify manually if the file has been created there ? and also try to debug the path value ,

@ZachHandley
Copy link
Author

Still doesn't work for some unknown reason. If you wish I can give you the credentials to see if I effed up somewhere, but I followed instructions to the T

@daudmalik06
Copy link
Owner

daudmalik06 commented Feb 25, 2018

hey ,
did you run this example ?

$Chrome = new Chrome(NULL, '/usr/bin/google-chrome');

$Chrome->setWindowSize($width=1024, $height=768);

$Chrome->setArgument('--no-sandbox','');

$HTML = '<html>hey</html>';

$Chrome->useHTML($HTML);

$Path = $Chrome->getPdf(public_path().'/'.Auth::user()->id.'/Resume.pdf');

return response()->download($Path, 'Resume.pdf');

then check manually the resume in public path.
i think you were missing file name in getPdf method

$Chrome->getPdf(public_path().'/'.Auth::user()->id.'/Resume.pdf')

you had used this way

$Chrome->getPdf(public_path().'/'.Auth::user()->id.'/')

hope this would solve your problem , and sorry for late reply

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

2 participants