Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a jspdf autotable landscape?

The table plugin JsPDF-AutoTable: https://github.com/simonbengtsson/jsPDF-AutoTable how do I make the page landscape as oppose to portrait? In the documentation it just says "Only pt supported (not mm or in)". I don't understand how to make the page landscape; landscape makes sense for a lot of tables....

like image 948
user1190132 Avatar asked Jul 14 '18 13:07

user1190132


People also ask

What is jsPDF Autotable?

The jsPDF AutoTables plugin is for converting a table to a PDF. This is a dependable client-side library to generate reports online in a table format.

What is format in jsPDF?

jsPDF(orientation, unit, format) Creates new jsPDF document object. instance Parameters: orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l") unit Measurement unit to be used when coordinates are specified. One of "pt" (points), "mm" (Default), "cm", "in"


2 Answers

Ok the answer is: var doc = new jsPDF('landscape');

It would be helpful if this was in the documentation.

like image 151
user1190132 Avatar answered Oct 21 '22 11:10

user1190132


I have done it initializing jsPDF instance like this:

var doc = new jsPDF('l', 'pt');

Here, l means Landscape format. For portrait, p can be used.

like image 44
ni8mr Avatar answered Oct 21 '22 12:10

ni8mr