How to use lineBreak inside the beforePageContent in jspdf autoTable

11,005

The overflow: linebreak; style is only for jspdf-autotable. In the hooks you are using pure jspdf and need to use jspdf methods. There are two functions that you are probably going to be helpful. The first one is doc.getStringUnitWidth("hello") and the second is doc.splitTextToSize("A longer title that might be split", 50).

Example 1:

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

Example 2:

var str = "A longer title that /n is split";
doc.text(str, 50, 50);
Share:
11,005
Saravana Kumar
Author by

Saravana Kumar

Hi,

Updated on June 22, 2022

Comments

  • Saravana Kumar
    Saravana Kumar about 2 years

    i'm using overFlow : linebreak in my program .And it work's fine this is my code ,

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

    But that doesn't reflect inside the beforePageContent , Here is that code ,

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

    So how can i use lineBreak inside my beforePageContent block .