Skip to content

Commit 0eda50b

Browse files
5.0.0
1 parent 90eb6b7 commit 0eda50b

File tree

6 files changed

+77
-98
lines changed

6 files changed

+77
-98
lines changed

dist/index.d.ts

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,5 @@
11
// Generated by dts-bundle-generator v9.5.1
22

3-
export type jsPDFConstructor = any;
4-
export type jsPDFDocument = any;
5-
export type Opts = {
6-
[key: string]: string | number;
7-
};
8-
declare class DocHandler {
9-
private readonly jsPDFDocument;
10-
readonly userStyles: Partial<Styles>;
11-
constructor(jsPDFDocument: jsPDFDocument);
12-
static setDefaults(defaults: UserOptions, doc?: jsPDFDocument | null): void;
13-
private static unifyColor;
14-
applyStyles(styles: Partial<Styles>, fontOnly?: boolean): void;
15-
splitTextToSize(text: string | string[], size: number, opts: Opts): string[];
16-
/**
17-
* Adds a rectangle to the PDF
18-
* @param x Coordinate (in units declared at inception of PDF document) against left edge of the page
19-
* @param y Coordinate (in units declared at inception of PDF document) against upper edge of the page
20-
* @param width Width (in units declared at inception of PDF document)
21-
* @param height Height (in units declared at inception of PDF document)
22-
* @param fillStyle A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke.
23-
*/
24-
rect(x: number, y: number, width: number, height: number, fillStyle: "S" | "F" | "DF" | "FD"): any;
25-
getLastAutoTable(): Table | null;
26-
getTextWidth(text: string | string[]): number;
27-
getDocument(): any;
28-
setPage(page: number): void;
29-
addPage(): any;
30-
getFontList(): {
31-
[key: string]: string[] | undefined;
32-
};
33-
getGlobalOptions(): UserOptions;
34-
getDocumentOptions(): UserOptions;
35-
pageSize(): {
36-
width: number;
37-
height: number;
38-
};
39-
scaleFactor(): number;
40-
getLineHeightFactor(): number;
41-
getLineHeight(fontSize: number): number;
42-
pageNumber(): number;
43-
}
443
export type MarginPadding = {
454
top: number;
465
right: number;
@@ -313,8 +272,49 @@ export type CellInput = null | string | string[] | number | boolean | CellDef;
313272
export type RowInput = {
314273
[key: string]: CellInput;
315274
} | HtmlRowInput | CellInput[];
316-
export type autoTableInstanceType = (options: UserOptions) => void;
275+
export type jsPDFConstructor = any;
276+
export type jsPDFDocument = any;
277+
export type Opts = {
278+
[key: string]: string | number;
279+
};
280+
declare class DocHandler {
281+
private readonly jsPDFDocument;
282+
readonly userStyles: Partial<Styles>;
283+
constructor(jsPDFDocument: jsPDFDocument);
284+
static setDefaults(defaults: UserOptions, doc?: jsPDFDocument | null): void;
285+
private static unifyColor;
286+
applyStyles(styles: Partial<Styles>, fontOnly?: boolean): void;
287+
splitTextToSize(text: string | string[], size: number, opts: Opts): string[];
288+
/**
289+
* Adds a rectangle to the PDF
290+
* @param x Coordinate (in units declared at inception of PDF document) against left edge of the page
291+
* @param y Coordinate (in units declared at inception of PDF document) against upper edge of the page
292+
* @param width Width (in units declared at inception of PDF document)
293+
* @param height Height (in units declared at inception of PDF document)
294+
* @param fillStyle A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke.
295+
*/
296+
rect(x: number, y: number, width: number, height: number, fillStyle: "S" | "F" | "DF" | "FD"): any;
297+
getLastAutoTable(): Table | null;
298+
getTextWidth(text: string | string[]): number;
299+
getDocument(): any;
300+
setPage(page: number): void;
301+
addPage(): any;
302+
getFontList(): {
303+
[key: string]: string[] | undefined;
304+
};
305+
getGlobalOptions(): UserOptions;
306+
getDocumentOptions(): UserOptions;
307+
pageSize(): {
308+
width: number;
309+
height: number;
310+
};
311+
scaleFactor(): number;
312+
getLineHeightFactor(): number;
313+
getLineHeight(fontSize: number): number;
314+
pageNumber(): number;
315+
}
317316
export declare function applyPlugin(jsPDF: jsPDFConstructor): void;
317+
export type autoTableInstanceType = (options: UserOptions) => void;
318318
export declare function autoTable(d: jsPDFDocument, options: UserOptions): void;
319319
export declare function __createTable(d: jsPDFDocument, options: UserOptions): Table;
320320
export declare function __drawTable(d: jsPDFDocument, table: Table): void;

dist/jspdf.plugin.autotable.js

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
*
3-
* jsPDF AutoTable plugin v4.0.0
3+
* jsPDF AutoTable plugin v5.0.0
44
*
55
* Copyright (c) 2025 Simon Bengtsson, https://github.com/simonbengtsson/jsPDF-AutoTable
66
* Licensed under the MIT License.
@@ -9,14 +9,14 @@
99
*/
1010
(function webpackUniversalModuleDefinition(root, factory) {
1111
if(typeof exports === 'object' && typeof module === 'object')
12-
module.exports = factory((function webpackLoadOptionalExternalModule() { try { return require("jspdf"); } catch(e) {} }()));
12+
module.exports = factory();
1313
else if(typeof define === 'function' && define.amd)
14-
define(["jspdf"], factory);
14+
define([], factory);
1515
else {
16-
var a = typeof exports === 'object' ? factory((function webpackLoadOptionalExternalModule() { try { return require("jspdf"); } catch(e) {} }())) : factory(root["jspdf"]);
16+
var a = factory();
1717
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
1818
}
19-
})(typeof globalThis !== 'undefined' ? globalThis : typeof this !== 'undefined' ? this : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : global , function(__WEBPACK_EXTERNAL_MODULE__396__) {
19+
})(typeof globalThis !== 'undefined' ? globalThis : typeof this !== 'undefined' ? this : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : global , function() {
2020
return /******/ (function() { // webpackBootstrap
2121
/******/ "use strict";
2222
/******/ var __webpack_modules__ = ({
@@ -899,15 +899,6 @@ function cellStyles(sectionName, column, rowIndex, themeName, styles, scaleFacto
899899
}
900900

901901

902-
/***/ }),
903-
904-
/***/ 396:
905-
/***/ (function(module) {
906-
907-
if(typeof __WEBPACK_EXTERNAL_MODULE__396__ === 'undefined') { var e = new Error("Cannot find module 'undefined'"); e.code = 'MODULE_NOT_FOUND'; throw e; }
908-
909-
module.exports = __WEBPACK_EXTERNAL_MODULE__396__;
910-
911902
/***/ }),
912903

913904
/***/ 460:
@@ -1417,14 +1408,14 @@ function calculateAllColumnsCanFitInPage(doc, table) {
14171408

14181409

14191410
Object.defineProperty(exports, "__esModule", ({ value: true }));
1420-
exports["default"] = default_1;
1411+
exports.applyPlugin = applyPlugin;
14211412
var autoTableText_1 = __webpack_require__(150);
14221413
var documentHandler_1 = __webpack_require__(643);
14231414
var htmlParser_1 = __webpack_require__(660);
14241415
var inputParser_1 = __webpack_require__(371);
14251416
var tableCalculator_1 = __webpack_require__(376);
14261417
var tableDrawer_1 = __webpack_require__(789);
1427-
function default_1(jsPDF) {
1418+
function applyPlugin(jsPDF) {
14281419
// eslint-disable-next-line @typescript-eslint/no-explicit-any
14291420
jsPDF.API.autoTable = function () {
14301421
var args = [];
@@ -2299,13 +2290,14 @@ var __webpack_exports__ = {};
22992290
!function() {
23002291
var exports = __webpack_exports__;
23012292

2293+
var _a;
23022294
Object.defineProperty(exports, "__esModule", ({ value: true }));
2303-
exports.Table = exports.Row = exports.Column = exports.CellHookData = exports.Cell = void 0;
2304-
exports.applyPlugin = applyPlugin;
2295+
exports.Table = exports.Row = exports.Column = exports.CellHookData = exports.Cell = exports.applyPlugin = void 0;
23052296
exports.autoTable = autoTable;
23062297
exports.__createTable = __createTable;
23072298
exports.__drawTable = __drawTable;
23082299
var applyPlugin_1 = __webpack_require__(639);
2300+
Object.defineProperty(exports, "applyPlugin", ({ enumerable: true, get: function () { return applyPlugin_1.applyPlugin; } }));
23092301
var HookData_1 = __webpack_require__(601);
23102302
Object.defineProperty(exports, "CellHookData", ({ enumerable: true, get: function () { return HookData_1.CellHookData; } }));
23112303
var inputParser_1 = __webpack_require__(371);
@@ -2316,11 +2308,6 @@ Object.defineProperty(exports, "Row", ({ enumerable: true, get: function () { re
23162308
Object.defineProperty(exports, "Table", ({ enumerable: true, get: function () { return models_1.Table; } }));
23172309
var tableCalculator_1 = __webpack_require__(376);
23182310
var tableDrawer_1 = __webpack_require__(789);
2319-
// export { applyPlugin } didn't export applyPlugin
2320-
// to index.d.ts for some reason
2321-
function applyPlugin(jsPDF) {
2322-
(0, applyPlugin_1.default)(jsPDF);
2323-
}
23242311
function autoTable(d, options) {
23252312
var input = (0, inputParser_1.parseInput)(d, options);
23262313
var table = (0, tableCalculator_1.createTable)(d, input);
@@ -2335,19 +2322,17 @@ function __drawTable(d, table) {
23352322
(0, tableDrawer_1.drawTable)(d, table);
23362323
}
23372324
try {
2338-
// eslint-disable-next-line @typescript-eslint/no-require-imports
2339-
var jsPDF = __webpack_require__(396);
2340-
// Webpack imported jspdf instead of jsPDF for some reason
2341-
// while it seemed to work everywhere else.
2342-
if (jsPDF.jsPDF)
2343-
jsPDF = jsPDF.jsPDF;
2344-
applyPlugin(jsPDF);
2345-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2325+
if (typeof window !== 'undefined' && window) {
2326+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2327+
var anyWindow = window;
2328+
var jsPDF = anyWindow.jsPDF || ((_a = anyWindow.jspdf) === null || _a === void 0 ? void 0 : _a.jsPDF);
2329+
if (jsPDF) {
2330+
(0, applyPlugin_1.applyPlugin)(jsPDF);
2331+
}
2332+
}
23462333
}
23472334
catch (error) {
2348-
// Importing jspdf in nodejs environments does not work as of jspdf
2349-
// 1.5.3 so we need to silence potential errors to support using for example
2350-
// the nodejs jspdf dist files with the exported applyPlugin
2335+
console.error('Could not apply autoTable plugin', error);
23512336
}
23522337
exports["default"] = autoTable;
23532338

dist/jspdf.plugin.autotable.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.plugin.autotable.mjs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@ function nextPage(doc) {
20112011
return false;
20122012
}
20132013

2014-
function _applyPlugin (jsPDF) {
2014+
function applyPlugin(jsPDF) {
20152015
// eslint-disable-next-line @typescript-eslint/no-explicit-any
20162016
jsPDF.API.autoTable = function () {
20172017
var args = [];
@@ -2050,11 +2050,7 @@ function _applyPlugin (jsPDF) {
20502050
};
20512051
}
20522052

2053-
// export { applyPlugin } didn't export applyPlugin
2054-
// to index.d.ts for some reason
2055-
function applyPlugin(jsPDF) {
2056-
_applyPlugin(jsPDF);
2057-
}
2053+
var _a;
20582054
function autoTable(d, options) {
20592055
var input = parseInput(d, options);
20602056
var table = createTable(d, input);
@@ -2069,19 +2065,17 @@ function __drawTable(d, table) {
20692065
drawTable(d, table);
20702066
}
20712067
try {
2072-
// eslint-disable-next-line @typescript-eslint/no-require-imports
2073-
var jsPDF = require('jspdf');
2074-
// Webpack imported jspdf instead of jsPDF for some reason
2075-
// while it seemed to work everywhere else.
2076-
if (jsPDF.jsPDF)
2077-
jsPDF = jsPDF.jsPDF;
2078-
applyPlugin(jsPDF);
2079-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2068+
if (typeof window !== 'undefined' && window) {
2069+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2070+
var anyWindow = window;
2071+
var jsPDF = anyWindow.jsPDF || ((_a = anyWindow.jspdf) === null || _a === void 0 ? void 0 : _a.jsPDF);
2072+
if (jsPDF) {
2073+
applyPlugin(jsPDF);
2074+
}
2075+
}
20802076
}
20812077
catch (error) {
2082-
// Importing jspdf in nodejs environments does not work as of jspdf
2083-
// 1.5.3 so we need to silence potential errors to support using for example
2084-
// the nodejs jspdf dist files with the exported applyPlugin
2078+
console.error('Could not apply autoTable plugin', error);
20852079
}
20862080

20872081
export { Cell, CellHookData, Column, Row, Table, __createTable, __drawTable, applyPlugin, autoTable, autoTable as default };

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspdf-autotable",
3-
"version": "4.0.0",
3+
"version": "5.0.0",
44
"description": "Generate pdf tables with javascript (jsPDF plugin)",
55
"main": "dist/jspdf.plugin.autotable.js",
66
"exports": {

0 commit comments

Comments
 (0)