3

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);
                	        
                	        
                	    },

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

4

1 回答 1

7

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);
于 2016-08-09T10:59:10.737 回答