Search code examples
javascriptreactjspdfjspdfjspdf-autotable

How to solve jspdf name conflict


I'm using different jsPDF libraries in my react app like below:

For table HTML exports:

import jsPDF from 'jspdf';
import "jspdf-autotable";

For SVG to PDF exports:

const svg2pdf = require('svg2pdf.js');
const jsPDF = require('jspdf-yworks');

Both jsPDF and jspdf-yworks use the same name for creating jsPDF object like;

const doc = new jsPDF('l', 'pt', [width, height]);

Is there any solution for the name conflict?

Thanks


Solution

  • You can change the default import name e.g import {default as jsPDFautotable} from 'jspdf'