itextsharp中文支援問題

2021-07-24 19:37:44 字數 974 閱讀 3673

因為專案需求要做乙個比較複雜的pdf,因pdf生成後有幾十頁,就考慮用模板填寫表單資料完成。前面進行的很順利,但是因為一開始新增的是系統的中文字型導致生成的pdf過大(上百m),又換成使用itextasian和itextasiancmaps的方式,但是一直報錯,希望哪位高人指點迷津,不勝感激。所有的dll都引用了 始終找不到原因。

font 'stsong-light' with 'unigb-ucs2-h' is not recognized.

說明: 執行當前 web 請求期間,出現未處理的異常。請檢查堆疊跟蹤資訊,以了解有關該錯誤以及**中導致錯誤的出處的詳細資訊。 

異常詳細資訊: itextsharp.text.documentexception: font 'stsong-light' with 'unigb-ucs2-h' is not recognized.

源錯誤:

行 34:             basefont.addtoresourcesearch("itextasian.dll");

行 35: basefont.addtoresourcesearch("itextasiancmaps.dll");

行 36: basefont basefont = basefont.createfont("stsong-light", "unigb-ucs2-h", basefont.embedded);

行 37: //basefont basefont = basefont.createfont("c:\\windows\\fonts\\stsong.ttf", basefont.identity_h, basefont.not_embedded);

行 38: //font font8 = new font(basefont, 7, font.bold);// fontfactory.getfont("宋體", 7, font.bold);

使用iTextSharp中文無顯示

itextsharp匯出pdf遇到問題中文無顯示!一開始老是少幾個顯示不完整,一直找 問題 最後才注意到中文無顯示!需要像這樣 指定字型庫,並建立字型 basefont basefont basefont.createfont c windows fonts stsong.ttf basefont....

pdfmake實現中文支援,解決中文亂碼問題

引言 當初自己為了在專案中bootstrap table中實現匯出pdf,使用的pdfmake,但是pdfmake預設使用的不是中文字型,實現pdfmake使用中文字型主要就是編譯新的vfs fonts.js代替原來vfs fonts.js檔案引入到前端頁面中,為了編譯出新的字型檔案,我也查了很多資...

PHP json encode 不支援中文的問題

今天用乙個包含中文的陣列轉json的時候發現存在問題 string u8d3a u54f2 u54f2 u6731 u6653 u745e u674e u946b u66fe u7ef4 u59ae 網上找了很多,大多數都是錯的,最後終於找到乙個對的,記錄下來吧!正確的方法是在json encode...