Can I export image to excel, pdf and print

Can I export image to excel, pdf and print

dpkkmdpkkm Posts: 4Questions: 1Answers: 0

https://codepen.io/dpkkm/pen/NWpVBgx

Name Age/Sex Photo
Durga Prasad 31/M image
Ramavtar 40/M image
Suresh Chand 35/M image
$(document).ready(function() { $('#example').DataTable( { dom: 'Bfrtip', buttons: [ 'excel', 'pdf', 'print' ] } ); } );

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Please refer to the answer you were given the last time you asked this question:
    https://datatables.net/forums/discussion/65174

  • dpkkmdpkkm Posts: 4Questions: 1Answers: 0

    Sir, I am a new developer, so i try to learn, I have tried many times. but something wrong. I don't understand and it is not working. please create new code for me.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Try this SO thread, there seems to be a working example there,

    Colin

  • dpkkmdpkkm Posts: 4Questions: 1Answers: 0

    Not Working, please check it

    $dp="https://image.shutterstock.com/image-vector/man-shirt-tie-businessman-avatar-260nw-548848999.jpg";

    $type = pathinfo($dp, PATHINFO_EXTENSION);
    $data = file_get_contents($dp);
    $imgdata = base64_encode($data);

    $src = 'data:image/'.$type.';base64,'.$imgdata;

    <td class="selected">
    <?php echo '<img class="img-fluid" src="'.$src.'" style="width:80px;">'; ?>
    </td>

    $(document).ready(function() { $('#example').DataTable( { dom: 'Bfrtip', buttons: [ { extend: 'pdfHtml5', orientation: 'landscape', customize: function(doc){ if(doc){ for (var i = 1; i < doc.content[1].table.body.length; i++) { doc.content[1].table.body[i][1] = { image: '<?php echo $src; ?>, }; } } }, exportOptions:{ stripHtml: false } }, ], }); } );
  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    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

Sign In or Register to comment.