将 custom-header 个参数传递给 Knp SnappyBundle

Passing custom-header arguments to Knp SnappyBundle

我在 Symfony 4 中使用 Knp SnappyBundle。

我无法通过 yaml 或作为请求中的选项将 custom-header 参数 (--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%'  }

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

我已经部分解决了,不幸的是不是通过 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 期望标量值为 custom-header...