Ability to print / PDF images displayed in DataTables?
Ability to print / PDF images displayed in DataTables?
Hello,
I did a quick scan to see if this question was covered already, but it doesn't appear to be.
I am displaying some images on my DataTable, but when I go to print / PDF the table, my column with <img src="$image_path"> is blank. Of course, I can use CSS to format the print function in the browser to do about the same thing, but I'd like to see if I can utilize the DataTables buttons, especially the PDF button, to display the image as shown in the table renderings on the browser.
Similarly, I will need a way to put in the image path value for the Excel / CSV export features since they cannot support images.
Thank you,
Mike
Answers
Hi Mike,
Its has indeed come up a few times before - see this thread for example.
In short, it is possible using the options for the print view (just have it not strip the HTML, which it does by default), and it is probably possible for the PDF, but it would be a hack of a lot of work.
Allan
You might be able to use wkhtmltopdf and a custom button. It creates a pdf from html. I think I plan on creating a 'report' page which strips my page's header. But using it requires installing wkhtmltopdf on the server and allowing it, a command line interface, access to a custom view url of the page.
You might even be able to just send the html directly to it, I'm not sure as I haven't used it a whole lot yet.
I know I have no desire to use the print functionality in browsers, so wkhtmltopdf was my alternative.
How do you do it for your clients? Do you generate the PDF server-side and then have them download that?
Allan
So far I haven't generated the report html but tested it on my site and it generates a perfectly rendered image. I run an internal website, so no clients per say. But yes I am going to generate the PDF server-side and then yes have them download that. I have too much trouble with the variance in browser printers.
All in all, it seems like using wkhtmltopdf will still require writing a 'report' similar to writing print css but hopefully less work and avoid the web browser printer. We'll see.
wkhtmltopdf is what I use to generate the invoices from this site when they are e-mailed out to customers (such as yourself ). The new versions in particular are fantastic!
Allan
Here I am, a year later, no less, searching for how to print images without having the server browse to the report, and just generating it client side.
As an update to this thread, instead of wkhtmltopdf I am using chrome puppeteer, which has also superseded phantomjs due to the developer(s) calling it quits after chrome puppeteer (chrome dev tools wrapper) was released.
Below link will help.
https://github.com/aravindnc/Buttons/wiki/How-to-add-title-and-image-header-to-all-pages-while-printing-using-DataTable