我在Symfony 4中使用Knp SnappyBundle。我在通過yaml或作為請求中的選項傳遞自定義標頭參數(shù)(--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%' }我也嘗試過將值作為數(shù)組傳遞,但這也失敗了。
1 回答

守候你守候我
TA貢獻1802條經(jīng)驗 獲得超10個贊
我已經(jīng)部分解決了,不幸的是不是通過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期望自定義標頭的標量值...
- 1 回答
- 0 關(guān)注
- 214 瀏覽
添加回答
舉報
0/150
提交
取消