#1528 Adding numbering replacer on header and footer
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
// Numbering and bullet points example
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
|
||||
import { AlignmentType, convertInchesToTwip, Document, Footer, Header, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
numbering: {
|
||||
@ -119,6 +119,46 @@ const doc = new Document({
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Hey you",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "What's up fam",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Hey you",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "What's up fam",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Hey you",
|
||||
|
@ -279,8 +279,10 @@ export class Compiler {
|
||||
// TODO: 0 needs to be changed when headers get relationships of their own
|
||||
const xmlData = this.imageReplacer.replace(tempXmlData, mediaDatas, 0);
|
||||
|
||||
const referenedXmlData = this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering);
|
||||
|
||||
return {
|
||||
data: xmlData,
|
||||
data: referenedXmlData,
|
||||
path: `word/header${index + 1}.xml`,
|
||||
};
|
||||
}),
|
||||
@ -301,8 +303,10 @@ export class Compiler {
|
||||
// TODO: 0 needs to be changed when headers get relationships of their own
|
||||
const xmlData = this.imageReplacer.replace(tempXmlData, mediaDatas, 0);
|
||||
|
||||
const referenedXmlData = this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering);
|
||||
|
||||
return {
|
||||
data: xmlData,
|
||||
data: referenedXmlData,
|
||||
path: `word/footer${index + 1}.xml`,
|
||||
};
|
||||
}),
|
||||
|
Reference in New Issue
Block a user