Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
qodex-ai avatar

Word Document Processor

  • 3.4k installs
  • 38 repo stars
  • Updated January 5, 2026
  • qodex-ai/ai-agent-skills

Ability to generate valid, professionally formatted .docx files with JavaScript/TypeScript using the docx library, including text formatting, styles, lists, tables, images, and page layout.

About

This skill teaches developers to programmatically generate professional Word documents (.docx) using the docx JavaScript library. It covers essential topics including text formatting (bold, italic, colors, highlights), style management with built-in and custom styles, list creation (bullets and numbered), table construction with proper borders and spacing, hyperlinks and navigation, image embedding, and page layout controls. The tutorial emphasizes critical rules: never use newlines within TextRun, always use proper list numbering configuration instead of unicode symbols, set table widths at both table and cell levels, use ShadingType.CLEAR for cell backgrounds, and wrap PageBreaks in Paragraph elements. Professional font combinations and visual hierarchy principles ensure documents render correctly across platforms.

  • Complete docx generation workflow with Node.js/Browser support via Packer.toBuffer() and Packer.toBlob()
  • Professional styling with overrideable built-in heading styles (Heading1, Heading2) and custom paragraph/character style
  • Proper list creation using LevelFormat.BULLET and LevelFormat.DECIMAL with independent numbering references
  • Table construction with dual-level width specification (columnWidths array + individual cell widths in DXA units)
  • Critical formatting rules preventing common corruption issues: no newlines in TextRun, ShadingType.CLEAR for shading, Pa

Word Document Processor by the numbers

  • 3,425 all-time installs (skills.sh)
  • +36 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #116 of 1,879 Documentation skills by installs in the Skillselion catalog
  • Security screen: HIGH risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/qodex-ai/ai-agent-skills --skill word-document-processor

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs3.4k
repo stars38
Security audit1 / 3 scanners passed
Last updatedJanuary 5, 2026
Repositoryqodex-ai/ai-agent-skills

What it does

Generate and manipulate DOCX files programmatically with JavaScript/TypeScript, handling complex formatting, tables, styles, and document structure.

Who is it for?

Backend services generating reports, invoices, resumes, contracts, or templates; Node.js/TypeScript projects requiring bulk document creation; automated document workflows.

Skip if: Real-time document collaboration, editing existing DOCX files, or scenarios requiring MS Office interoperability beyond standard formatting.

When should I use this skill?

Building document generation APIs, creating report generators, automating template-based document creation, or integrating document export into SaaS platforms.

What you get

Developer can build DOCX files with consistent styling, complex layouts, and proper Word-compatible structure; documents open correctly and render as intended across Office versions.

  • .docx Word document
  • formatted tables and headers
  • embedded images

By the numbers

  • Uses docx library APIs including Document, Packer, Paragraph, TextRun, Table, ImageRun, and TableOfContents

Files

SKILL.mdMarkdownGitHub ↗

DOCX Library Tutorial

Generate .docx files with JavaScript/TypeScript.

Important: Read this entire document before starting. Critical formatting rules and common pitfalls are covered throughout - skipping sections may result in corrupted files or rendering issues.

Setup

Assumes docx is already installed globally If not installed: npm install -g docx

const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, ImageRun, Media, 
        Header, Footer, AlignmentType, PageOrientation, LevelFormat, ExternalHyperlink, 
        InternalHyperlink, TableOfContents, HeadingLevel, BorderStyle, WidthType, TabStopType, 
        TabStopPosition, UnderlineType, ShadingType, VerticalAlign, SymbolRun, PageNumber,
        FootnoteReferenceRun, Footnote, PageBreak } = require('docx');

// Create & Save
const doc = new Document({ sections: [{ children: [/* content */] }] });
Packer.toBuffer(doc).then(buffer => fs.writeFileSync("doc.docx", buffer)); // Node.js
Packer.toBlob(doc).then(blob => { /* download logic */ }); // Browser

Text & Formatting

// IMPORTANT: Never use \n for line breaks - always use separate Paragraph elements
// ❌ WRONG: new TextRun("Line 1\nLine 2")
// ✅ CORRECT: new Paragraph({ children: [new TextRun("Line 1")] }), new Paragraph({ children: [new TextRun("Line 2")] })

// Basic text with all formatting options
new Paragraph({
  alignment: AlignmentType.CENTER,
  spacing: { before: 200, after: 200 },
  indent: { left: 720, right: 720 },
  children: [
    new TextRun({ text: "Bold", bold: true }),
    new TextRun({ text: "Italic", italics: true }),
    new TextRun({ text: "Underlined", underline: { type: UnderlineType.DOUBLE, color: "FF0000" } }),
    new TextRun({ text: "Colored", color: "FF0000", size: 28, font: "Arial" }), // Arial default
    new TextRun({ text: "Highlighted", highlight: "yellow" }),
    new TextRun({ text: "Strikethrough", strike: true }),
    new TextRun({ text: "x2", superScript: true }),
    new TextRun({ text: "H2O", subScript: true }),
    new TextRun({ text: "SMALL CAPS", smallCaps: true }),
    new SymbolRun({ char: "2022", font: "Symbol" }), // Bullet •
    new SymbolRun({ char: "00A9", font: "Arial" })   // Copyright © - Arial for symbols
  ]
})

Styles & Professional Formatting

const doc = new Document({
  styles: {
    default: { document: { run: { font: "Arial", size: 24 } } }, // 12pt default
    paragraphStyles: [
      // Document title style - override built-in Title style
      { id: "Title", name: "Title", basedOn: "Normal",
        run: { size: 56, bold: true, color: "000000", font: "Arial" },
        paragraph: { spacing: { before: 240, after: 120 }, alignment: AlignmentType.CENTER } },
      // IMPORTANT: Override built-in heading styles by using their exact IDs
      { id: "Heading1", name: "Heading 1", basedOn: "Normal", next: "Normal", quickFormat: true,
        run: { size: 32, bold: true, color: "000000", font: "Arial" }, // 16pt
        paragraph: { spacing: { before: 240, after: 240 }, outlineLevel: 0 } }, // Required for TOC
      { id: "Heading2", name: "Heading 2", basedOn: "Normal", next: "Normal", quickFormat: true,
        run: { size: 28, bold: true, color: "000000", font: "Arial" }, // 14pt
        paragraph: { spacing: { before: 180, after: 180 }, outlineLevel: 1 } },
      // Custom styles use your own IDs
      { id: "myStyle", name: "My Style", basedOn: "Normal",
        run: { size: 28, bold: true, color: "000000" },
        paragraph: { spacing: { after: 120 }, alignment: AlignmentType.CENTER } }
    ],
    characterStyles: [{ id: "myCharStyle", name: "My Char Style",
      run: { color: "FF0000", bold: true, underline: { type: UnderlineType.SINGLE } } }]
  },
  sections: [{
    properties: { page: { margin: { top: 1440, right: 1440, bottom: 1440, left: 1440 } } },
    children: [
      new Paragraph({ heading: HeadingLevel.TITLE, children: [new TextRun("Document Title")] }), // U

Related skills

How it compares

Choose word-document-processor when you need programmatic .docx assembly with full layout control inside an agent pipeline.

FAQ

Why must PageBreak be inside a Paragraph?

Standalone PageBreak creates invalid XML that Word cannot parse. Always wrap: new Paragraph({ children: [new PageBreak()] })

What is DXA and how do I calculate column widths?

DXA = twentieths of a point. 1440 DXA = 1 inch. Letter with 1-inch margins = 9360 DXA usable. For 2 equal columns: [4680, 4680].

How do independent numbered lists work?

Each unique numbering reference creates a separate list. Same reference continues numbering (1,2,3 then 4,5,6). Different reference restarts (1,2,3 then 1,2,3).

Is Word Document Processor safe to install?

skills.sh reports 1 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Documentationbackenddocs

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.