{"id":225,"date":"2012-03-03T00:47:34","date_gmt":"2012-03-03T00:47:34","guid":{"rendered":"d1c38a09acc34845c6be3a127a5aacaf"},"modified":"2012-03-03T00:47:34","modified_gmt":"2012-03-03T00:47:34","slug":"","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/225","title":{"rendered":"PHP\u751f\u6210PDF\u6587\u6863\u7684\u4e24\u79cd\u65b9\u5f0f\u53caHTML2PDF"},"content":{"rendered":"<p><span style=\"text-align:center;widows:2;text-transform:none;text-indent:0px;border-collapse:separate;font:medium Simsun;white-space:normal;orphans:2;letter-spacing:normal;color:#000000;word-spacing:0px;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;\" class=\"Apple-style-span\"><span style=\"text-align:left;color:#114246;font-size:12px;\" class=\"Apple-style-span\">&nbsp;<\/p>\n<h3 style=\"text-align:left;padding-bottom:0px;line-height:24px;overflow-x:hidden;overflow-y:hidden;margin:30px 0px 20px;padding-left:0px;padding-right:0px;word-wrap:break-word;font-size:14px;word-break:break-all;padding-top:0px;\" class=\"title pre fs1\" align=\"center\"><span style=\"font-size:20px;\" class=\"tcnt\">PHP\u751f\u6210PDF\u6587\u6863\u7684\u4e24\u79cd\u65b9\u5f0f\u53caHTML2PDF<\/span><\/h3>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u4e00\u3001PHP\u624b\u518c\u4e2d\u63d0\u5230\u7684\uff0c\u7528dll\u6587\u4ef6\u7684\u6269\u5c55\u5e93\uff0c\u4f7f\u7528pdflib\uff08\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/www.pdflib.com\/download\/pdflib-family\/pdflib-7\/\uff09\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">1.\u4e0b\u8f7ddll\u7ec4\u4ef6\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">2.\u653e\u5728AppServ\\php5\\ext\uff08\u5373php\u6269\u5c55\u6587\u4ef6\u5939\uff09\u4e0b\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">3.\u4fee\u6539PHP.INI\uff0c\u589e\u52a0extension=libpdf_php.dll\u8fd9\u53e5\uff0c\u4e00\u822c\u90fd\u5728\u6700\u540e\u6dfb\u52a0\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">4.\u91cd\u542f\u670d\u52a1\u5668\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u7f3a\u70b9\uff1a\u56e0\u4e3apdflib\u662f\u76c8\u5229\u7684\uff0c\u4f46\u63d0\u4f9b\u514d\u8d39\u4e0b\u8f7d\uff0c\u53ea\u4e0d\u8fc7\u514d\u8d39\u7248\u7684\u4f1a\u5728\u751f\u6210\u7684PDF\u6587\u4ef6\u4e0a\u9762\u6709\u6c34\u5370\uff0c\u5f71\u54cd\u7f8e\u89c2\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u4e8c\u3001\u4f7f\u7528fpdf\u7c7b\uff0c\u6bd4\u8f83\u5e38\u89c1\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5f00\u6e90\uff0c\u6587\u4ef6\u4e0b\u8f7d\u5730\u5740\uff1a<a style=\"line-height:22px;color:#ffffff;text-decoration:none;\" href=\"http:\/\/www.fpdf.org\/\">http:\/\/www.fpdf.org\/<\/a>\uff0c\u8fd8\u6709\u591a\u56fd\u8bed\u8a00\u7684\u624b\u518c\uff0c\u5f88\u4e0d\u9519\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u8bbe\u7f6e\uff0c\u53ea\u8981\u5f15\u5165\u6587\u4ef6\u5373\u53ef\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u7f3a\u70b9\uff1a\u5bf9\u4e2d\u6587\u652f\u6301\u4e0d\u662f\u5f88\u597d\uff0c\u9700\u8981\u81ea\u5df1\u6269\u5c55\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u4e09\u3001HTML2FPDF\uff1ahttp:\/\/html2fpdf.sourceforge.net\/\u4e0b\u8f7d\u7c7b\u6587\u4ef6<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u5b9e\u4f8b\uff1a<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">&lt;?<br style=\"line-height:22px;\" \/><br \/>\nrequire_once('html2fpdf.php');<br style=\"line-height:22px;\" \/><br \/>\n\/\/ activate Output-Buffer:<br style=\"line-height:22px;\" \/><br \/>\nob_start();<br style=\"line-height:22px;\" \/><br \/>\n?&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;html&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;head&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;title&gt;HTML 2 (F)PDF Project&lt;\/title&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;\/head&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;body&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;div align=\"center\"&gt;&lt;img src=\"logo.gif\" alt=\"HTML 2 PDF logo\" \/&gt;&lt;\/div&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;h2 align=\"center\"&gt;HTML 2 PDF Project&lt;\/h2&gt;<br style=\"line-height:22px;\" \/><br \/>\nBelow are the descriptions of each MENU button:<br style=\"line-height:22px;\" \/><br \/>\n&lt;ul&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;li&gt;&lt;b&gt;&lt;font color=\"red\"&gt;HOME&lt;\/font&gt;&lt;\/b&gt; - Returns to the main page (this one)&lt;\/li&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;li&gt;&lt;b&gt;FEATURES&lt;\/b&gt; - Explains the script's main features&lt;\/li&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;li&gt;&lt;b&gt;EXAMPLES&lt;\/b&gt; - A series of examples in which the script works&lt;\/li&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;li&gt;&lt;b&gt;CLASS-DOC&lt;\/b&gt; - Some documentation about the used classes&lt;\/li&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;li&gt;&lt;b&gt;LICENSE&lt;\/b&gt; - In case you want to distribute or modify the code&lt;\/li&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;li&gt;&lt;b&gt;CREDITS&lt;\/b&gt; - (the name says it all)&lt;\/li&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;li&gt;&lt;b&gt;FAQ&lt;\/b&gt; - Frequently asked questions...and answers!&lt;\/li&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;\/ul&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;p&gt;This project is hosted on Source Forge. DOWNLOAD IT &lt;a<br style=\"line-height:22px;\" \/><br \/>\nhref=\"<a style=\"line-height:22px;color:#ffffff;text-decoration:none;\" href=\"http:\/\/sourceforge.net\/projects\/html2fpdf\">http:\/\/sourceforge.net\/projects\/html2fpdf<\/a>\" target=\"_blank\"&gt;THERE&lt;\/a&gt;!&lt;\/p&gt;<br style=\"line-height:22px;\" \/><br \/>\nThis script was written on PHP 4.3.3 (should work on 4.0 and greater)<br style=\"line-height:22px;\" \/><br \/>\n&lt;br \/&gt;&lt;br \/&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;div style='background:#ccc;border:thin dashed black'&gt;<br style=\"line-height:22px;\" \/><br \/>\nThis page was dinamically created using PHP ob_get_contents and HTML2FPDF<br style=\"line-height:22px;\" \/><br \/>\nclass.&lt;br \/&gt;<br style=\"line-height:22px;\" \/><br \/>\nRead more on FAQ on how to make this or check the 2&lt;sup&gt;nd&lt;\/sup&gt; page (use the<br style=\"line-height:22px;\" \/><br \/>\n'PageDown' keyboard key)&lt;\/div&gt;&lt;newpage&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;div style='background:#eee;font-weight:bold'&gt;&lt;code&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;? $metaphp = htmlspecialchars($metaphp);<br style=\"line-height:22px;\" \/><br \/>\n$metaphp = str_replace(\"\\n\",'&lt;br&gt;',$metaphp);<br style=\"line-height:22px;\" \/><br \/>\necho \"&amp;lt;?\".$metaphp.\"?&amp;gt;\"; ?&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;\/div&gt;&lt;\/code&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;\/body&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;\/html&gt;<br style=\"line-height:22px;\" \/><br \/>\n&lt;?<br style=\"line-height:22px;\" \/><br \/>\n\/\/ Output-Buffer in variable:<br style=\"line-height:22px;\" \/><br \/>\n$html=ob_get_contents();<br style=\"line-height:22px;\" \/><br \/>\n\/\/ delete Output-Buffer<br style=\"line-height:22px;\" \/><br \/>\nob_end_clean();<br style=\"line-height:22px;\" \/><br \/>\n$pdf = new HTML2FPDF();<br style=\"line-height:22px;\" \/><br \/>\n$pdf-&gt;DisplayPreferences('HideWindowUI');<br style=\"line-height:22px;\" \/><br \/>\n$pdf-&gt;AddPage();<br style=\"line-height:22px;\" \/><br \/>\n$pdf-&gt;WriteHTML($html);<br style=\"line-height:22px;\" \/><br \/>\n$pdf-&gt;Output('doc.pdf','I');<br style=\"line-height:22px;\" \/><br \/>\n?&gt;<\/p>\n<p><\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p><span style=\"text-align:center;widows:2;text-transform:none;text-indent:0px;border-collapse:separate;font:medium Simsun;white-space:normal;orphans:2;letter-spacing:normal;color:#000000;word-spacing:0px;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;\" class=\"Apple-style-span\"><span style=\"text-align:left;color:#114246;font-size:12px;\" class=\"Apple-style-span\">&nbsp;<\/p>\n<h3 style=\"text-align:left;padding-bottom:0px;line-height:24px;overflow-x:hidden;overflow-y:hidden;margin:30px 0px 20px;padding-left:0px;padding-right:0px;word-wrap:break-word;font-size:14px;word-break:break-all;padding-top:0px;\" class=\"title pre fs1\" align=\"center\"><span style=\"font-size:20px;\" class=\"tcnt\">PHP\u751f\u6210PDF\u6587\u6863\u7684\u4e24\u79cd\u65b9\u5f0f\u53caHTML2PDF<\/span><\/h3>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u4e00\u3001PHP\u624b\u518c\u4e2d\u63d0\u5230\u7684\uff0c\u7528dll\u6587\u4ef6\u7684\u6269\u5c55\u5e93\uff0c\u4f7f\u7528pdflib\uff08\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/www.pdflib.com\/download\/pdflib-family\/pdflib-7\/\uff09\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">1.\u4e0b\u8f7ddll\u7ec4\u4ef6\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">2.\u653e\u5728AppServ\\php5\\ext\uff08\u5373php\u6269\u5c55\u6587\u4ef6\u5939\uff09\u4e0b\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">3.\u4fee\u6539PHP.INI\uff0c\u589e\u52a0extension=libpdf_php.dll\u8fd9\u53e5\uff0c\u4e00\u822c\u90fd\u5728\u6700\u540e\u6dfb\u52a0\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">4.\u91cd\u542f\u670d\u52a1\u5668\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u7f3a\u70b9\uff1a\u56e0\u4e3apdflib\u662f\u76c8\u5229\u7684\uff0c\u4f46\u63d0\u4f9b\u514d\u8d39\u4e0b\u8f7d\uff0c\u53ea\u4e0d\u8fc7\u514d\u8d39\u7248\u7684\u4f1a\u5728\u751f\u6210\u7684PDF\u6587\u4ef6\u4e0a\u9762\u6709\u6c34\u5370\uff0c\u5f71\u54cd\u7f8e\u89c2\u3002<\/p>\n<p style=\"text-align:left;padding-bottom:0px;line-height:22px;overflow-x:hidden;overflow-y:hidden;margin:0px 0px 10px;padding-left:0px;padding-right:0px;word-wrap:break-word;color:#114246;font-size:14px;padding-top:0px;\" class=\"bct fc05 fc11 nbw-blog ztag js-fs2\">\u4e8c\u3001\u4f7f\u7528fpdf\u7c7b\uff0c\u6bd4\u8f83\u5e38\u89c1\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5f00\u6e90...<\/p>\n<p><\/span><\/span> <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/225\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[273],"tags":[71,27],"class_list":["post-225","post","type-post","status-publish","format-standard","hentry","category-article","tag-pdf","tag-php"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=225"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/225\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}