Angular 7 AmCharts PDF字体

问题描述 投票:0回答:1

我正在使用Angular 7和AmCharts,并且正在导出PDF(使用附带的pdfmake库),但是我无法更改所生成PDF的默认字体。我已经用所需的字体创建了vfs_fonts.js,并将其包含在angular.json部分的scripts中。在生成报告的组件中,执行以下操作:

let pdfMake = res[0];

pdfMake.fonts = {
    "Open Sans": {
        "normal": 'OpenSans-Regular.ttf',
        "bold": 'OpenSans-Bold.ttf',
        "italics": 'OpenSans-Italic.ttf',
        "bolditalics": 'OpenSans-BoldItalic.ttf'
    }
}

let doc = {
    header: this.drawHeader(),
    footer: this.drawFooter(),
    pageSize: "A4",
    pageOrientation: "portrait",
    pageMargins: [40, 80, 40, 60],
    content: [],
    defaultStyle: {
        font: "Open Sans"
    }
};

但出现以下错误:

ERROR Error: Uncaught (in promise): Error: Font 'Open Sans' in style 'normal' is not defined in the font section of the document definition.
Error: Font 'Open Sans' in style 'normal' is not defined in the font section of the document definition

我该如何解决?谢谢

angular amcharts
1个回答
-1
投票
{ stack : [ { text: this is a test text font: 'OpenSans', italic: true }, { text: this is another test text font: 'Roboto', bold: true } ] }

来自GitHub的参考this issue comment。>>

[This comment可能有助于覆盖字体。

© www.soinside.com 2019 - 2024. All rights reserved.