How to generate customize table pdf using jspdf

Viewed 360

I am working on react with jsPDF, to export a table of data to pdf in my react application. In my component, I am showing 7 columns of data plus one action column which has action buttons.

I have a download report button on top, now I am trying to export the table using jsPdf. while exporting pdf I want to remove the action column and wanted to add an image column at last(or replace action with image) and add specific data's image

I am showing the table below, enter image description here

When I export a pdf it is coming like the below, I wanted to rename the last column and add the specific data's image on each row enter image description here

I have tried like below, not able to replace it.

downloadRecords = async (id: string) => {
    const { type } = this.props;
    const doc = new jsPDF({
        orientation: "landscape"
      }
    )
    const title = `${type}`;
    
    doc.text(title, 14, 10)
    autoTable(doc, {
      html: '#mytable',
      bodyStyles:{minCellHeight: 20},
      startY: 20
    })
    doc.save(`${id}.pdf`)
  }

Can someone please suggest how can I replace the last column and add an image for that,

Thanks in advance.

0 Answers
Related