Jéssica
Jéssica

Reputation: 11

jsPDF exporting without css style



I have this code, that i use to export html to pdf and it's working but without css

<body>
    <div class="container">
        <div style="background-color: yellow" id="pagina">Page to Print</div>
        <div id="editor">
             <a href="#" class="btn btn-primary download-pdf">Download PDF</a>
        </div>
    </div>
 </body>
 <script type="text/javascript">

    var doc = new jsPDF();
    var specialElementHandlers = {
        '#editor': function(element, renderer){
            return true;
        }
    };
    doc.fromHTML($('body').get(0), 15, 15, {
        'width': 170, 
        'elementHandlers': specialElementHandlers
    });

        $('.download-pdf').click(function(){    
            doc.save('demo.pdf');
        });  

It's possible to export with css?

Upvotes: 0

Views: 4348

Answers (1)

Ilyas Foo
Ilyas Foo

Reputation: 134

According to jspdf's site, HTML renderer is in its early stages. I have also found in other posts css is not supported (yet), both inline and imported stylesheets.

I could suggest you an alternative, if you are willing to install 3rd party app in your server, you can check out a tutorial using phantomjs to generate pdf from html.

Upvotes: 2

Related Questions