/    Sign up×
Community /Pin to ProfileBookmark

Problem using jsPDF to output large table

I am trying to use jsPDF to export an HTML page to PDF, but I’m getting an error from within the jspdf.debug.js file: “Unable to get property ‘1’ of undefined or null reference”. Before trying it on my page, I used the example they give for jsPDF and edited it to make it an 11×17 landscape page and it worked. However, when I tried to bring that same functionality over to my table page, I keep getting the error. Here is my html file (or at least the major portions that are needed to show what’s wrong):

[code=html]<!DOCTYPE html>
<html>
<head>
<style>
body {
font-size: 11.5px;
}
td, th {
margin: 0px;
padding: 5px;
vertical-align: top;
font: 1em Arial, sans-serif;
border: 1px solid #CCCCCC;
}
.myTable {
margin: 0px;
margin-bottom: 10px;
padding: 0px;
vertical-align: top;
}
</style>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”></script>
<script src=”https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.debug.js”></script>
<script language=”javascript”>
var doc = new jsPDF({
orientation: “landscape”,
format: [279.4, 431.8]
}); //format is 11×17 in millimeters vs inches

var specialElementHandlers = {
‘#editor’: function(element, renderer) {
return true;
}
};

$(document).ready(function() {
$(“#btnSave”).click(function() {
alert(“Save document”);
doc.fromHTML($(“#content”).html(), 15, 15, {
“width”: 170,
“elementHandlers”: specialElementHandlers
});
doc.save(“C:\Users\ccote1\Desktop\Baseline Diffs\VPT-TCP-GUI-IRS-002_test.pdf”);
});
});
</script>
</head>
<body>
<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=”100%”>
<tr>
<td><input type=”button” value=”Save as PDF” id=”btnSave”></input> </td>
</tr>
</table>
<div id=”content”>
<table cellpadding=”0″ cellspacing=”0″ width=”100%”>
<tr>
<td id=”heading”>
<h4>Baseline Comparison Report</h4>
</td>
</tr>
</table>
<table class=”myTable” cellpadding=”0″ cellspacing=”0″ width=”100%”>
<thead>
<tr>
<th colspan=”7″><div id=”modInfo”><b>Module:</b> /VIRGINIA PSES/Block IV/3 – Software/TCP GUI IRS/VPT-TCP-GUI-IRS-002<a class=”exported”><b>Exported from DOORS on:</b> 3/30/2017 14:42:27</a></div>
</th>
</tr>
<tr>
<th width=”5%”><b>Object ID</b></th>
<th width=”8%”><b>Change</b></th>
<th width=”450px”><b>Baseline 1.3 (SCP-VPT-0448)</b></th>
<th width=”450px”><b>Baseline 1.4 (SCP-VPT-0476A)</b></th>
<th width=”15%”><b>Attributes</b></th>
<th width=”15%”><b>Links</b></th>
</tr>
</thead>
<tr>
<td>TCGI_227</td>
<td>Table Changed</td>
<td>
<table cellpadding=”0″ cellspacing=”0″ width=”80%”>
<tr>
<td>Revision<br /></td>
<td>Issue Date<br /></td>
<td>Description of Revision<br /></td>
</tr>
<tr>
<td>1.0<br /></td>
<td>February 26, 2016<br /></td>
<td>Initial Release<br /></td>
</tr>
<tr>
<td>1.2<br /></td>
<td>December 2, 2016<br /></td>
<td>SCP-VPT-0470<br /></td>
</tr>
<tr>
<td><span class=”addedItem”>1.4</span><br /></td>
<td><span class=”addedItem”>January 9, 2017</span><br /></td>
<td>SCP-VPT-<span class=”deletedItem”>0476</span><span class=”addedItem”>0476A</span><br /></td>
</tr>
<tr>
<td><a style=’color:red’><b>Cell Deleted</b></a><br /></td>
<td><a style=’color:red’><b>Cell Deleted</b></a><br /></td>
<td><a style=’color:red’><b>Cell Deleted</b></a><br /></td>
</tr>
</table>
</td>
<td>
<table cellpadding=”0″ cellspacing=”0″ width=”80%”>
<tr>
<td>Revision<br /></td>
<td>Issue Date<br /></td>
<td>Description of Revision<br /></td>
</tr>
<tr>
<td>1.0<br /></td>
<td>February 26, 2016<br /></td>
<td>Initial Release<br /></td>
</tr>
<tr>
<td>1.2<br /></td>
<td>December 2, 2016<br /></td>
<td>SCP-VPT-0470<br /></td>
</tr>
<tr>
<td>1.4<br /></td>
<td>January 9, 2017<br /></td>
<td>SCP-VPT-0476A<br /></td>
</tr>
<tr>
</tr>
</table>
</td>
<td>&nbsp;</td>
<td></td>
</tr>
<tr>
<td>TCGI_27</td>
<td>Object Text Changed<br /><br />
<u>SCP Comments:</u> VPT-170103-05 </td>
<td>a) VPT-TCP-SSS-002 Revision 1.<span class=”deletedItem”>27</span><span class=”addedItem”>31</span>, <span class=”deletedItem”>November</span><span class=”addedItem”>January</span> <span class=”deletedItem”>21</span><span class=”addedItem”>5</span>, <span class=”deletedItem”>2016</span><span class=”addedItem”>2017</span>, System/Subsystem Specification (SSS) for Payload Tube Control System for use with VIRGINIA Payload Tube (VPT) and Torpedo Tube<br /> </td>
<td>a) VPT-TCP-SSS-002 Revision 1.31, January 5, 2017, System/Subsystem Specification (SSS) for Payload Tube Control System for use with VIRGINIA Payload Tube (VPT) and Torpedo Tube<br /> </td>
<td><u>*Baseline Allocation</u>= VA4A-14/15-01
VA4A-16/15-01<br /><br /><u>*Object Type</u>= Text<br /><br /><u>*Safety Critical</u>= FALSE<br /><br /><u>*Verification Method</u>= <br /><br /></td>
<td><span style=’color:red’><s><a class=”arrow”><b>&#8656;</b></a> EPG_125</s></span><br />
</td>
</tr>
<tr>
<td>TCGI_285</td>
<td>Object Text Changed<br /><br />
<u>SCP Comments:</u> VPT-170103-05 </td>
<td>b) VPT-TTAP-SRS-002 Revision 1.<span class=”deletedItem”>4</span><span class=”addedItem”>6</span>, <span class=”deletedItem”>December</span><span class=”addedItem”>January</span> <span class=”deletedItem”>1</span><span class=”addedItem”>5</span>, <span class=”deletedItem”>2016</span><span class=”addedItem”>2017</span>, Software Requirements Specification for the VIRGINIA Payload Tube (VPT) Application Program (TTAP)<br /> </td>
<td>b) VPT-TTAP-SRS-002 Revision 1.6, January 5, 2017, Software Requirements Specification for the VIRGINIA Payload Tube (VPT) Application Program (TTAP)<br /> </td>
<td><u>*Baseline Allocation</u>= VA4A-14/15-01
VA4A-16/15-01<br /><br /><u>*Object Type</u>= Text<br /><br /><u>*Safety Critical</u>= FALSE<br /><br /><u>*Verification Method</u>= <br /><br /></td>
<td> </td>
</tr>
<tr>
<td>TCGI_108</td>
<td><u>SCP Comments:</u> VPT-170102-01</td>
<td></td>
<td>The PTAP GUI shall initialize the TTAP GUI.<br /> </td>
<td>
<u>*Baseline Allocation</u>=VA4A-14/15-01
VA4A-16/15-01<br /><br /><u>*Object Type</u>=Requirement<br /><br /><u>*Safety Critical</u>=FALSE<br /><br /><u>*Verification Method</u>=Inspection<br /><br /><br /></td>
<td></td>
</tr>
<tr>
<td>TCGI_106</td>
<td><u>SCP Comments:</u> VPT-170102-01</td>
<td></td>
<td>The TTAP GUI shall provide the PTAP GUI access to all TTAP displays. (see 2.2.1(b) Section 3.3.7.2.2)<br /> </td>
<td>
<u>*Baseline Allocation</u>=VA4A-14/15-01
VA4A-16/15-01<br /><br /><u>*Object Type</u>=Requirement<br /><br /><u>*Safety Critical</u>=FALSE<br /><br /><u>*Verification Method</u>=Demonstration<br /><br /><br /></td>
<td></td>
</tr>
<tr>
<td>TCGI_111</td>
<td><u>SCP Comments:</u> VPT-170102-01</td>
<td></td>
<td>The TTAP GUI shall provide the PTAP GUI access to all TTAP operational mode indicators.<br /> </td>
<td>
<u>*Baseline Allocation</u>=VA4A-14/15-01
VA4A-16/15-01<br /><br /><u>*Object Type</u>=Requirement<br /><br /><u>*Safety Critical</u>=FALSE<br /><br /><u>*Verification Method</u>=Demonstration<br /><br /><br /></td>
<td></td>
</tr>
</table>
<footer>
<div style=”margin:0 auto;” class=”note”><u><b>Note:</b></u> All bolding, underlines, and italics have been removed prior to checking differences.</div>
<tr>
<td>
The following attributes are new since the older baseline, and have not been compared:<br />*DXL Trace – Parent Requirement<br /><br /><b>Attributes Compared in this Module:</b> *Baseline Allocation, *Object Type, *Safety Critical, *Verification Method, Object Heading, Object Text, </td>
</tr>
</footer>
</div>
</body>
</html>[/code]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @ccote1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...