{"id":1515,"date":"2017-06-03T17:39:46","date_gmt":"2017-06-03T09:39:46","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=1515"},"modified":"2018-12-13T14:02:35","modified_gmt":"2018-12-13T06:02:35","slug":"%e4%bd%bf%e7%94%a8-jquery-jspdf-%e6%8f%92%e4%bb%b6%e7%94%9f%e6%88%90pdf%e6%96%87%e6%a1%a3%e5%b9%b6%e8%a7%a3%e5%86%b3%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=1515","title":{"rendered":"\u4f7f\u7528 jQuery jsPDF \u63d2\u4ef6\u751f\u6210pdf\u6587\u6863\u5e76\u89e3\u51b3\u4e2d\u6587\u4e71\u7801\u95ee\u9898"},"content":{"rendered":"<p>\n\t\u6700\u8fd1\u8bba\u575b\u91cc\u6709\u4e00\u4f4d\u7f51\u53cb\u5728\u5b9e\u9645\u7528 <a href=\"https:\/\/parall.ax\/products\/jspdf\" name=\"jspdf\" target=\"_blank\" title=\"jspdf\">jsPDF \u63d2\u4ef6<\/a>\uff0c\u9047\u5230\u4e86\u95ee\u9898\u3002\u6211\u8fd9\u4e2a\u6574\u7406\u4e00\u4e0b\u5173\u4e8e\u8fd9\u4e2a\u63d2\u4ef6\u7684\u7528\u6cd5\u3002\n<\/p>\n<p>\n\tjsPDF <a href=\"http:\/\/baike.baidu.com\/item\/html5\" name=\"HTML5\" target=\"_blank\" title=\"HTML5\">HTML5<\/a>\u662f\u4e00\u4e2a\u5ba2\u6237\u7aef\u89e3\u51b3\u65b9\u6848\u751f\u6210pdf\u6587\u4ef6\u3002\u9002\u5408\u6d3b\u52a8\u95e8\u7968\u3001\u62a5\u544a\u3001\u8bc1\u4e66,\u7b49\u7b49\u3002 \u5b83\u5c06\u5728IE6+,Firefox 3 +,Chrome,Safari 3 +,Opera\u3002IE9\u4e0b\u5de5\u4f5c\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"jsPDF \u63d2\u4ef6\" src=\"http:\/\/img-bbs.csdn.net\/upload\/201706\/03\/1496480989_503776.png\" style=\"width: 620px;height: 400px\" \/>\n<\/p>\n<p>\n\tjspdf \u5b98\u65b9\u5730\u5740\uff1a<a href=\"https:\/\/parall.ax\/products\/jspdf\" target=\"_blank\">https:\/\/parall.ax\/products\/jspdf<\/a>\n<\/p>\n<p>\n\tjspdf \u652f\u6301\u4ee5\u4e0b\u51e0\u79cd\u5185\u5bb9\uff1a\n<\/p>\n<ul>\n<li>\n\t\tImages \u56fe\u7247\n\t<\/li>\n<li>\n\t\tFont faces&nbsp;\u5b57\u4f53\n\t<\/li>\n<li>\n\t\tTwo page Hello World \u5206\u9875\u663e\u793a\u5185\u5bb9\n\t<\/li>\n<li>\n\t\tCircles \u692d\u5706\u56fe\u5f62\u7b49\n\t<\/li>\n<li>\n\t\tFont sizes \u8bbe\u7f6e\u5b57\u4f53\u5927\u5c0f\n\t<\/li>\n<li>\n\t\tLandscape \u9884\u89c8\u8bbe\u7f6e\uff0c\u6253\u5370\uff0c\u5927\u5c0f\u7f29\u653e\u7b49\n\t<\/li>\n<li>\n\t\tLines \u7ebf\u6761\uff0c\u7b80\u5355\u56fe\u8868\n\t<\/li>\n<li>\n\t\tRectangles \u77e9\u5f62\u56fe\u5f62\n\t<\/li>\n<li>\n\t\tString Splitting \u5b57\u7b26\u4e32\u62c6\u5206\uff0c\u81ea\u52a8\u6362\u884c\n\t<\/li>\n<li>\n\t\tTriangles \u652f\u6301\u4e09\u89d2\u5f62\n\t<\/li>\n<\/ul>\n<p>\n\t\u9664\u4e86\u4e0a\u9762\u7684\u7279\u8272\u5916\uff0c\u8fd8\u652f\u6301\u5927\u5c0f\u7f29\u653e\uff0c\u5927\u5c0f\u8c03\u6574\uff0c\u6253\u5370\uff0c\u4e0b\u8f7d\u7b49\u529f\u80fd\u3002\n<\/p>\n<h2>\n\tjspdf \u5b9e\u4f8b<br \/>\n<\/h2>\n<p>\n\tjspdf \u7684\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u5bfc\u5165\u5bf9\u5e94js\uff0c\u7f16\u5199\u4ee5\u4e0b\u4ee3\u7801\u5373\u53ef\u3002\n<\/p>\n<pre class=\"brush:jscript;\">\r\nvar doc = new jsPDF();\r\ndoc.text(20, 20, &#039;Hello world.&#039;);\r\ndoc.save(&#039;Test.pdf&#039;);<\/pre>\n<p>\n\t\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;!DOCTYPE html&gt; \r\n&lt;html&gt; \r\n&lt;head&gt; \r\n\t&lt;title&gt;Downloadify&lt;\/title&gt; \r\n\t&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text\/html;charset=utf-8&quot;&gt; \r\n\t&lt;style type=&quot;text\/css&quot; media=&quot;screen&quot;&gt; \r\n\tbody {background: #fff; width: 500px; margin: 20px auto;} \r\n\tinput, textarea, p { font-family: \u5b8b\u4f53, \u9ed1\u4f53; font-size: 12pt;} \r\n\tinput, textarea { border: solid 1px #aaa; padding: 4px; width: 98%;} \r\n\t&lt;\/style&gt; \r\n\t&lt;script type=&quot;text\/javascript&quot; src=&quot;js\/swfobject.js&quot;&gt;&lt;\/script&gt; \r\n\t&lt;script type=&quot;text\/javascript&quot; src=&quot;js\/downloadify.js&quot;&gt;&lt;\/script&gt; \r\n\t&lt;script type=&quot;text\/javascript&quot; src=&quot;js\/jspdf.js&quot;&gt;&lt;\/script&gt; \r\n\t&lt;!-- &lt;script type=&quot;text\/javascript&quot; src=&quot;js\/downloadify.min.js&quot;&gt;&lt;\/script&gt; --&gt; \r\n\t&lt;script type=&quot;text\/javascript&quot;&gt; \r\n\t\twindow.load=function(){ \r\n\t\t\tDownloadify.create(&#039;downloadify&#039;,{ \r\n\t\t\t\tfilename: function(){ \r\n\t\t\t\t\treturn document.getElementById(&#039;filename&#039;).value; \r\n\t\t\t}, \r\n\t\t\tdata: function(){ \r\n\t\t\t\tvar doc = new jsPDF(); \r\n\t\t\t\tdoc.text(20, 20, document.getElementById(&#039;data&#039;).value); \r\n\t\t\t\tdoc.addPage(); \r\n\t\t\t\tdoc.text(20, 20, document.getElementById(&#039;data&#039;).value); \r\n\t\t\t\treturn doc.output(); \r\n\t\t\t}, \r\n\t\t\tonComplete: function(){ alert(&#039;\u6210\u529f\u4fdd\u5b58\u6587\u4ef6!&#039;); }, \r\n\t\t\tonCancel: function(){ alert(&#039;\u60a8\u5df2\u7ecf\u53d6\u6d88\u4fdd\u5b58\u6587\u4ef6&#039;); }, \r\n\t\t\tonError: function(){ alert(&#039;\u51fa\u73b0\u9519\u8bef\u4e86&#039;); }, \r\n\t\t\tswf: &#039;js\/downloadify.swf&#039;, \r\n\t\t\tdownloadImage: &#039;js\/download.png&#039;, \r\n\t\t\twidth: 100, \r\n\t\t\theight: 30, \r\n\t\t\ttransparent: true, \r\n\t\t\tappend: false \r\n\t\t\t}); \r\n\t\t} \r\n\t&lt;\/script&gt; \r\n&lt;\/head&gt; \r\n&lt;body onload=&quot;load();&quot;&gt; \r\n&lt;input type=&quot;text&quot; name=&quot;filename&quot; value=&quot;\u6587\u4ef6\u540d.pdf&quot; id=&quot;filename&quot; \/&gt;&lt;br \/&gt; \r\n&lt;textarea cols=&quot;60&quot; rows=&quot;10&quot; name=&quot;data&quot; id=&quot;data&quot;&gt;it seem do not support to Chinese&lt;\/textarea&gt; \r\n&lt;p id=&quot;downloadify&quot;&gt;You must have Flash 10 installed to download this file.&lt;\/p&gt; \r\n&lt;\/body&gt; \r\n&lt;\/html&gt; <\/pre>\n<p>\n\tjspdf \u63d2\u4ef6\u4e0b\u8f7d\uff0c\u5927\u5bb6\u53ef\u4ee5\u5230\u5b98\u7f51\u4e0a\u81ea\u884c\u4e0b\u8f7d\u3002\n<\/p>\n<h2>\n\t\u4e2d\u6587\u4e71\u7801\u5904\u7406<br \/>\n<\/h2>\n<p>\n\tjsPDF \u63d2\u4ef6\u5bf9\u4e2d\u6587\u652f\u6301\u4e0d\u591f\u53cb\u597d\uff0c\u4f1a\u51fa\u73b0\u4e71\u7801\u95ee\u9898\u3002\u76ee\u524d\u6bd4\u8f83\u597d\u7684\u89e3\u51b3\u529e\u6cd5\u662f\uff0c\u4e2d\u6587\u90e8\u5206\u4f7f\u7528\u56fe\u7247\u66ff\u6362\u3002\u8fd8\u6709\u4e00\u79cd\u505a\u6cd5\u662f\u5236\u4f5c\u4e00\u4e2a\u6587\u5b57\u5305\u3002\u8fd9\u79cd\u505a\u6cd5\u9700\u8981\u5bf9\u6e90\u7801\u6709\u5f88\u6df1\u7684\u7406\u89e3\u3002\n<\/p>\n<p>\n\t\u611f\u89c9\u8fd9\u6837\u9ebb\u70e6\u7684\uff0c\u53ef\u4ee5\u628a\u6240\u6709\u5185\u5bb9\u90fd\u52a0\u5165 <a href=\"http:\/\/baike.baidu.com\/item\/canvas\/16416421#viewPageContent\" name=\"Canvas\" target=\"_blank\" title=\"Canvas\">Canvas<\/a> \u4e2d\uff0c\u4f7f\u7528 <a href=\"http:\/\/www.xttblog.com\/?p=261\" name=\"html2canvas\" target=\"_blank\" title=\"html2canvas\">html2canvas<\/a> \u63d2\u4ef6\u5c06 canvas \u4e2d\u5185\u5bb9\u8f6c\u6362\u6210\u56fe\u7247\uff0c\u7136\u540ejspdf \u4e2d\u663e\u793a\u56fe\u7247\u5373\u53ef\u3002\u5173\u4e8e <a href=\"http:\/\/www.xttblog.com\/?p=261\" name=\"html2canvas\" target=\"_blank\" title=\"html2canvas\">html2canvas<\/a> \u7684\u5185\u5bb9\uff0c<a href=\"http:\/\/www.xttblog.com\/?p=261\" name=\"html2canvas\" target=\"_blank\" title=\"html2canvas\">\u70b9\u8fd9\u91cc<\/a>\u8fdb\u884c\u5b66\u4e60\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=1515\">\u4f7f\u7528 jQuery jsPDF \u63d2\u4ef6\u751f\u6210pdf\u6587\u6863\u5e76\u89e3\u51b3\u4e2d\u6587\u4e71\u7801\u95ee\u9898<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u8bba\u575b\u91cc\u6709\u4e00\u4f4d\u7f51\u53cb\u5728\u5b9e\u9645\u7528 jsPDF \u63d2\u4ef6\uff0c\u9047\u5230\u4e86\u95ee\u9898\u3002\u6211\u8fd9\u4e2a\u6574\u7406\u4e00\u4e0b\u5173\u4e8e\u8fd9\u4e2a\u63d2\u4ef6\u7684\u7528\u6cd5\u3002 jsPDF H [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[54,49,1257,1258,1259],"class_list":["post-1515","post","type-post","status-publish","format-standard","hentry","category-html5","tag-html2canvas","tag-jquery","tag-jspdf","tag-pdf","tag-1259"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1515"}],"version-history":[{"count":2,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1515\/revisions"}],"predecessor-version":[{"id":3551,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1515\/revisions\/3551"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}