dolanmiu / docx

Easily generate and modify .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.

Home Page:https://docx.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can i set padding to a Paragraph?

jimmywong123 opened this issue · comments

WX20240409-152040@2x
like this paragraphy, i want to set some padding like css in the text.

new Paragraph({
  text: title,
  style: 'bannerText',
  shading: {
    type: ShadingType.CLEAR,
    fill: "3978BB",
  },
})

here is what i do:

new Table({
      rows: [
        new TableRow({
          children: [
            new TableCell({
              children: [
                new Paragraph({
                  text: title,
                  style: 'bannerText',
                })
              ],
              shading: {
                type: ShadingType.CLEAR,
                color: "ffffff",
                fill: "3978BB",
              },
              borders: {
                top: disableBorder,
                right: disableBorder,
                bottom: disableBorder,
                left: disableBorder,
              },
              margins: {
                top: 50,
                right: 50,
                bottom: 50,
                left: 50,
              },
              width: {
                size: 8970,
                type: WidthType.DXA,
              }
            })
          ]
        })
      ],
      borders: {
        top: disableBorder,
        right: disableBorder,
        bottom: disableBorder,
        left: disableBorder,
      },
      width: {
        size: 9070,
        type: WidthType.DXA,
      }
    })
  }