本帖最后由 yeshuang 于 2019-4-28 11:40 编辑
- var fileName = config.options.title.text == '' ? '未命名' : config.options.title.text;
- var sheet = spread.getActiveSheet();
- sheet.suspendPaint();
- var printInfo = sheet.printInfo();
- printInfo.showBorder(true);
- printInfo.showGridLine(true);
- printInfo.headerCenter("Olympic Athletes");
- printInfo.headerLeft("&G");
- printInfo.headerLeftImage("./images/olympic.jpg");
- printInfo.footerCenter("&P/&N");
- sheet.resumePaint();
- 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) {
- // 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.readAsArrayBuffer(blob);
- }
- };
- xhr.send();
- }
- registerServerFont('微软雅黑', 'normal', '/Content/Lib/Spread.Sheets.Release.11.2.2/fonts/msyh.ttf');
- spread.savePDF(
- function (blob) {
- saveAs(blob, fileName + '.pdf');
- },
- console.log,
- {
- title: fileName,
- author: 'Test Author',
- subject: 'Test Subject',
- keywords: 'Test Keywords',
- creator: 'test Creator'
- }
- );
复制代码 咨询了技术,看了代码说,正常注册字体就是这样做的,让我提供一下模板ssjson帮忙排查一下原因。
|
-
-
模板.zip
1.18 KB, 下载次数: 159
ssjson文件
|