-3

I want to convert image to pdf or print preview which is fetched from database in jquery datatable.

Suppose, I have fetched records from database in a jquery datatable by ajax call and have images in every row. Now, I want to export it in pdf or want to show in print preview, those data are fetched with images in every row.

1 Answers1

0

I found this answer https://stackoverflow.com/a/42486892/6631280

use jsPDF.js plug-in Fiddle Demo

<div id="content"><img src="imageURL" ></div>
var options = {}
var pdf = new jsPDF('p', 'pt', 'a4');
pdf.addHTML($("#content"), 15, 15, options, function() {
    pdf.save('pageContent.pdf');
});

If your image take time to load then I suggest use some delay before generate PDF

Ravi Makwana
  • 2,782
  • 1
  • 29
  • 41
  • Suppose, I have fetched records from database in a jquery datatable by ajax call and have images in every row. Now, I want to export it in pdf or want to show in print preview, those data are fetched with images in every row. – pratick chakraborty Oct 05 '19 at 09:02
  • add button on page to print and it's will generate PDF of everything in target div – Ravi Makwana Oct 06 '19 at 10:36
  • I did it already, but my actual point is, those pictures are show in datatable, after click print button from jquery datatable, pictures are not shown in print preview. – pratick chakraborty Oct 06 '19 at 12:10