【问题标题】:How to use lineBreak inside the beforePageContent in jspdf autoTable如何在jspdf autoTable的beforePageContent中使用lineBreak
【发布时间】:2019-08-22 19:43:53
【问题描述】:

我在我的程序中使用overFlow : linebreak。它工作正常这是我的代码,

styles: {
                		  fillStyle: 'DF',
                	      overflow: 'linebreak',
                	      columnWidth: 110,
                	      lineWidth: 2,
                	      lineColor: [85, 51, 27]
                           
                	    }

但这并没有反映在 beforePageContent 内部,这是代码,

beforePageContent: function(data) {
                	    	doc.setFontSize(12);
                	    	doc.setFont("courier");
                	    	doc.text("Process Name :",20 ,15);
                	    	doc.setFontStyle('bold');
                	    	//doc.overflow('linebreak');
                	        doc.setFontStyle('normal');
                       doc.text("Description :"+sampData, 20, 30);
                	        
                	        
                	    },

那么我如何在我的beforePageContent 块中使用lineBreak。

【问题讨论】:

  • @Simon Bengtsson ,帮我解决这个问题

标签: jspdf jspdf-autotable


【解决方案1】:

overflow: linebreak; 样式仅适用于jspdf-autotable。在钩子中,您使用的是纯 jspdf 并且需要使用 jspdf 方法。有两个功能可能会对您有所帮助。第一个是doc.getStringUnitWidth("hello"),第二个是doc.splitTextToSize("A longer title that might be split", 50)。

示例 1:

var strArr = doc.splitTextToSize("A longer title that might be split", 50)
doc.text(strArr, 50, 50);

示例 2:

var str = "A longer title that /n is split";
doc.text(str, 50, 50);

【讨论】:

  • ,你能把上面这个例子的链接放上来,这样我可以得到更多的澄清。
  • 现在加了两个例子,我很快google了一下,没有找到上述函数的引用。你要么测试它,要么检查 jspdf 源代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-27
相关资源
最近更新 更多