https://github.com/MrRio/jsPDF
英文文档 https://parall.ax/products/jspdf
yarn add jspdf jspdf-autotable
jspdf-autotable表格自适应
import jsPDF from 'jspdf'
import 'jspdf-autotable'
const doc = new jsPDF()
// It can parse html:
// <table id="my-table"><!-- ... --></table>
doc.autoTable({ html: '#my-table' })
// Or use javascript directly:
doc.autoTable({
head: [['Name', 'Email', 'Country']],
body: [
['David', 'david@example.com', 'Sweden'],
['Castille', 'castille@example.com', 'Spain'],
// ...
],
})
doc.save('table.pdf')