[英]How to attach a PDF using barryvdh/laravel-dompdf into an email in Laravel
[英]Why barryvdh/laravel-dompdf Stuck or won't process HTML to PDF when using @font-face CSS?
使用 dompdf 庫將 html 生成為 pdf 時,我沒有發現任何問題。 但是當我在 CSS 中添加 @font-face 並為“Courier New”字體提供 .ttf 文件時,dompdf 被卡在某個過程中,它不會完成生成 pdf 文件。
我將此行添加到我的樣式中
@font-face { font-family: 'CourierNew'; src: url('{{ asset('fonts/cour.ttf') }}'); }
我將 Courier New TrueType 文件放在 public/fonts/ 文件夾中
我的項目使用:
有沒有人遇到過這樣的問題或有關於這個問題的解決方案?
先感謝您。
您應該嘗試暫時增加最大執行
ini_set('max_execution_time', 300);
// your pdf generation code
ini_restore('max_execution_time');
只是為了確保問題不是您嘗試生成的 pdf 文件太大,並且加載字體的額外時間足以使其超過執行時間限制。
這可能晚了,希望這對某人有用。 我的字體文件在public/fonts/
我與 Laravel Blade 集成,在樣式標簽中的該文件中,您只需像在普通 css 中一樣添加路徑。 而且你還需要定義格式,我的字體就像
@font-face {
font-family: 'Product Sans';
src: url('../fonts/ProductSans-Regular.ttf') format('truetype'),
font-weight: normal;
font-style: normal;
font-display: swap;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.