1金币
本帖最后由 Joestar.Xu 于 2023-8-11 11:36 编辑
第13页底部还有空间文字没在当前页显示,而是在14页展示。这是什么原理呢- // 导出pdf
- handleExport() {
- this.loading = true
- let _this = this
- setTimeout(() => {
- let spread = this.spread
- let fontsObj = fonts;
- _this.registerCustomFont(fontsObj);
- _this.addFontsToFontManager(fontsObj);
- _this.setPrintInfo(spread);
- spread.savePDF(function (blob) {
- saveAs(blob, 'EXITWIKI-WTM-20230809.pdf');
- _this.loading = false
- }, function (error) {
- _this.$modal.alertError(error.errorMessage);
- _this.loading = false
- }, {});
- }, 200)
- },
- registerCustomFont(fontsObj) {
- var fonts = {
- normal: fontsObj["simkai.ttf"],
- };
- GC.Spread.Sheets.PDF.PDFFontsManager.registerFont("楷体", fonts);
- },
- addFontsToFontManager(fontsObj) {
- var fonts = {
- normal: fontsObj["MTCORSVA.TTF"],
- };
- GC.Spread.Sheets.PDF.PDFFontsManager.fallbackFont = function (font) {
- var fontInfoArray = font.split(" "),
- fontName = fontInfoArray[fontInfoArray.length - 1];
- if (fontName === "mtcorsva") {
- return fonts.normal;
- }
- };
- },
- setPrintInfo(spread) {
- for (let i = 0; i < spread.getSheetCount(); i++) {
- var sheet = spread.getSheet(i)
- var printInfo = sheet.printInfo();
- sheet.suspendPaint();
- printInfo.showBorder(false); // 是否显示边框
- printInfo.showGridLine(false); // 是否打印网格线 (默认是打印)
- printInfo.blackAndWhite(false); // 彩色打印
- if (i == 0) {
- printInfo.margin({top: -10, bottom: -10, left: -12, right: -50,}) // 边距
- printInfo.columnEnd(12) // 打印截至至某一列
- printInfo.rowEnd(62) // 打印截至至某一行
- } else {
- printInfo.columnEnd(6); // 打印截至至某一列
- if (sheet.name() == '列表页-新增' || sheet.name() == '列表页-更新') {
- let num = 4
- if (num > 7) {
- for (let j = 1; j <= (parseInt(num / 7)); j++) {
- sheet.setRowPageBreak(j * 6 * 7 + (j * 2), true);
- }
- }
- }
- if (sheet.name() != '列表页-新增' && sheet.name() != '列表页-更新' && sheet.name() != '释义' && sheet.name() != '免责声明页') {
- sheet.setRowPageBreak(43, true);
- printInfo.rowEnd(79) // 打印截至至某一行
- }
- printInfo.headerCenter("EXITWIKI-WTM-20230809")
- printInfo.footerCenter("&P/&N");
- printInfo.firstPageNumber(null);
- printInfo.margin({top: 100, left: 0, right: 0,bottom:55}) // 边距
- printInfo.watermark([{x: 60, y: 20, width: 201, height: 48, imageSrc: this.images1, page: "all"}]);
- printInfo.centering(GC.Spread.Sheets.Print.PrintCentering.horizontal); // 打印的居中方式
- }
- printInfo.qualityFactor(8); //打印质量,value为1~8的一个数值,越高则打印效果越好
- sheet.resumePaint();
- }
- }
复制代码
|
|