docx icon indicating copy to clipboard operation
docx copied to clipboard

Change page number font

Open qusysert opened this issue 2 years ago • 2 comments

Hello, Is there any way to change font of page number? Font changes fine from default in "Page | " part, but then in the next TextRun it always prints page number in Times New Roman.

Here is example of the code

paragraph(
  {
      alignment: docx.AlignmentType.RIGHT,
      children: [
          new TextRun({
              font: FontFamily,
              text: "Page | ",
          }),
          new TextRun({
              font: FontFamily,
              children: [docx.PageNumber.CURRENT],
          }),
      ],
  }
),

qusysert avatar Jan 23 '23 14:01 qusysert

Try something like this:

https://github.com/dolanmiu/docx/blob/master/demo/45-highlighting-text.ts

dolanmiu avatar Jan 23 '23 14:01 dolanmiu

I also tried uniting two TextRuns and applying styling from examle. Styles work on "Page | " but not on page number. Dont really any got idea why it works like this

children: [
    new TextRun({
        color: "FF0000",
        bold: true,
        font: {
            name: FontFamily,
        },
        children: ["Страница | ", docx.PageNumber.CURRENT],
    }),
],

qusysert avatar Jan 26 '23 11:01 qusysert