1.0.3 • Published 6 months ago

html2pdf-export-tool v1.0.3

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

html2pdf-export-tool

一个基于 html2canvas 和 jspdf 的 HTML 转 PDF 导出工具,支持 ESM 和 CommonJS 模块化引入。

安装

npm install html2pdf-export-tool

使用

// ESM 方式引入
import { HTMLToPDF } from 'html2pdf-export-tool';
// 或者使用默认导出
import getPDF from 'html2pdf-export-tool';

// CommonJS 方式引入
const { HTMLToPDF } = require('html2pdf-export-tool');
// 或者使用默认导出
const getPDF = require('html2pdf-export-tool').default;

// 使用示例
const element = document.querySelector('#content');
const options = {
  download: true,
  filename: 'example.pdf',
  format: 'a4'
};

// 使用类方法
HTMLToPDF.getPDF(element, options)
  .then(pdf => {
    console.log('PDF generated successfully');
  })
  .catch(error => {
    console.error('Error generating PDF:', error);
  });

// 或者使用默认导出的方法
getPDF(element, options)
  .then(pdf => {
    console.log('PDF generated successfully');
  })
  .catch(error => {
    console.error('Error generating PDF:', error);
  });
  
1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago