Skip to main content

Update Headers and Footers in Word in n8n

What this node does

PDF4me - Update Headers Footers in Word Document adds or replaces headers and footers in any DOCX file inside your n8n workflow. Supply HTML or plain text content for all pages, the first page, or separate odd/even pages. Use built-in tokens like PAGE and NUMPAGES to insert automatic page numbers. The node returns an updated DOCX with the new headers and footers applied - body content is completely preserved. Route the output to cloud storage, email, or any further document step.

Authenticating Your API Request

Every PDF4me node in n8n requires valid Credentials. Create or select credentials that hold your PDF4me API key so the node can authenticate document formatting requests securely.

Important Facts You Should Not Miss

PAGE and NUMPAGES insert live page numbers
Write the literal text PAGE and NUMPAGES anywhere in your header or footer content. Word replaces them with the actual page number and total page count when the document is opened. So Page PAGE of NUMPAGES renders as Page 3 of 12 on page three of a twelve-page document - no manual updating needed.
All Pages fields override page-specific ones when both are set
If you fill All Pages Header and also fill Odd Pages Header, the All Pages content takes precedence across the document. To use different headers on odd and even pages, leave All Pages Header empty and fill only the Even Pages Header and Odd Pages Header fields. For a unique first-page header, fill First Page Header separately regardless of what you set for other pages.
Body content is never touched - only header and footer zones are updated
The node modifies only the header and footer sections of the DOCX XML. Paragraphs, tables, images, styles, tracked changes, and all other body content remain exactly as they were in the source document. You can safely apply this node to complex branded templates without risk of altering the body.
n8n PDF4me Update Headers Footers in Word Document node showing Input Data Type set to Binary Data, Input Binary Field referencing the prior node, Word Document Name set to report.docx, All Pages Header with HTML div content, All Pages Footer showing Page PAGE of NUMPAGES, and Culture Name set to en-US

Set the input source, enter HTML or plain text in the header and footer fields, use PAGE/NUMPAGES tokens for page numbers, and execute. The updated DOCX is available in the binary output.

Parameters

Required: Input Data Type, the document source field matching that type (Input Binary Field, Base64 Word Content, or Word Document URL), and Word Document Name. All header and footer content fields are optional - fill only the ones you need.

ParameterRequiredWhat it doesExample
Input Data TypeYesFormat of the source DOCX. Binary Data maps the file from a prior node; Base64 String accepts encoded content; URL fetches from a public address.Binary Data
Input Binary FieldYes (Binary)Binary property name from the prior node holding the DOCX.data
Base64 Word ContentYes (Base64)Base64-encoded DOCX string to process.UEsDBBQABgAI...
Word Document URLYes (URL)Publicly accessible URL to the source DOCX.https://example.com/report.docx
Word Document NameYesFilename of the input DOCX including .docx extension. Used for format detection.report.docx
All Pages HeaderNoHeader content applied to every page. Accepts HTML with inline styles or plain text. Supports PAGE, NUMPAGES, SECTION, SECTIONPAGES tokens.<div style='text-align:center'>Acme Corp</div>
All Pages FooterNoFooter content applied to every page. Accepts HTML or plain text with the same token support.Page PAGE of NUMPAGES
First Page HeaderNoHeader used only on the first page - useful for title pages and cover sheets. Leave All Pages Header empty when using this for a unique first-page look.<div style='text-align:center'>Confidential</div>
First Page FooterNoFooter used only on the first page.Draft - Not for Distribution
Even Pages HeaderNoHeader on even-numbered pages. Use with Odd Pages Header for two-sided print layouts.<div style='text-align:right'>Chapter Title</div>
Even Pages FooterNoFooter on even-numbered pages.<div style='text-align:center'>Page PAGE</div>
Odd Pages HeaderNoHeader on odd-numbered pages.<div style='text-align:left'>Report Title</div>
Odd Pages FooterNoFooter on odd-numbered pages.<div style='text-align:center'>Page PAGE</div>
Culture NameNoCulture/locale code for date and number formatting inside headers. Defaults to null.en-US

Quick Setup

  1. Add a PDF4me node and select Update Headers Footers in Word Document.
  2. Choose or create Credentials with your PDF4me API key.
  3. Set Input Data Type and map the DOCX from the prior node.
  4. Enter Word Document Name with .docx extension.
  5. Fill All Pages Header and/or All Pages Footer with HTML or plain text content. Use PAGE and NUMPAGES for page numbers.
  6. Click Execute Node. The output binary contains the updated DOCX.

Workflow Examples

Workflow ExamplesCommon n8n workflow patterns using Update Headers Footers in Word.
Apply company branding to generated reports
  1. A scheduled trigger generates a monthly performance report DOCX from a template.
  2. Update Headers Footers in Word Document adds a centered company logo placeholder and name in the header, and a footer with the report date and "Page PAGE of NUMPAGES."
  3. The branded DOCX is uploaded to SharePoint in the monthly reports library.
  4. Teams notifies the management channel that the branded report is ready.
Add a confidentiality footer to all outgoing contracts
  1. Airtable triggers when a contract record status changes to "Ready to Send."
  2. Google Drive downloads the contract DOCX.
  3. Update Headers Footers applies a footer with "CONFIDENTIAL - Page PAGE of NUMPAGES" to every page and a unique first-page header with the client name pulled from Airtable.
  4. Gmail sends the branded contract as an attachment to the client.
Two-sided printing layout for book chapters
  1. A webhook receives a new chapter DOCX from the writing tool.
  2. Update Headers Footers sets left-aligned Odd Pages Header with the chapter title and right-aligned Even Pages Header with the book title.
  3. Both even and odd footers show the page number centered for mirrored two-sided printing.
  4. The formatted chapter is saved to Dropbox and a Slack message alerts the editorial team.

Frequently Asked Questions

How do I add page numbers that update automatically?+
Write the literal tokens PAGE and NUMPAGES in your header or footer content. For example, entering "Page PAGE of NUMPAGES" in the All Pages Footer field produces "Page 1 of 24" on page one of a 24-page document. Word resolves these tokens to live values when the document is opened or printed. SECTION and SECTIONPAGES work the same way for section-level numbering.
What HTML is supported inside the header and footer fields?+
Standard inline HTML including div, p, span, strong, em, and br elements with inline CSS styles. Center, left, or right align using text-align on a div or p element. Bold and italic work with the relevant HTML tags. Complex CSS classes, external stylesheets, or JavaScript are not supported - keep styles inline. Example: <div style="text-align:right;font-size:10pt">Confidential</div>.
Can I have a different header on the first page vs the rest of the document?+
Yes. Fill First Page Header with the content you want on page one - for example your company logo placeholder or a "Cover Page" label. Leave All Pages Header empty or fill it separately for pages two onwards. If you fill both All Pages Header and First Page Header, the first page gets its dedicated content and all other pages get the All Pages content.
Does the update overwrite existing headers and footers?+
Yes. Any existing headers and footers in the source DOCX are replaced by the content you supply. If you only fill some fields - for example All Pages Footer but not All Pages Header - the header zone is cleared and replaced with an empty header. If you want to keep an existing header unchanged, read its content first and pass it back into the corresponding field.
Is the document body affected?+
No. The node exclusively modifies the header and footer zones in the DOCX XML. All paragraphs, tables, images, embedded objects, styles, tracked changes, comments, and formatting in the document body are preserved exactly as they appear in the source file.

Get Help