locked
html to pdf conversion using javasccript RRS feed

  • Question

  • hi

     I tried to store the html content to pdf format.

    <html>
    <head>
    <script src="E:\ExcelServices\try2\jquery-1.11.3.min.js"></script>
    <script src="E:\ags\jspdf.min.js"></script>

    <script>
    var doc = new jsPDF();
    var specialElementHandlers = {
        '#editor': function (element, renderer) {
            return true;
        }
    };

    function generatepdf() {
        doc.fromHTML($('#tablen').html(), 15, 15, {
            'width': 170,
                'elementHandlers': specialElementHandlers
        });
        doc.save('sample-file.pdf');
    }</script>
    </head>
    <body>
    <div id="content">
         <h3>Hello, this is a H3 tag</h3>

        <p>a pararaph</p>
        <table id="tablen"><tr>
            <td>asffsd</td>
            </tr>
            <tr>
                <td>
                    <table>
                        <tr>
                            <td>
                                This s innertable
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <div id="editor"></div>
    <button id="cmd" onclick="generatepdf()">generate PDF</button>
    </body>
    </html>

    if i store as html and run it is working perfect.. but webform.aspx if i use this i am getting error in jspdf.js

    Pls help


    Janani.R

    Sunday, November 22, 2015 4:42 AM

Answers

  • Thanks for replying .. i found that the issue is in IE . until IE9 it is not working, IE10 its not saving with pdf extension. 

    Above IE10 it is working fine.

    Pls help


    Janani.R

    Monday, November 23, 2015 9:09 AM

All replies

  • Hi Jhanani Ravishankar,

    In your code above, you add some external JS files to your web page, if you want to use absolute path for the SRC, you’d better refer to the following thread to implement it. Before this, you should make sure the JS files are in your project.

    http://forums.asp.net/t/1511349.aspx?script+src+absolute+path+problem

    Besides, the following video tutorial you’d better have a look.

    http://www.asp.net/web-forms/videos/how-do-i/how-do-i-add-javascript-to-an-aspnet-page

    If you have any issues about web form development, you’d better post them in the following form for more support.

    http://forums.asp.net/

    Best Regards.

    Monday, November 23, 2015 5:31 AM
  • Thanks for replying .. i found that the issue is in IE . until IE9 it is not working, IE10 its not saving with pdf extension. 

    Above IE10 it is working fine.

    Pls help


    Janani.R

    Monday, November 23, 2015 9:09 AM