Skip to content

How to prevent PDF from splitting over multiple pages using JSPDF #1139

@KatiyarSP

Description

@KatiyarSP

I am using JSPDF to generate PDF. I am passing html div reference to jspdf. My html contains text and tables. The text is coming fine but the table header is splitting to the second page if the table heading starts from the end of the page. Any help would be appreciated. Below is my code

pdf_error

`
function btnDownload_click()
{

	var doc = new jsPDF('p', 'mm', [340, 340]);
	var output="";

	var elementHandler = {
	  '#tobeIgnored1': function (element, renderer) {
		return true;
	  },
	  
	  '#tobeIgnored2': function (element, renderer) {
		return true;
	  }
	  
	};
	var source = document.querySelectorAll("#SecondaryStatements");
	for(var i=0 ; i<source.length;i++)
	{
		output = output + source[i].innerHTML;
     	
	}
	var  disclaimerText = document.getElementById("Disclaimer").innerHTML;
	output= output + disclaimerText;
	var margins = { top: 30, bottom: 30, left: 40, width: 522 };
	doc.fromHTML(output,15,15,{'pagesplit': false,'width': 300,'elementHandlers':     elementHandler},function (dispose) {
	doc.save("SearchResults.pdf");},margins);
	

}`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions