如何在vfs_fonts.js中分配ttf字体文件?
How to I assign the ttf font file in the vfs_fonts.js?
我正在尝试将自定义字体添加到 vfs_fonts.js,但我不明白需要在 window.pdfMake 对象的值字段中写入什么?
我的密钥是 "MyFont.ttf",我知道它的值只是 ttf 文件。我的 ttf 是一个物理文件而不是一组字符。如何填写值字段?
window.pdfMake = window.pdfMake || {}; window.pdfMake.vfs = {
"Roboto-Italic.ttf": "AAEAAAASAQAABA",
"Roboto-Medium.ttf": "AAEAAA",
"MyFont.ttf":"???????????????????"
}
谢谢
/* Read the documenation at https://github.com/bpampuch/pdfmake
specially the readme file */
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>my first pdfmake example</title>
<script src='build/pdfmake.min.js'></script>
<script src='build/vfs_fonts.js'></script>
</head>
<body>
<script>
// works great with the default vfs_fonts.js
pdfMake.fonts = {
Roboto: {
normal: 'Roboto-Regular.ttf',
bold: 'Roboto-Medium.ttf',
italics: 'Roboto-Italic.ttf',
bolditalics: 'Roboto-MediumItalic.ttf'
}
};
// open the PDF in a new window
pdfMake.createPdf(docDefinition).open();
</script>
</body>
我正在尝试将自定义字体添加到 vfs_fonts.js,但我不明白需要在 window.pdfMake 对象的值字段中写入什么?
我的密钥是 "MyFont.ttf",我知道它的值只是 ttf 文件。我的 ttf 是一个物理文件而不是一组字符。如何填写值字段?
window.pdfMake = window.pdfMake || {}; window.pdfMake.vfs = {
"Roboto-Italic.ttf": "AAEAAAASAQAABA",
"Roboto-Medium.ttf": "AAEAAA",
"MyFont.ttf":"???????????????????"
}
谢谢
/* Read the documenation at https://github.com/bpampuch/pdfmake
specially the readme file */
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>my first pdfmake example</title>
<script src='build/pdfmake.min.js'></script>
<script src='build/vfs_fonts.js'></script>
</head>
<body>
<script>
// works great with the default vfs_fonts.js
pdfMake.fonts = {
Roboto: {
normal: 'Roboto-Regular.ttf',
bold: 'Roboto-Medium.ttf',
italics: 'Roboto-Italic.ttf',
bolditalics: 'Roboto-MediumItalic.ttf'
}
};
// open the PDF in a new window
pdfMake.createPdf(docDefinition).open();
</script>
</body>