3

So, snappy does an amazing job for creating PDFs for my Laravel site. The problem is the login. Snappy can PDF all the pages before the login but if I try to pdf the url of a page that appears only after login, then it PDFs the login page. It must be something to do with sessions or the Auth function. Anyone knows how to PDF pages that require authorisation with Snappy?

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
Panos
  • 61
  • 1
  • 5
  • as i aware to snappy, you can access pdf through first http request to specific url then its will generate pdf, while its will hit to http you can auth request. – Safoor Safdar May 16 '15 at 18:09
  • would be great if you share some piece of code, how you using snappy. – Safoor Safdar May 16 '15 at 18:10
  • $snappy = new Pdf(realpath('/usr/local/bin/wkhtmltopdf')); header('Content-Type: application/pdf'); header('Content-Disposition: attachment; filename="file.pdf"'); $url='http://localhost/BackOffice/public/'; echo $snappy->getOutput($url); echo 'PDF generated Successfully'; – Panos May 18 '15 at 11:43
  • Can I have an example of how to authenticate before the pdf is generated? I am not quite sure I understand exactly what you mean – Panos May 18 '15 at 11:47
  • how you checking user authentication on other controller? – Safoor Safdar May 18 '15 at 14:45

1 Answers1

1

Am not aware much about passing authentication to the pdf generation. But what i suggest is, have a separate page which will render all your required data and generate pdf.

Example : Say you want to generate pdf with user profile detail.

First you need to have a normal page which will ask for authentication, once authentication done and details are fetched, then the retrieved information send to the pdf generation page which render the data.

CalixCaine
  • 33
  • 9