Use image as page background
Is it possible to use an image as the background for a page and then overlay the autoTable? I can overlay images using just jsPDF, but can't figure it out with AutoTable. What I've tried so far is to addImage the full page size in the pageContent. The image lays overtop of the table so I can't see the tables.
I kind of figured this out, so you can delete if you want. I was able to subscribe to the addPage event. Not sure how to unsubscribe! In case this helps.
doc.internal.events.subscribe('addPage', function() {
pageSize = view.doc.internal.pageSize;
doc.addImage(myimage, 'JPG', 0, 0, pageSize.width, pageSize.height);
});
Innovative solution! And as soon as the document is finished rendered you automatically unsubscribe in jspdf so you don't need to worry about that 👍
What if you want the solution to work also in the first page? This workaround applies after the doc.addPage is in the code and I was looking to also apply to the initial page. Thanks!
What if you want the solution to work also in the first page? This workaround applies after the doc.addPage is in the code and I was looking to also apply to the initial page. Thanks!
I solved this by removing and re-adding the first page after the subscribe:
doc.deletePage(1)
doc.addPage()
Probably a bit hacky but at least it works.
I kind of figured this out, so you can delete if you want. I was able to subscribe to the addPage event. Not sure how to unsubscribe! In case this helps.
doc.internal.events.subscribe('addPage', function() { pageSize = view.doc.internal.pageSize; doc.addImage(myimage, 'JPG', 0, 0, pageSize.width, pageSize.height); });
Thank you