Top Ad unit 728 × 90

random

convert html to pdf using javascript

convert html to pdf using javascript

convert html to pdf using javascriptThere are many scenario when we need to generate PDF using JavaScript. It is possible to generate html to pdf using jquery and jsPDF library. It allows you to select the DOM elements                                                                                that you would wish to                                                                                    publish to PDF.
Below is the Sample Code for generating PDF.  Add libraries- JQuery and jsPDF
  
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script>
    <style> 
        table
            font-family: arial, sans-serif
            border-collapse: collapse
            width: 100%
        } 
 
        td, th
            border: 1px solid #dddddd
            text-align: left
            padding: 8px
        } 
 
        tr:nth-child(even)
            background-color: #dddddd
        } 
    </style>
</head>

<body>
    <form id="form1" runat="server">
             
       <table>
            <tbody> 
                <tr> 
                    <th>Company</th> 
                    <th>Contact</th> 
                    <th>Country</th> 
                </tr> 
                <tr> 
                    <td>HCL</td> 
                    <td>Maria Anders</td> 
                    <td>USA</td> 
                </tr> 
                <tr> 
                    <td>Conduent</td> 
                    <td>Francisco Chang</td> 
                    <td>UK</td> 
                </tr> 
                <tr> 
                    <td>Wipro</td> 
                    <td>Roland Mendel</td> 
                    <td>Austria</td> 
                </tr> 
                <tr> 
                    <td>NIIT Technologies LTD</td> 
                    <td>Helen Bennett</td> 
                    <td>INDIA</td> 
                </tr> 
                <tr> 
                    <td>Laughing Bacchus Winecellars</td> 
                    <td>Yoshi Tannamuri</td> 
                    <td>Canada</td> 
                </tr> 
                <tr> 
                    <td>Magazzini Alimentari Riuniti</td> 
                    <td>Giovanni Rovelli</td> 
                    <td>Italy</td> 
                </tr> 
            </tbody> 
        </table>

    </form>
</body>
     <script>
         let doc = new jsPDF('p', 'pt', 'a4'); 
         doc.addHTML(document.body, function () {
             doc.save('html.pdf');
         });

    </script>
</html>


For more details about C# interview question you can use below site.

References
 | pdf js library



Tag | convert html page to pdf using jquery,convert webpage to pdf using javascript,export html page to pdf on user click using javascript,javascript convert html to pdf source code,convert html to pdf using jquery example,generate pdf using jquery,jspdf html to pdf,export div content to pdf using javascript


Want to Learn C#.net interview questions and answers visit below link.
convert html to pdf using javascript Reviewed by Vikas Kumar Singh on April 05, 2018 Rating: 5

28 comments:

  1. itest this code but image is not exported in pdf.
    Can you help me for export image in pdf.

    ReplyDelete
  2. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    big data training in chennai

    ReplyDelete
  3. Your article has very unique and reliable information on new topic so i am really impress with your post.
    Thirsty Crow Short Story

    ReplyDelete
  4. I am really enjoying reading your well written articles.
    It looks like you spend a lot of effort and time on your blog.
    I have bookmarked it and I am looking forward to reading new articles. Keep up the good work..
    Best IELTS Coaching in Chennai
    IELTS Coaching Center in Chennai
    IELTS Coaching Center in Mumbai
    Best IELTS Coaching Centers in Chennai
    IELTS Classes in Chennai

    ReplyDelete
  5. Appreciate Your Work... Thanks for Sharing Useful Information on ---... I Just want to Share Some information related to Hadoop Training in Chennai hope it is useful for the Community Here.
    Hadoop Course in Chennai
    best big data training in chennai
    Big Data Hadoop Training
    Hadoop training institutes in chennai
    hadoop big data training in chennai

    ReplyDelete
  6. Amazing information,thank you for your ideas.after along time i have studied
    an interesting informations.we need updation in your blog.
    Java Training Institutes in Bangalore
    Java Courses in Chennai Anna Nagar
    Java Training in Vadapalani
    Java Training in Perungudi

    ReplyDelete
  7. Such an excellent and interesting blog, do post like this more with more information, this was very useful, Thank you.
    airport ground staff training courses in chennai
    airport ground staff training in chennai
    ground staff training in chennai

    ReplyDelete
  8. There are lots of information about latest technology and how to get trained in them, like Hadoop Training in Chennai have spread around the web, but this is a unique one according to me.

    Big Data Hadoop Training In Chennai | Big Data Hadoop Training In anna nagar | Big Data Hadoop Training In omr | Big Data Hadoop Training In porur | Big Data Hadoop Training In tambaram | Big Data Hadoop Training In velachery

    ReplyDelete

All Rights Reserved by DotNetBasic.com © 2019

Contact Form

Name

Email *

Message *

© 2018 All rights reserved by DotNetBasic. Powered by Blogger.