有需要在你的問題需要解決兩個問題的東西,更迫切的是,作爲@湯姆 - 梅特卡夫指出,has yet to be resolved PHP的錯誤。這兩個可幫助解決的信息有:dompdf版本,PHP版本。
如果確實解決了該錯誤,則需要解決另一個問題:字體CSS中的dompdf only understands named font weights。如果您確定自己維護CSS,則可以解決此問題。
您需要基於CSS的True Type字體(TTF)版本工作,因爲dompdf目前只能嵌入TTF。 Google Web字體字體服務根據訪問的瀏覽器提供最合適的格式。獲取樣式表的TTF版本visit the URL in a browser that requires TTF for web fonts。我在我的服務器上使用了lynx(TTF必須是未知瀏覽器的後備)。從谷歌使用樣式表來創建自定義的CSS,例如:
@font-face {
font-family: 'Roboto Condensed Light';
font-style: normal;
font-weight: normal;
src: local('Roboto Condensed Light'), local('RobotoCondensed-Light'), url(http://themes.googleusercontent.com/static/fonts/robotocondensed/v7/b9QBgL0iMZfDSpmcXcE8nL3QFSXBldIn45k5A7iXhnc.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: normal;
src: local('Roboto Condensed Regular'), local('RobotoCondensed-Regular'), url(http://themes.googleusercontent.com/static/fonts/robotocondensed/v7/Zd2E9abXLFGSr9G3YK2MsDR-eWpsHSw83BRsAQElGgc.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: bold;
src: local('Roboto Condensed Bold'), local('RobotoCondensed-Bold'), url(http://themes.googleusercontent.com/static/fonts/robotocondensed/v7/b9QBgL0iMZfDSpmcXcE8nDokq8qT6AIiNJ07Vf_NrVA.ttf) format('truetype');
}
注意,font-weight
聲明進行了修改,使用命名權和字體的「輕」變體給出了自己的姓。由於dompdf沒有完全支持數字權重,所以您必須這樣做。
我不知道這些字體網址有多穩定。它們似乎是某種散列,所以當新版本發佈時它們可能會消失。爲了安全起見,您可能需要自己託管文件。
Yeahh我試過:(無濟於事。謝謝同樣的湯姆:) ... PS。設置作者標籤也不起作用:/ – Deej
您是否嘗試過測試多種字體?這很奇怪,如果你創建你的dompdf對象如下「$ dompdf = new DOMPDF();」與包含的庫和調用「$ dompdf-> add_info('作者','湯姆');它應該工作! –
關於你編碼的環境更多的信息可能會有幫助,例如你使用框架?我在zend中使用DOMPDF,並且在它正常工作之前必須對它進行相當的配置。 –