首页 > 解决方案 > 使用 wkhtmltopdf 打印 url

问题描述

我的问题是我需要用 wkhtmltopdf 打印一个 url,但是打印的 url 是这样开始的:

<?php
session_start();
if (!isset($_SESSION['login'])) {
    header('Location:../../../index.php');
}

这意味着必须对用户进行身份验证,但是从 wkhtmltopdf 生成的文件会打印 index.php 而不会打印 imprimir_ingreso.php 的内容。

到目前为止,这是我的代码源:

<?php
session_start();
if (!isset($_SESSION['login'])){
    header("Location:../../index.php");
}

$sesion_id= session_id();
system("C://\"Program Files\"//wkhtmltopdf//bin//wkhtmltopdf --cookie 'sessionid' $sesion_id http://localhost/proyecto/hc/php/admisiones/ambulatorio/imprimir_ingreso.php?id_ingreso=84 hc.pdf");

我不知道这到底在做什么--cookie 'sessionid' $sesion_id,因为要打印的 url 以此开头!isset($_SESSION['login'])以使用未经身份验证的用户重定向到 index.php。

标签: phpsessionwkhtmltopdf

解决方案


推荐阅读