79390718

Date: 2025-01-27 12:28:46
Score: 5.5
Natty:
Report link

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

Reasons:
  • RegEx Blacklisted phrase (3): can somebody help
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): I am facing the same issue
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Avni Goyal