我花了过去 3 天试图解决这个问题,但一直得到相同的结果......
我有一个使用 JavaScript 完成的 HTML 表格。
HTML
<div id="tb_container">
<table id="tb_Logbook" class="table table-striped" onload="LoadPilotLogBook()">
<thead>
<tr>
<th><center>DATE</center></th>
<th colspan="2">DEPARTURE</th>
<th colspan="2">ARRIVAL</th>
<th colspan="2">AIRCRAFT</th>
<th colspan="2">SINGLE PILOT FLIGHT TIME</th>
<th>MULTI-PILOT</th>
<th>TOTAL TIME</th>
<th>NAME OF</th>
<th colspan="2">LANDINGS</th>
<th>APPROACH</th>
<th colspan="2">OPERATIONAL CONDITION TIME</th>
<th colspan="4">PILOT FUNCTION TIME</th>
<th colspan="3">FLIGHT SIM TRAINING</th>
<th>REMARKS AND</th>
<th colspan="2">ACTIONS</th>
</tr>
<tr>
<th><center>dd/mm/yyyy</center></th>
<th>Place</th>
<th>Time</th>
<th>Place</th>
<th>Time</th>
<th>Model</th>
<th>Registration</th>
<th>SE</th>
<th>ME</th>
<th>FLIGHT TIME</th>
<th>OF FLIGHT</th>
<th>Pilot in command</th>
<th>Day</th>
<th>Night</th>
<th>IFR</th>
<th>Night</th>
<th>IFR</th>
<th>PIC</th>
<th>Co-Pilot</th>
<th>Dual</th>
<th>Instructor</th>
<th>Date</th>
<th>Type</th>
<th>Time</th>
<th>ENDORSMENTS</th>
<th>EDIT</th>
<th>SUPPR</th>
</tr>
</thead>
<tbody>
//AutoGenerated via JS
</tbody>
</table>
</div>
我已经包含了所有这些文件:
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js"></script>
<script src="https://rawgit.com/someatoms/jsPDF-AutoTable/master/dist/jspdf.plugin.autotable.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.0.10/jspdf.plugin.autotable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script>
JavaScript
window.html2canvas = html2canvas
var doc = new jsPDF('l', 'mm', [297, 210]);
title = "Your Logbook",
source = $('#tb_container')[0];
specialElementHandlers = {
'#bypassme': function (element, renderer) {
return true
}
};
margins = {
top: 100,
bottom: 10,
left: 10,
right: 10
};
$('#cmd').click(function () {
doc.addHTML($('#tb_Logbook')[0], function () {
title,
source,
margins.left,
margins.top, {
'width': margins.width,
'elementHandlers': specialElementHandlers
},
doc.save('LOGBOOK_' + userLastName + '_' + userFirstName + '.pdf');
});
});
当我单击按钮导出为 PDF 时,我得到这个文件:
我现在真的不知道如何处理这个问题。
谢谢你的帮助 !