I have a print function in jquery as follows:
$("#btn_print").click(function () {
//Create print div
populatePrintdiv();
$("#btn_cmplte").css('display', 'block');
var divToPrint = document.getElementById('printdiv');
var newWin = window.open('', 'Print-Window');
newWin.document.open();
newWin.document.write('<html><body onload="window.print()" style="font-family:consolas;margin-left:30px;">' + divToPrint.innerHTML + '</body></html>');
newWin.document.close();
setTimeout(function () {
newWin.close();
}, 10);
});
Here I am specifying font-family as consolas for as you can see in this line
newWin.document.write('<html><body onload="window.print()" style="font-family:consolas;margin-left:30px;">' + divToPrint.innerHTML + '</body></html>');
I want to use Dot Matrix font family so I downloaded the font family 1979_dot_matrix.ttf
file and put it inside my project fonts
folder.
How can I include this font-family using font face inside :
newWin.document.write('<html><body onload="window.print()" style="font-family:consolas;margin-left:30px;">' + divToPrint.innerHTML + '</body></html>');
In css it will looks like:
@font-face {
font-family: 1979_dot_matrix;
src: local("1979_dot_matrix"),
local("1979_dot_matrix"),
url(fonts/1979_dot_matrix.ttf);
font-weight: bold;
}
How can I use this dynamically using jquery as the same line above.
I got the solution as: