jsPDF-AutoTable is a widely-used plugin for the jsPDF library, enabling the generation of tabular data within PDF documents directly from JavaScript. It supports parsing existing HTML tables or constructing tables programmatically using JavaScript arrays for header, body, and footer content. The current stable version is 5.0.7, with active development indicated by frequent releases addressing bug fixes, dependency updates, and feature enhancements. Key differentiators include its tight integration with jsPDF, flexibility in content sources (HTML or raw data), and comprehensive styling options, making it a robust solution for dynamically generating structured reports and documents. It provides fine-grained control over cell spanning, styling, and column definitions, and ships with TypeScript types for improved developer experience.
npm install jspdf-autotableVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates generating PDF tables using `jspdf-autotable` with both the direct `autoTable` function call and the `doc.autoTable()` method (enabled after applying the plugin). It includes basic data-driven table generation, a more complex example with merged cells and custom styling, and adds a page number footer to each page.
Ensure you `import { applyPlugin } from 'jspdf-autotable'` and call `applyPlugin(jsPDF)` after importing jsPDF. Alternatively, use the direct function call: `autoTable(doc, { ... })` instead of the `doc.autoTable({ ... })` method.Review the v4.0.0 changelog and update any usage of removed options or styles to their current equivalents. For TypeScript users, update type references from `autoTable` to `autoTableInstanceType` if you were typing plugin instance methods. Be aware of the dropped IE support if targeting legacy browsers.
Remove any `/es` suffix from your import paths. For example, change `import { autoTable } from 'jspdf-autotable/es'` to `import { autoTable } from 'jspdf-autotable'`.Verify that your installed `jspdf` version falls within the required range. Use `npm list jspdf` to check your current version and update/downgrade `jspdf` with `npm install jspdf@^4` (or the appropriate version).
If using an ESM setup or in Node.js since v5, ensure you explicitly call `applyPlugin(jsPDF)` after importing jsPDF and `applyPlugin`. For example:
`import { jsPDF } from 'jspdf';
import { applyPlugin } from 'jspdf-autotable';
applyPlugin(jsPDF);
const doc = new jsPDF();
doc.autoTable({...});`
Alternatively, use the direct function call: `autoTable(doc, { ... });`Remove the `/es` suffix from your import path: `import { autoTable } from 'jspdf-autotable'`.Ensure `jspdf-autotable` is installed and `applyPlugin(jsPDF)` is called in your application's initialization logic. If the issue persists, verify your `tsconfig.json` correctly includes `jspdf` and `jspdf-autotable` in the `types` array or `typeRoots` (though usually installing the packages is sufficient for type discovery).
Refer to the `jspdf-autotable` documentation for v4.0.0+ options and styles. Update your table configuration to use the current properties, for instance, replacing `styles.columnWidth` with `columnStyles.<column_index_or_dataKey>.cellWidth`.