2

What's the best way to print tables in PDF with JavaScript?

For example, I have the next code, and if you click on "Show PDF", the table appears in PDF in a new window. Is it possible to implement this with the jsPDF library?

<body>
    <table>
        <tr>
            <th>example</th>
            <th>example2</th>
        </tr>
        <tr>
            <td>value1</td>
            <td>value2</td>
        </tr>
    </table>
    <br>
    <input type="button" value="Show PDF">
</body>
4

5 に答える 5

1

Bytescout には、クライアント側で PDF ファイルを 100% 生成できる新しい JavaScript 製品 "PDF Generator SDK for Javascript" があります。おそらく、テキスト、画像、グラフィックスを含む PDF を生成できます。完全な HTML フォーマットはサポートされていませんが、テキスト内で 、 、 html タグを使用してリッチ フォーマットを使用できます (新しいバージョンでは、テキスト内で および html タグがサポートされる予定です)。

ロゴと表が生成された請求書のデモ: http://bytescout.com/products/developer/pdfgeneratorsdkjs/create_pdf_invoice_javascript.html

于 2013-02-09T20:57:56.540 に答える
0

試してみてください TCPDF
TCPDF は、外部拡張機能を必要とせずにオンザフライで PDF ファイルを生成するための PHP クラスです。このライブラリには、既存の PDF ドキュメントからデータを抽出するクラスと、さまざまな形式の 1D および 2D バーコードを生成するクラスも含まれています。

于 2014-05-16T13:03:22.903 に答える
-2

You should to use DOMPDF, :
dompdf is an HTML to PDF converter. At its heart, dompdf is (mostly) CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements. It also supports most presentational HTML attributes.

Download domPDF

http://code.google.com/p/dompdf/

<?
require  "dompdf_config.inc.php";
$html = <<<STY
<table>
<tr>
<th>example</th>
<th>example2</th>
</tr>
<tr>
<td>value1</td>
<td>value2</td>
</tr>
</table>
</body>
STY;
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();    
$dompdf->stream("mypdf.pdf", array("Attachment" => 0));
?>
于 2013-02-09T20:52:18.570 に答える