I am facing the same issue This my code-
import pdfMake from 'pdfmake/build/pdfmake';
import pdfFonts from 'pdfmake/build/vfs_fonts';
pdfMake.vfs = pdfFonts.pdfMake.vfs;
const handleDownload = async (option) => {
if (option === 'dashboard') {
const input = document.getElementById('dashboard');
if (!input) {
console.error('Element with ID dashboard not found.');
return;
}
html2canvas(input, { scale: 2 }).then((canvas) => {
const imgData = canvas.toDataURL('image/png');
const pdfContent = [
{
image: imgData,
width: 500, // Adjust the width based on your requirement
}
];
pdfMake.createPdf({ content: pdfContent }).download('dashboard.pdf');
}).catch((error) => {
console.error('Error generating PDF:', error);
});
} else if (option === 'everything') {
setIsDownloading(true);
const tabs = ['Dashboard', 'Overview', 'Milestone', 'Finance', 'Offtake', 'Interconnect', 'Land', 'Equipments', 'Construction', 'Operation'];
const pdfContent = [];
for (const tab of tabs) {
await captureTabContent(tab, pdfContent);
}
pdfMake.createPdf({ content: pdfContent }).download('everything.pdf');
setIsDownloading(false);
setActiveTab('Dashboard');
}
};
can somebody help