找回密码
 立即注册

QQ登录

只需一步,快速开始

想念
中级会员   /  发表于:2023-8-10 12:16  /   查看:2026  /  回复:11
1金币
本帖最后由 Joestar.Xu 于 2023-8-11 11:36 编辑

企业微信截图_16916384027375.png471313170.png 第13页底部还有空间文字没在当前页显示,而是在14页展示。这是什么原理呢
  1. // 导出pdf
  2. handleExport() {
  3.       this.loading = true
  4.       let _this = this
  5.       setTimeout(() => {
  6.         let spread = this.spread
  7.         let fontsObj = fonts;
  8.         _this.registerCustomFont(fontsObj);
  9.         _this.addFontsToFontManager(fontsObj);
  10.         _this.setPrintInfo(spread);
  11.         spread.savePDF(function (blob) {
  12.           saveAs(blob, 'EXITWIKI-WTM-20230809.pdf');
  13.           _this.loading = false
  14.         }, function (error) {
  15.           _this.$modal.alertError(error.errorMessage);
  16.           _this.loading = false
  17.         }, {});
  18.       }, 200)
  19.     },
  20.     registerCustomFont(fontsObj) {
  21.       var fonts = {
  22.         normal: fontsObj["simkai.ttf"],
  23.       };
  24.       GC.Spread.Sheets.PDF.PDFFontsManager.registerFont("楷体", fonts);
  25.     },
  26.     addFontsToFontManager(fontsObj) {
  27.       var fonts = {
  28.         normal: fontsObj["MTCORSVA.TTF"],
  29.       };
  30.       GC.Spread.Sheets.PDF.PDFFontsManager.fallbackFont = function (font) {
  31.         var fontInfoArray = font.split(" "),
  32.           fontName = fontInfoArray[fontInfoArray.length - 1];
  33.         if (fontName === "mtcorsva") {
  34.           return fonts.normal;
  35.         }
  36.       };
  37.     },
  38.     setPrintInfo(spread) {
  39.       for (let i = 0; i < spread.getSheetCount(); i++) {
  40.         var sheet = spread.getSheet(i)
  41.         var printInfo = sheet.printInfo();
  42.         sheet.suspendPaint();
  43.         printInfo.showBorder(false); // 是否显示边框
  44.         printInfo.showGridLine(false); // 是否打印网格线 (默认是打印)
  45.         printInfo.blackAndWhite(false); // 彩色打印
  46.         if (i == 0) {
  47.           printInfo.margin({top: -10, bottom: -10, left: -12, right: -50,}) // 边距
  48.           printInfo.columnEnd(12) // 打印截至至某一列
  49.           printInfo.rowEnd(62) // 打印截至至某一行

  50.         } else {
  51.           printInfo.columnEnd(6); // 打印截至至某一列
  52.           if (sheet.name() == '列表页-新增' || sheet.name() == '列表页-更新') {
  53.             let num = 4
  54.             if (num > 7) {
  55.               for (let j = 1; j <= (parseInt(num / 7)); j++) {
  56.                 sheet.setRowPageBreak(j * 6 * 7 + (j * 2), true);
  57.               }
  58.             }
  59.           }
  60.           if (sheet.name() != '列表页-新增' && sheet.name() != '列表页-更新' && sheet.name() != '释义' && sheet.name() != '免责声明页') {
  61.             sheet.setRowPageBreak(43, true);
  62.             printInfo.rowEnd(79) // 打印截至至某一行
  63.           }
  64.           printInfo.headerCenter("EXITWIKI-WTM-20230809")
  65.           printInfo.footerCenter("&P/&N");
  66.           printInfo.firstPageNumber(null);
  67.           printInfo.margin({top: 100, left: 0, right: 0,bottom:55}) // 边距
  68.           printInfo.watermark([{x: 60, y: 20, width: 201, height: 48, imageSrc: this.images1, page: "all"}]);
  69.           printInfo.centering(GC.Spread.Sheets.Print.PrintCentering.horizontal); // 打印的居中方式
  70.         }
  71.         printInfo.qualityFactor(8); //打印质量,value为1~8的一个数值,越高则打印效果越好
  72.         sheet.resumePaint();
  73.       }
  74.     }
复制代码

json(1).txt

1.38 MB, 阅读权限: 150, 下载次数: 1

11 个回复

倒序浏览
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2023-8-10 14:54:04
沙发
您好,出现这种问题是因为SpreadJS在导出为PDF的时候是不会将一个单元格拆分为两部分显示的,因此为了将一个单元格显示全,会寻找一个充足的空间来显示。因此对于以下单元格来说:

image.png390102233.png

将其拆分为两个或多个单元格就可以解决这个问题了。

image.png604308166.png

image.png322577513.png

SpreadJS 17.0.9 | GcExcel 7.1.2 已发布~
回复 使用道具 举报
想念
中级会员   /  发表于:2023-8-10 16:12:33
板凳
Joestar.Xu 发表于 2023-8-10 14:54
您好,出现这种问题是因为SpreadJS在导出为PDF的时候是不会将一个单元格拆分为两部分显示的,因此为了将一 ...

企业微信截图_16916549336470.png187890624.png 企业微信截图_16916541856230.png148886412.png 导出后文字显示不全

456.SSJSON

4.83 MB, 阅读权限: 150, 下载次数: 1

回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2023-8-10 17:15:43
地板
您好,您尝试将这个单元格的行高稍微调高一些应该就不会出现这个问题了。

image.png547267150.png

image.png670624389.png
SpreadJS 17.0.9 | GcExcel 7.1.2 已发布~
回复 使用道具 举报
想念
中级会员   /  发表于:2023-8-11 10:07:40
5#
Joestar.Xu 发表于 2023-8-10 17:15
您好,您尝试将这个单元格的行高稍微调高一些应该就不会出现这个问题了。

数据是动态的不能固定高度
回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2023-8-11 11:30:39
6#
我们这边先调研一下,后续有进展我会在本贴中回复您。

本帖先做保留处理了。
SpreadJS 17.0.9 | GcExcel 7.1.2 已发布~
回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2023-8-17 08:58:56
7#
您好,该问题已被确认为是一个Bug,目前正在修复中,等修复完毕我会在帖子下回复您。
SpreadJS 17.0.9 | GcExcel 7.1.2 已发布~
回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2023-8-21 17:24:24
8#
您好,目前有一个解决方案,您尝试将列宽调大一些:sheet.setColumnWidth(1, 103)

这样就可以显示正常了。
SpreadJS 17.0.9 | GcExcel 7.1.2 已发布~
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2023-9-14 15:46:27
9#
此bug仍在调研,后续进展我们会再回复更新
回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2023-9-20 09:00:27
10#
您好,经调研,您也可以将缩放大小调整到100%来解决这个问题。
SpreadJS 17.0.9 | GcExcel 7.1.2 已发布~
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部