External font-family for print export (datatables)
External font-family for print export (datatables)

Hello,
I am using datatables and also the extension to generate a print view. But I need to use a specific font which I using on the webpage. I am not able to use this in the print view. All my comands are ignored.
Even just to change the font to standard Times New Roman is ignored how I do it:
Any idea how I can change the font?
My own fonts are included like this:
@font-face { font-family: 'Helvetica';
src: url('/font/HelveticaNeueLTPro-LtCn.ttf') format('truetype'); }
@font-face { font-family: 'Helvetica';
src: url('/font/HelveticaNeueLTPro-BdCn.ttf') format('truetype');
font-weight: bold; }
@font-face { font-family: 'Basil';
src: url('/font/Basil-Regular.otf') format('truetype'); }
The datatable part looks like this:
$(document).ready(function() {
$('#example').DataTable( {
"dom": 'Bfrtip',
"lengthMenu": [
[ 10, 25, 50, -1 ],
[ '10 Zeilen', '25 Zeilen', '50 Zeilen', 'Alle Zeilen' ]
],
"buttons": [
'pageLength',
{
extend: 'print',
text: 'Drucken',
customize: function ( win ) {
win.defaultStyle.font = 'Times New Roman';
},
autoPrint: false
}
,'pdf','csv'
],
"processing": true,
"serverSide": true,
"language": {
"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
},
"ajax": $.fn.dataTable.pipeline( {
url: '/vertragsliste_load.php',
pages: 5 // number of pages to cache
} )
} );
} );
Any idea how I can do this?
Thanks
Mark
This discussion has been closed.
Answers
Have you tried a print stylesheet?
https://onextrapixel.com/how-to-create-a-simple-print-css-for-your-site/
You might only need to override the font settings.
Hi @markglahn ,
Another option is this thread, should help as it shows how to change fonts.
Cheers,
Colin
Hi both. This not work. I tried both. Even I do it wrong or it is not work for this issue.
Thanks
Mark
Hi @markglahn ,
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