1
ここに私が達成しようとしているのは、HTMLテーブルを内部に含んだhtmlテーブルを印刷しようとしています。私の詳細(ヘッダと詳細があります)のデータです。しかし、私がHTMLテーブルを印刷するためにjspdf.jsを使用すると、pdfのテーブルが壊れてしまい、HTMLのように見えなくなり、メインテーブル内のループテーブルが乱雑になり、内部テーブルが作成されないように見えます。どのようにテーブル内のテーブルを正しく印刷するには?ここ 正しく印刷するにはjspdf.jsを使用してHTMLテーブルdo PDFを作成しますか?
は私のHTMLは私jsfiddleがある<div id="customers">
<div class="table-responsive">
<table id="tbl" class="table table-hover">
<thead>
<tr>
<th style="background-color: #928989; color; white;">No BPS</th>
<th style="background-color: #928989; color; white;">Tanggal BPS</th>
<th style="background-color: #928989; color; white;">Tanggal Input</th>
<th style="background-color: #928989; color; white;">Status</th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="listLaporanRetur in listLaporanReturs | limitTo:quantity">
<td class="btn btn-mini btn-primary pull-center">BPXXXXXXX</td>
<td>2016-06-22</td>
<td>2016-06-22</td>
<td>SENT</td>
</tr>
<tr ng-repeat-end="">
<td colspan="10" style="padding: 0">
<div>
<table class="table table-bordered table-hover">
<tr>
<td style="background-color: #80A3C1;">Kode Barang</td>
<td style="background-color: #80A3C1;">Qty</td>
<td style="background-color: #80A3C1;">Merk</td>
<td style="background-color: #80A3C1;">Hasil</td>
</tr>
<tr ng-repeat-start="details in listLaporanRetur.returDetailList">
<td>STUFFID1</td>
<td>10</td>
<td>APPLE</td>
<td>BOOM</td>
</tr>
<tr>
<td>STUFFID2</td>
<td>40</td>
<td>SONY</td>
<td>BREAK</td>
</tr>
<tr ng-repeat-end=""></tr>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<button onclick="javascript:demoFromHTML();">PDF</button>
は、ここに私のjavascriptここ
function demoFromHTML() {
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 = $('#customers')[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: 10,
width: 700
};
// 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);
}
ある
index.htmlのように見えている表を印刷する方法http://jsfiddle.net/ugD5L/126/
適切に私はPDFで乱雑なテーブルを取得する必要はありません?あなたがjsfiddleの例で私を見せることができればよかった
で-line.Firstごfile.WriteのCSSの左端にあなたのテキストはpdf.Putとしてhtmlと使用の上のすべての動的データを、それを印刷する前に、あなたのPDFビューをチェック揃えループはforeachのように
@Bugfixer JsPDFは、あなたが今述べたことをサポートしていません。 TCPDFは、HTML5でクライアント側でPDFを生成するJsPDFと比較して、サーバー側のオプションです。 – kazenorin
この質問は以前に尋ねられ、答えられましたhttp://stackoverflow.com/questions/19807870/how-to-export-the-html-tables-data-into-pdf-using-jspdf –
答えて
回答ネストされたテーブルの1つで言及されているようにJsPDFはこれまでサポートされていませんでした。
Demo
出典
2016-06-27 03:11:01 Neha
もし投票結果がわからないのならば...問題を解決するためのそのちょっとした提案その要件に応じていない場合。ちょうどコメントを削除します。 – Neha
いいえ、私には投票してもらえません。私の質問も投票が下がります。あなたの答えは最高ですが、まず何か別の答えを見る必要があります。 kazenorinには別の方法があります –
関連する問題