Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jspdf-autotable

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jspdf-autotable

Generate pdf tables with javascript (jsPDF plugin)

  • 3.8.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is jspdf-autotable?

jspdf-autotable is an npm package that allows you to create tables in PDF documents using jsPDF. It provides a simple API to generate tables with various customization options, including styling, headers, footers, and more.

What are jspdf-autotable's main functionalities?

Basic Table

This feature allows you to create a basic table with headers and rows. The `head` property defines the table headers, and the `body` property defines the table rows.

const { jsPDF } = require('jspdf');
require('jspdf-autotable');

const doc = new jsPDF();

doc.autoTable({
  head: [['Name', 'Email', 'Country']],
  body: [
    ['John Doe', 'john@example.com', 'USA'],
    ['Jane Doe', 'jane@example.com', 'Canada'],
  ],
});

doc.save('table.pdf');

Custom Styling

This feature allows you to apply custom styling to the table, including the table body, headers, and alternate rows. The `styles`, `headStyles`, and `alternateRowStyles` properties are used to define the styles.

const { jsPDF } = require('jspdf');
require('jspdf-autotable');

const doc = new jsPDF();

doc.autoTable({
  head: [['Name', 'Email', 'Country']],
  body: [
    ['John Doe', 'john@example.com', 'USA'],
    ['Jane Doe', 'jane@example.com', 'Canada'],
  ],
  styles: { fillColor: [255, 0, 0] },
  headStyles: { fillColor: [0, 255, 0] },
  alternateRowStyles: { fillColor: [255, 255, 0] },
});

doc.save('styled_table.pdf');

Column and Row Spanning

This feature allows you to create tables with cells that span multiple columns or rows. The `colSpan` and `rowSpan` properties are used to define the spanning.

const { jsPDF } = require('jspdf');
require('jspdf-autotable');

const doc = new jsPDF();

doc.autoTable({
  head: [['Name', 'Email', 'Country']],
  body: [
    [{ content: 'John Doe', colSpan: 2 }, 'USA'],
    ['Jane Doe', { content: 'jane@example.com', rowSpan: 2 }, 'Canada'],
    ['Another Jane', ''],
  ],
});

doc.save('spanning_table.pdf');

Other packages similar to jspdf-autotable

Keywords

FAQs

Package last updated on 15 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc