Export Array Images with PDF using DataTable

Export Array Images with PDF using DataTable

webiscorewebiscore Posts: 4Questions: 3Answers: 0

I found many solutions how to export images in PDF using DataTable which I applied one with some modifications however those examples are related to static one image while I have an array of images that I need to export in every row.

I have to export every product's image but it's repeating the same image for all instead.

var tmptext = '<?php if ($products) { ?><?php foreach ($products as $product) { ?><?php echo $product['image']; ?><?php }} ?>';

            {
                extend: 'pdfHtml5',
                text:      '<i class="fa fa-file-pdf-o"></i>',
                titleAttr: 'Export to PDF',
                orientation: 'landscape',
                customize: function (doc) {
                   if (doc) {
                        for (var i = 1; i < doc.content[1].table.body.length; i++) {
                            doc.content[1].table.widths = Array(doc.content[1].table.body[0].length + 1).join('*').split('');
                            doc.content[1].table.body[i][1] = {
                                margin: [0, 0, 0, 12],
                                alignment: 'center',
                                image: tmptext,
                                width: 36,
                                height: 36
                            };
                        }
                    }
                },
                exportOptions: {
                    columns: [0, 1, 2, 3, 4, 5, 6, 7],
                    stripHtml: true
                }
            }

My other question does this same customization applies to Excel if I wanna export images to excel??

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @webiscore ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.