0

我在 Symfony 4 中使用 Knp SnappyBundle。

我在通过 yaml 或作为请求中的选项传递自定义标头参数 ( --custom-header <name> <value>) 时遇到问题。wkhtmltopdf

这是我正在尝试的,似乎失败了:

knp_snappy:
  temporary_folder: "%kernel.cache_dir%/snappy"
  pdf:
    enabled: true
    binary: xvfb-run wkhtmltopdf
    options:
      - { name: 'custom-header', value: '%app_auth_header_name%' '%app_auth_header_token%'  }

我也尝试将值作为数组传递,但这也失败了。

4

1 回答 1

0

我已经部分解决了,不幸的是不是通过yaml,而是在代码示例中直接解决:

   public function getPdfBinary($url, Pdf $pdfService): PdfResponse
    {
        $url = urldecode($url);
        $res = new PdfResponse($pdfService->getOutput($url, ['custom-header' =>
            [ 'X-Authorization' => 'mytoken' ] ]),'output.pdf');
        return $res;

yaml 期望自定义标头的标量值...

于 2019-04-15T13:07:55.203 回答