小编reg*_*man的帖子

Angular 11 和 PdfMake。错误 TS2345:类型 {...} 的参数无法分配给类型 TDocumentDefinitions 的参数

我正在尝试根据 Angular 11 应用程序中 pdfMake 的官方文档定义 pdf 文档结构。但收到错误:

error TS2345: Argument of type '{ pageSize: string; pageOrientation: string; content: ({ text: string; style: string; fontSize?: undefined; } | { text: string; fontSize: number; style?: undefined; })[]; }' is not assignable to parameter of type 'TDocumentDefinitions'.
  Types of property 'pageOrientation' are incompatible.
    Type 'string' is not assignable to type '"landscape" | "portrait" | undefined'.

75     pdfMake.createPdf(docDefinition).open();
Run Code Online (Sandbox Code Playgroud)

我已经安装了所有人员:

npm install --save pdfmake
npm i --save-dev @types/pdfmake
Run Code Online (Sandbox Code Playgroud)

并导入它们:

import * as pdfMake from …
Run Code Online (Sandbox Code Playgroud)

pdfmake angular

4
推荐指数
1
解决办法
3212
查看次数

标签 统计

angular ×1

pdfmake ×1