Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footer is not preserved #343

Open
csod-bganatra opened this issue Jan 2, 2024 · 3 comments
Open

Footer is not preserved #343

csod-bganatra opened this issue Jan 2, 2024 · 3 comments

Comments

@csod-bganatra
Copy link

So I have a docx templates containing three pages

    1. Header
    1. Middle Page
    1. Last Page

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
Copy link
Collaborator

jjhbw commented Jan 2, 2024

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

@csod-bganatra
Copy link
Author

csod-bganatra commented Jan 3, 2024

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants