guigrpa / docx-templates

Template-based docx report creation
MIT License
882 stars 145 forks source link

Footer is not preserved #343

Open csod-bganatra opened 8 months ago

csod-bganatra commented 8 months ago

So I have a docx templates containing three pages

Header has some info about doc middle page has a loop which generates some pages now what I want is every page to have different footers header has different footer middle pages have different footer and last page should have different footer Last page for some greeting

but when I try to generate docx using template it applied first page's footer to every page how can I overcome this issue?

jjhbw commented 8 months ago

Can you provide a reproducible example? Code + template, needs to be runnable without fuss.

csod-bganatra commented 8 months ago

Hello @jjhbw Here is my code

const { createReport } = require("docx-templates");
const fs = require("fs");

createReport({
  template: fs.readFileSync(filePath),
  data: {
    title: "Page 1",
    numbers: [1, 2, 3, 4, 5],
    page_break_xml: `||<w:br w:type="page" />||`,
  },
  cmdDelimiter: ["{", "}"],
  processLineBreaks: false,
}).then((buf) => {
  console.log(buf);
  fs.writeFileSync("./demo.docx", buf);
});

And sample docx file sample.docx

Please have a look and let me know if I am doing something wrong.

csod-bganatra commented 8 months ago

Hello @jjhbw just asking, did you have a chance to look at this demo docx file and issue, please let me know.