1
我需要與中國信導出PDF,並編寫代碼如下鏈接說:添加自定義字體宋體在jsPDF
和我的代碼:
CSS:
@font-face {
font-family: SimSun;
font-weight: normal;
font-style: normal;
src: url("./simsun.ttc");
}
body{
font-family: 'SimSun';
}
js:
pdf.addFont('SimSun', 'SimSun', 'normal','StandardEncoding');
pdf.setFont('SimSun');
pdf.text(20, 20, '西溪園區 5號樓 1F');
pdf.save('TestSVG.pdf');
正如有人說的,我已經證實addFont是公開的:
API.addFont = function(postScriptName, fontName, fontStyle) {
addFont(postScriptName, fontName, fontStyle, 'StandardEncoding');
};
而且我還發現「中Simsun」的postScriptName是宋體。 http://mirror.sars.tw/FreeBSD_Chinese_HOWTO/simsun.html
有人可以告訴我爲什麼嗎?
這會影響html中的單詞,但不能影響pdf中的單詞。當我導出pdf文件並用chrome打開時,它是亂碼。 –
那麼我建議首先問你應該問的第一個地方:https://github.com/MrRio/jsPDF/issues –