Skip to content

Commit be5457e

Browse files
committed
allow a object to be passed as first argument to extend internal options, such as line-width/height
1 parent 27f9e31 commit be5457e

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

jspdf.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,16 @@ PubSub implementation
326326
@private
327327
*/
328328
function jsPDF(orientation, unit, format, compressPdf) { /** String orientation, String unit, String format, Boolean compressed */
329+
var options = {};
330+
331+
if (typeof orientation === 'object') {
332+
options = orientation;
333+
334+
orientation = options.orientation;
335+
unit = options.unit;
336+
format = options.format;
337+
compressPdf = options.compress || options.compressPdf;
338+
}
329339

330340
// Default parameter values
331341
if (typeof orientation === 'undefined') {
@@ -389,14 +399,14 @@ PubSub implementation
389399
page = 0,
390400
pages = [],
391401
objectNumber = 2, // 'n' Current object number
392-
outToPages = false, // switches where out() prints. outToPages true = push to pages obj. outToPages false = doc builder content
402+
outToPages = !!options.outToPages, // switches where out() prints. outToPages true = push to pages obj. outToPages false = doc builder content
393403
offsets = [], // List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.
394404
fonts = {}, // collection of font objects, where key is fontKey - a dynamically created label for a given font.
395405
fontmap = {}, // mapping structure fontName > fontStyle > font key - performance layer. See addFont()
396406
activeFontSize = 16,
397407
activeFontKey, // will be string representing the KEY of the font as combination of fontName + fontStyle
398-
lineWidth = 0.200025, // 2mm
399-
lineHeightProportion = 1.15,
408+
lineWidth = options.lineWidth || 0.200025, // 2mm
409+
lineHeightProportion = options.lineHeight || 1.15,
400410
pageHeight,
401411
pageWidth,
402412
k, // Scale factor

0 commit comments

Comments
 (0)