使用带有utf-8支持的js的HTML到PDF

时间:2017-07-02 20:54:01

标签: utf-8 jspdf html-to-pdf

我需要将网页导出为PDF格式我在浏览器中显示的html内容,我想让用户能够以PDF格式下载它,我尝试了jsPDF,但它没有支持阿拉伯语 我需要pdf而不是单词,我需要在客户端进行。请帮忙 提前谢谢,

1 个答案:

答案 0 :(得分:2)

  

演示: http://jsfiddle.net/kumarrishikesh12/rwdL0rxh/

<script async src="//jsfiddle.net/kumarrishikesh12/rwdL0rxh/embed/"></script>

OR

function doit(){
if (!window.print){
alert("You need NS4.x to use this print button!")
return
}
window.print()
}
color:#C03;
	font-size:18px; font-family:"Courier New", Courier, monospace;
	}
p{ font-family:"Comic Sans MS", cursive;
font-size:15px; color:#066; text-align:justify;}
a{
	text-decoration:none;
	font-size:20px; }
<body>

<div style="float:right;">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- sidebar300X600 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:600px"
     data-ad-client="ca-pub-1456458421931279"
     data-ad-slot="1562820743"></ins>

</div>

<div style="width:500px; height:600px; border:2px #093 dashed; margin:0 auto; padding:10px;">
<h2>What is PHP?</h2>

<p>PHP is a server side scripting language commonly used for web applications</p>

<h2>How to include a file to a php page?</h2>

<p>we can include a file using &quot;include() &quot; or &quot;require()&quot; function with as its parameter..</p>

<h2>What&#39;s the difference between include and require?</h2>

<p>If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.</p>

<h2>What Is a Session?</h2>

<p>It can be used to store information on the server for future use</p>

<h2>How to set cookies in PHP?</h2>

<p>Cookies are often used to track user information Syntax: Setcookie(name, value, expire, path, domain); eg:Setcookie(&quot;sample&quot;, &quot;ram&quot;, time()+3600);</p>

<div align="center"><a href="javascript:doit()"><img align="middle" border="0" src="http://demos.2my4edge.com/2my4edge-print-page/icon-48-print.png" /> Click here to Print the Page</a></div>
</div>


</body>