首页 文章

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

提问于
浏览
1

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

1 回答

  • 2

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

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

    要么

    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>
    

相关问题