Export PDF with images?
Export PDF with images?
yet
Posts: 43Questions: 17Answers: 1
We have a DT column containing images and logos (using <img> tag).
Is it possible to include these images and logos as part of the PDF export? Or even as part of the "print" export?
This discussion has been closed.
Answers
This example shows how you can do images in the pdf. It is not trivial I'm afraid, the pdfmake library that is used to provide the pdf export doesn't make it particularly easy. If you are using images in the table it is even harder since you need to provide each as a base64 encoded image to the pdf generator.
For print, use the
stripHtml
option of theprint
button export options. By default it is set to strip the HTML tags, soimg
elements would be removed.Allan
@allan In the same situation, how would you display the image at the end of the PDF? How would the doc.content.splice change ? Thanks for such a great library!
@Venky1995 I'm not sure its exactly the same as the OP is asking about images in each row.
Let's take a look. Here is an example:
http://live.datatables.net/jatobaqi/1/edit
It has 3 PDF buttons; one with no changes, one using this example and one placing the image at the bottom of the document. It is also using
console.log(doc.content)
for each button so you can see the differences. Looks likedoc.content
is an array of objects. The 2nd and 3rd buttons manipulate the array to place the image where desired.Kevin