使用utf-8支持的js将HTML转换为PDF [英] HTML to PDF using js with utf-8 support

查看:75
本文介绍了使用utf-8支持的js将HTML转换为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将网页导出为pdf,这是我在浏览器中显示的html内容,我想为用户提供将其下载为pdf的功能,我尝试了jsPDF,但它不支持阿拉伯语 我需要pdf而不是word,并且需要在客户端执行.请帮忙 预先感谢

I need to export a web page as pdf it's html content that I display in the browser, I want to give the user the capability to download it as pdf, I tried jsPDF but it doesn't support arabic I need pdf not word, and I need to do it in the client side. please help Thanks in advance,

推荐答案

演示: 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>

这篇关于使用utf-8支持的js将HTML转换为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆