Export PDF with custom format : problem of decoding html
Export PDF with custom format : problem of decoding html
Hello,
I see this documentation https://datatables.net/extensions/buttons/examples/html5/outputFormat-function.html
of how customize the export for a column.
So i tried and it works but i'm encounter a new problem of html code.
I have this to export in pdf :
buttons: [
{ extend: 'pdfHtml5',
footer: true,
orientation: 'landscape', exportOptions:{
format: {
body: function ( data, row, column, node ) {
return (column === 10 ? (data==1?'Oui':'') : data);
}
},
},
}
],
But if i have a quote a column, i got Cal'enzana
and not Cal'enzana
in the pdf.
Do i need to decode ? There is simple way with DataTable to do it ?
Regards
Replies
I tried with a test case, but i don't reproduce the problem :
https://live.datatables.net/femahudo/1/edit
Any idea ?
Where does your data come from, ie, Ajax, Javascript HTML?
If Ajax or Javascript then update the test case to use a sample of the data using Javascript loading like this example.
If HTML then right click and inspect the cell to see what the cell contains.
Likely you will need to decode it. There is nothing built into Datatables for this. Possibly using Orthogonal data for export will help.
Kevin
Hello,
Thank's Kevin
I have update my test case, but i use Laravel framework with https://github.com/yajra/laravel-datatables
So it's a server side processing.
Orthogonal export doesn't work.
If i inpect the cell, i have the quote decoded, but i think it's not decode in the data of the datatable.
I found a solution to decode with jquery :
decodeHTMLEntities(data)
and this function :
It works nice, but if someone have a better solution i will take it.
Regards
Yup that will work, but it will be slow for large data sets. That said, I'm not sure I have a better solution for you at this time.
Allan