jsPDF无法在IE< 10浏览器中工作

时间:2015-08-19 08:17:02

标签: javascript jquery html css internet-explorer

我正在尝试将HTML转换为PDF格式。我正在使用' jsPDF'插件,它在IE< 10以外的所有浏览器中工作。我得到了未定义的' jsPDF未定义' IE8和IE9的控制台中出错。请帮我解决这个问题......

这是我的js



function demoFromHTML() { alert("inside demoFromHTML");
	var table = document.getElementById("mytab1");
	for (var i = 0, row; row = table.rows[i]; i++) { 	
		if(i==0 || i == table.rows.length-1 || row.cells.length < 2 || row.className == "item category"){}else{ 
			var quantity=row.cells[1].childNodes[0].value;
			row.cells[1].innerHTML = quantity;
			var priceOne = row.cells[4].childNodes[0].value;
			row.cells[4].innerHTML = priceOne;
			var priceTwo = row.cells[5].childNodes[0].value;
			row.cells[5].innerHTML = priceTwo;
			var priceThree = row.cells[6].childNodes[0].value;
			row.cells[6].innerHTML = priceThree;
		}  
	}
	var total = document.getElementById('total').value;
	document.getElementById('grandTotal').innerHTML = total;
	

	var pdf = new jsPDF('p', 'pt', 'letter')

	// source can be HTML-formatted string, or a reference
	// to an actual DOM element from which the text will be scraped.
	, source = $('#mainContentWide')[0]

	// we support special element handlers. Register them with jQuery-style 
	// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
	// There is no support for any other type of selectors 
	// (class, of compound) at this time.
	, specialElementHandlers = {
		// element with id of "bypass" - jQuery style selector
		'#bypassme': function(element, renderer){
			// true = "handled elsewhere, bypass text extraction"
			return true
		}
	}

	margins = {
      top: 10,
      bottom: 10,
      left: 10,
      width: 522
    };
    // all coords and widths are in jsPDF instance's declared units
    // 'inches' in this case
    pdf.fromHTML(
    	source // HTML string or DOM elem ref.
    	, margins.left // x coord
    	, margins.top // y coord
    	, {
    		'width': margins.width // max width of content on PDF
    		, 'elementHandlers': specialElementHandlers
    	},
    	function (dispose){
			alert("inside dispose function");
          pdf.save('Software.pdf');
        },
		
    	margins
    )  
	
	document.getElementById("buttonPDF").disabled = 'true'; 
}
&#13;
&#13;
&#13;

错误显示在var jsPDF = new ..... line

0 个答案:

没有答案