Click here to Skip to main content
15,390,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have a situation,in which i have to convert element of a repeter into pdf. so i am using jsPDF plugin. first i am trying to convert the element of a div,but it is not working please help to overcome from this.

my script is
<script src="jquery-1.7.1.min.js"></script>
    <script src="jspdf.js"></script>
    <script src="jspdf.plugin.standard_fonts_metrics.js"></script>
    <script src="jspdf.plugin.split_text_to_size.js"></script>
    <script src="jspdf.plugin.from_html.js"></script>

        $(document).ready(function () {
            $(function () {
                var doc = new jsPDF();
                var specialElementHandlers = {
                    '#editor': function (element, renderer) {
                        return true;

                $('#cmd').click(function () {
                    doc.fromHTML($('#content').html(), 15, 15, {
                        'width': 170,
                        'elementHandlers': specialElementHandlers

and HTMl div is ;
    <form id="form1" runat="server">
        <div id="content">
            <h3>Hello, this is a H3 tag</h3>
            <p>a pararaph</p>
        <div id="editor"></div>
        <button id="cmd">generate PDF</button>

1 solution

Hello Amit,
This problem an be solved by adding htm2canvas.js and addhtml.js along with jspdf.js.
You dont need any other js for that.
If you still have problems I'll come up with example code.
Member 10416382 3-Apr-17 5:55am

i have problem with Hindi fonts in my html div content. when i am using window.print() viwer i am getting hindi fonts.when i am using above code not able get hindi fonts can you please help me.

Hitesh Rohilla 27-Jul-18 2:19am
Dear @Seenivasagan.vrp Please share the addhtml.js link as I am unable to find this library.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900