Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a PDF from a HTML page in landscape format

I need to make a PDF in landscape format.

<script type="text/javascript">
    $(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
            });
            doc.save('sample-file.pdf');
        });
    });
</script>
like image 377
L.S Avatar asked Oct 15 '25 14:10

L.S


1 Answers

I found it out. It is so simple :) The first Param is for landscape in jsPDF() which is l for landscape.

var pdf = new jsPDF('l', 'mm', [297, 210]); //The first Param is for landscape or portrait

like image 130
L.S Avatar answered Oct 17 '25 05:10

L.S