DOCXKIT_HEADER_FOOTER_INVALID_CONTENT: 頁首頁尾內容無效
頁首或頁尾外掛回傳了 Paragraph、Table 以外的元素。
修復步驟
- 頁首頁尾內容回傳 Paragraph 或 Table 實例。
- 將行內元素包裝在 Paragraph 內。
問題範例
ts
import { TextRun } from 'docx'
// Invalid output from a plugin used in a header/footer:
const render = () => new TextRun('Header')修復範例
ts
import { Paragraph, TextRun } from 'docx'
// Valid output from a plugin used in a header/footer:
const render = () => new Paragraph({ children: [new TextRun('Header')] })常見原因
- 外掛直接回傳 TextRun 或其他不支援的子元素。
診斷欄位
code:HEADER_FOOTER_INVALID_CONTENTdiagnosticCode:DOCXKIT_HEADER_FOOTER_INVALID_CONTENTname:DocxKitErrordocs: https://docx-kit.ntnyq.dev/errors/docxkit_header_footer_invalid_content/
訊息範例
text
Header and footer plugins must render paragraphs or tables