直线、圆形和其他形状?

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

是否可以使用

pdfmake
绘制
lines
circles
other shapes?如果有,有
documentation
或者有样品吗?我想用 pdfmake 替换 jsPDF

pdfmake
5个回答
17
投票

是的,有可能。 pdfmake 将它们称为向量。看 pdf制作矢量示例以获得更多可能性。

绘制一条线和多边形的示例:

{
   canvas: 
   [
       {
           type: 'line',
           x1: 40, y1: 60,
           x2: 260, y2: 60,
           lineWidth: 3
       },
       {
           type: 'polyline',
           lineWidth: 3,
           closePath: true,
           points: [{ x: 10, y: 10}, { x: 35, y: 40 }, { x: 100, y: 40 }, { x: 125, y:10 }]
       }
   ]
}

8
投票

我在 GitHub 上的 pdfMake 中回答了一个问题,如下:

创建一个带有布局标题的表格,您必须定义一个空的正文,否则该行不会出现:

var dd = {
    content: [
        {
                                  table : {
                                      headerRows : 1,
                                      widths: [200],
                                      body : [
                                              [''],
                                              ['']
                                              ]
                                  },
                                  layout : 'headerLineOnly'
                              }
            ] }

宽度定义线的长度


3
投票
canvas: [
                {
                    type: 'rect',
                    x: 198,
                    y: -186,
                    w: 198,
                    h: 188,
                    r: 8,
                    lineWidth: 4,
                    lineColor: '#276fb8',

                },

                 ]

0
投票

@gegobyte 我使用了 @Beka 提到的代码,其中 headerRows : 0,layout : 'lightHorizontalLines' 来减少线宽

{ 桌子 : { 标题行:0, 宽度:['*'], 身体 : [ [''], [''] ] }, 布局:'lightHorizontalLines' },


-1
投票

据我所知,pdfmake不提供绘图API。尽管如此,pdfmake 还是为您提供了一些在 pdf 中插入图像的方法。

致以诚挚的问候!

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