How to import and access JS libraries like jsPDF and jsPDF-autotable

Hmm thanx @AnsonHwang

I have another query. Can u please ans to it ?

I am use jsPDF and jsPDF-autotable libraries in retool How can I use them ?

It is not allowing me to import them where I am using these.

also If I import them in libraries, then they are not accessible

You should try custom component.

It does not work, any working example ?
Did u ever try your own ?

Hello, I write a demo for you, just paste it to iframe.
Don't forget allow download

But it seem it can't support doc.output in custom component, so I commented out this code in the code.

Here is code


<script crossorigin src=""></script>
<script crossorigin src=""></script>

<table class="table pure-table" id="basic-table" style="display: block;">
        <th colspan="2">Name</th>
    <tr style="background: rgb(155, 89, 182); color: white;">
        <td>United States</td>

<embed  id="output"  type="application/pdf" style="width:500px;height:800px;"/>

		const doc = new window.jspdf.jsPDF();

  // From HTML
  doc.autoTable({ html: '.table' })

  // From Javascript
  var finalY = doc.lastAutoTable.finalY || 10
  doc.text('From javascript arrays', 14, finalY + 15)
    startY: finalY + 20,
    head: [['ID', 'Name', 'Email', 'Country', 'IP-address']],
    body: [
      ['1', 'Donna', '', 'China', ''],
      ['2', 'Janice', '', 'Ukraine', ''],
        'Trinidad and Tobago',
      ['4', 'Jason', '', 'Brazil', ''],
      ['5', 'Jane', '', 'United States', ''],
      ['6', 'Adam', '', 'Canada', ''],

  finalY = doc.lastAutoTable.finalY
  doc.text('From HTML with CSS', 14, finalY + 15)
    startY: finalY + 20,
    html: '.table',
    useCss: true,

 // document.getElementById("output").src = doc.output('datauri');"ss.pdf");




In my local chrome, I can use doc.output('datauri'); to get the base64 string and append it to src of embed tag.

Hope help.

1 Like