Fix jsPDF Constructor (#36806)

* Added test for the custom size constructor

* Fix jsPDF Constructor

According to the official jsPDF GitHub: the 3rd parameter in the constructor should be of type String OR Array to allow a custom size.
2f51a5dc2a/src/jspdf.js (L84)

* Added myself to the "Definitions by" section
This commit is contained in:
Leon Montealegre 2019-07-11 19:02:43 -04:00 committed by Armando Aguirre
parent 5440457ff3
commit 5aa0f90d72
2 changed files with 11 additions and 1 deletions

View File

@ -4,13 +4,14 @@
// Kevin Gonnord <https://github.com/lleios>
// Jackie Weng <https://github.com/jemerald>
// Frank Brullo <https://github.com/frankbrullo>
// Leon Montealegre <https://github.com/leonmontealegre>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'jspdf' {
class jsPDF {
constructor(orientation?:any,
unit?:string,
format?:string,
format?:string|Array<Number>,
compressPdf?:number);
CapJoinStyles:any;

View File

@ -121,6 +121,15 @@ function test_font_metrics_based_line_sizing_split() {
pdf.save('Test.pdf');
}
function test_simple_custom_size_document() {
var doc = new jsPDF('l', 'px', [500, 200]);
doc.text(20, 20, 'Hello world!');
doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
doc.addPage();
doc.text(20, 20, 'Do you like that?');
doc.save('Test.pdf');
}
function test_from_html() {
var pdf = new jsPDF('p', 'pt', 'letter')
, source = document.getElementById('#fromHTMLtestdiv')