有什么方法可以从PDF中排除分页和排序?我正在使用bootstrap模板和数据表。
我只是想打印表格。 还可以为此添加标题吗?以及其他元素?
<script>
$(function () {
$("#example1").DataTable();
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false
});
});
function demoFromHTML() {
var pdf = new jsPDF('landscape', 'pt', 'legal');
// source can be HTML-formatted string, or a reference
// to an actual DOM element from which the text will be scraped.
source = $('#content')[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: 80,
bottom: 60,
left: 40,
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) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('Test.pdf');
}, margins);
}
</script>
<div class="box-body" id="content">
<a href="javascript:demoFromHTML()" class="btn btn-primary">Run Code</a>
<div class="box-body" id="content">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Date</th>
<th>Shift</th>
<th>Product</th>
<th>Trans. No.</th>
<th>U/Cost</th>
<th>Liters</th>
<th>Amount</th>
<th>Cash Deposit</th>
<th>Check Deposit</th>
<th>Variance</th>
<th>Cashier</th>
</tr>
</thead>
<tbody>
<c:forEach items="${SalesReport}" var="p">
<tr>
<td>${p.date}</td>
<td>${p.shift}</td>
<td>${p.product}</td>
<td>${p.nooftrans}</td>
<td>${p.uprice}</td>
<td>${p.tank1liters}</td>
<td>${p.cashdepoamt}</td>
<td>${p.cashdepoamt}</td>
<td>${p.checkdepoamt}</td>
<td>${p.variance}</td>
<td>${p.cashier}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div><!-- /.box-body -->
</div><!-- /.box -->