开发者

How to use wkhtmltopdf in ASP.Net page that requires users to be logged in

I have created a simple ASP.Net page to create self printable tickets so non-technical people can change the text and layout of a ticket. Obviously the user has to be logged in t开发者_如何学Goo be able to print their tickets.

When providing the URL for wkhtmltopdf to convert, the tickets are not created because wkhtmltopdf does not have a session to prove the user is logged in.

Is it possible to pass the session to wkhtmltopdf in the URL, or is their a better solution?


Yes, you can pass on sessions via URL, however, that's kind of unnecessary.

Usually, you do something like:

http://xyz.com/tickets.php

Would contain:

<ul>
  <li>
    <a href="ticket.php?ticket=1">Ticket 1</a>
  </li><li>
    <a href="ticket.php?ticket=2">Ticket 2</a>
  </li><li>
    <a href="ticket.php?ticket=N">Ticket N</a>
  </li>
</ul>

And ticket.php:

<?php
    if( User->logged_in() ){

      $temp='C:\\windows\\temp\\tmp123546.html';

      file_put_contents($temp,'ticket html stuff');

      shell_exec('wkhtmltopdf.exe file:///'.str_replace('\\','/',$temp));

    }
?>

Note: I know you asked about this in ASP, but I don't know much about it. However, the above info should be true to any web-based software, be it ASP, PHP, Ruby or Python.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜