Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to change default pdf page width and font size in jspdf.debug.js?

I need to change default pdf page width and font size in jspdf.debug.js.

Where and how to change the default values in jspdf.debug.js?

like image 800
user3428816 Avatar asked Apr 16 '14 08:04

user3428816


People also ask

What is unit jsPDF?

orientation - The default value of orientation is "portrait". We can set it to "landscape" if we want a different page orientation. unit - We can tell jsPDF in which units we want to work. Use on of the following: "pt" (points), "mm" (default), "cm", "in".


2 Answers

Besides using one of the default formats you can specify any size you want in the unit you specify.

For example:

// Document of 210mm wide and 297mm high new jsPDF('p', 'mm', [297, 210]); // Document of 297mm wide and 210mm high new jsPDF('l', 'mm', [297, 210]); // Document of 5 inch width and 3 inch high new jsPDF('l', 'in', [3, 5]); 

The 3rd parameter of the constructor can take an array of the dimensions. However they do not correspond to width and height, instead they are long side and short side (or flipped around).

Your 1st parameter (landscape or portrait) determines what becomes the width and the height.

In the sourcecode on GitHub you can see the supported units (relative proportions to pt), and you can also see the default page formats (with their sizes in pt).

like image 154
Aidiakapi Avatar answered Sep 22 '22 03:09

Aidiakapi


From the documentation page

To set the page type pass the value in constructor

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"

format One of 'a3', 'a4' (Default),'a5' ,'letter' ,'legal'

To set font size

setFontSize(size)

Sets font size for upcoming text elements.

Parameters:

{Number} size Font size in points.

like image 23
Ramesh Avatar answered Sep 24 '22 03:09

Ramesh