Search code examples
javascriptjspdfjspdf-autotable

How to position an image behind autotable in jspdf


I am trying to make my autotables to overlay the images in my document but the available options don't seem to work. I found a way to make it done like this:

doc.internal.events.subscribe('addPage', function() { doc.addImage(myImage, 'JPG', 5, 265, 20, 30); });

But this solution would only apply from the second page ahead. I would like it to work also in the initial page. Is it fine to use this solution? How could I get it to work also in the first page?

Thanks.


Solution

  • I kept digging and I found out that in jsPDF the elements are rendered on top of the previous one, so I just added the image in the beginning of the code specifying the coordinates in the bottom of the page where I wanted it and it worked. Having that information it is easy to position the elements similar as to z-index does.

    I hope this is useful to someone else. Thanks!