我正在使用 BrowserShot 将 HTML 转换为 PDF。当我在存储磁盘上保存 pdf 文件时,我面临以下问题。
The command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/home/irshad/Desktop/projects/seller-suite/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/146500948-0992198001603349147\/index.html","action":"pdf","options":{"args":[],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"margin":{"top":"18mm","right":"18mm","bottom":"24mm","left":"18mm"},"format":"A4","printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /home/irshad/Desktop/projects/seller-suite/public Output: ================ Error Output: ================ { TimeoutError: Navigation timeout of 30000 ms exceeded at Promise.then (/home/irshad/Desktop/projects/seller-suite/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:106:111) name: 'TimeoutError' }
我正在使用代码将 HTML 转换为 PDF
$save_to_file= storage_path('example.pdf');
$pdf_file = Browsershot::html($html)
->margins(18, 18, 24, 18)
->format('A4')
->showBackground()
->pdf();
$invoice = response()->stream(function () use ($pdf_file) {
echo $pdf_file->pdf();
}, 200, ['Content-Type' => 'application/pdf']);
我该如何解决它,我浪费了很多时间。谢谢