本帖最后由 18744279242 于 2017-12-21 12:47 编辑
在导出PDF时注册字体,可是注册隶书粗体(bold)时 savePDF 会走到pdf导出错误的function里。注册其它字体没问题。
registerServerFont("隶书", "bold", "http://localhost:9000/lims/js/spreadJS/modelFont/LISHUBOLD.TTF");
// 注册服务器里以存放的字体
function registerServerFont(name, type, serverPath) {
var t1 = new Date().getTime();
var xhr = new XMLHttpRequest();
xhr.open('GET', serverPath, true);
xhr.responseType = 'blob';
xhr.onload = function (e) {
if (this.status == 200) {
// get binary data as a response
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 = null;
};
reader.readAsArrayBuffer(blob);
}
};
xhr.send();
}
|
|