在保存PDF前注册了多种字体,但是只有第一个字体 宋体normal 保存PDF之后不是乱码,其他几种还是乱码格式
具体注册代码如下:
var fontTtfs = [{
name: "宋体",
type: "Normal",
serverPath: IFM_CONTEXT + "/static/plugin/spread-sheets-11.2.6/designer/index/font/simsun.ttf"
}, {
name: "宋体",
type: "Bold",
serverPath: IFM_CONTEXT + "/static/plugin/spread-sheets-11.2.6/designer/index/font/simsun-bold.ttf"
}, {
name: "Times New Roman",
type: "Normal",
serverPath: IFM_CONTEXT + "/static/plugin/spread-sheets-11.2.6/designer/index/font/times.ttf"
},{
name: "Times New Roman",
type: "Bold",
serverPath: IFM_CONTEXT + "/static/plugin/spread-sheets-11.2.6/designer/index/font/timesbd.ttf"
},{
name: "Times New Roman",
type: "Bold Italic",
serverPath: IFM_CONTEXT + "/static/plugin/spread-sheets-11.2.6/designer/index/font/timesbi.ttf"
},{
name: "Times New Roman",
type: "Italic",
serverPath: IFM_CONTEXT + "/static/plugin/spread-sheets-11.2.6/designer/index/font/timesi.ttf"
}/*, {
name: "黑体",
type: "normal",
serverPath: IFM_CONTEXT + "/static/plugin/spread-sheets-11.2.6/designer/index/font/simhei.ttf"
}*/];
function setFont() {
for (var key in fontTtfs) {
var name = fontTtfs[key].name;
var type = fontTtfs[key].type;
var serverPath = fontTtfs[key].serverPath;
registerServerFont(name, type, serverPath);
}
}
/**
* 加载时为字体赋值(只用于导出pdf)
*/
var checkfontsuccess = 0;
function registerServerFont(name, type, serverPath) {
var xhr = new XMLHttpRequest();
xhr.open('GET', serverPath, true);
xhr.responseType = 'blob';
xhr.onload = function (e) {
if (this.status == 200) {
var blob = this.response;
// 将Blob 对象转换成 ArrayBuffer
var reader = new FileReader();
reader.onload = function (e) {
var fontrrayBuffer = reader.result;
var fonts = GC.Spread.Sheets.PDF.PDFFontsManager.getFont(name) || {};
fonts[type] = fontrrayBuffer;
GC.Spread.Sheets.PDF.PDFFontsManager.registerFont(name, fonts);
}
reader.readAsArrayBuffer(blob);
checkfontsuccess++;
} else {
designer.MessageBox.show("字体文件开小差了!请刷新页面!", "提示", 3);
}
};
xhr.send();
}
请问是啥问题
|
|