6 min read 1397 words Updated Mar 17, 2026 Created Mar 17, 2026

Create Workflow

Use this guide when:

  • Creating a new document from scratch
  • Redesigning/beautifying an existing poorly-formatted document (content extraction + new design)

1. Lane Clarification

ScenarioLaneRationale
No input fileCreatePure creation
Input file + "fill this template"Template-ApplyPreserve structure
Input file + "redesign/beautify this"CreateExtract content, rebuild with new design
Input file + "fix formatting issues"CreateContent is source, not structure

When input exists but user wants redesign, treat the file as content source, not template.


2. Content Extraction (When Input Exists)

2.1 Detect Container Type

Check magic bytes before processing:

xxd -l 8 <input-file>
ContainerMagic BytesAction
OOXML (.docx)50 4B 03 04Extract directly
OLE Binary (.doc)D0 CF 11 E0 A1 B1 1A E1Convert first

2.2 Convert Legacy .doc

soffice --headless --convert-to docx --outdir <tmp-dir> <input.doc>
  • Do NOT use textutil (loses structure fidelity)
  • Keep original read-only
  • Work with converted copy

2.3 Extract Content

# Preview text content
python3 <skill-path>/docx_engine.py preview <input.docx>

# Or use pandoc for structured extraction
pandoc <input.docx> -t markdown -o content.md

Extract:

  • Text content (paragraphs, headings)
  • Table data
  • List items
  • Image references (if reusable)

Discard:

  • Poor styling/formatting
  • Broken layouts
  • Inconsistent spacing

3. Scene Routing

Match the document's purpose to a template starting point:

Scene CharacteristicsRecommended TemplateKey Features
Academic/ResearchAcademicPaper.csAbstract, citations, formal hierarchy
Technical ManualTechManual.csCode blocks, tables, procedures
Book/Collection/Small paper (A5/B5)PoetryCollection.csSection isolation, headers/footers
Business ReportCombine primitivesExecutive summary, charts, recommendations

No exact match? Use design primitives (Section 2) to compose from scratch.


4. Design Primitives

When no template fits, combine these building blocks:

2.1 Cover Page Patterns

PatternVisual EffectBest For
Full-bleedBackground image fills page, text overlaysBrochures, pitch decks, event programs
Whitespace-centeredLarge margins, content centered or offsetResumes, academic covers, minimalist reports
SplitLeft/right or top/bottom zones with contrastProposals, dual-language documents

Implementation: render/page_art.py for backgrounds, Word text layer for editability.

2.2 Body Layout Patterns

PatternVisual EffectBest For
Single columnTraditional flowReports, papers, contracts
Two columnMagazine feelNewsletters, catalogs, manuals
Card gridEqual-width blocks with imagesProduct listings, performer bios, portfolios
TimelineVertical axis with nodesResumes, project histories, event schedules
Side-by-sideLeft/right comparisonContracts, before/after, bilingual

Implementation: See Layout.cs for column/section helpers.

2.3 Navigation Elements

ElementWhen to IncludeImplementation
TOC3+ major sectionsFields.cs → TOC field + refresh hint
Page numbersMulti-page documentsFooter with PAGE/NUMPAGES fields
HeadersPersistent identification neededDocument title or org name
Section dividersLong documents with distinct partsPageBreakBefore + visual heading

5. Design Decision Framework

When composing without a template, answer these questions:

3.1 Content Density

If...Then...
High density (tables, lists, data)Tighter spacing, smaller margins, compact headings
Low density (prose, few elements)Generous whitespace, larger titles, more breathing room

3.2 Visual Focus

If...Then...
Image-heavyFull-bleed covers, card layouts, minimal text styling
Text-heavyStrong heading hierarchy, wider line spacing, clear indentation

3.3 Reading Pattern

If...Then...
Sequential (start to end)Traditional chapters, numbered sections, linear flow
Random access (flip through)Independent pages, strong navigation, visual anchors

3.4 Audience & Purpose

If reader needs to...Prioritize...
Approve budget/scopeExecutive summary, decision options, recommendations early
Execute implementationProcedures, constraints, checklists, verification steps
Audit complianceTraceability tables, signature blocks, metadata

6. Adjustment Guide

4.1 Color Palette

Location: src/Templates/Themes.cs or inline in your code.

// Use a predefined theme
var colors = Themes.Ocean;  // or Forest, Stone, Ember, Amethyst, Monochrome

// Apply to heading
new Color { Val = colors.Heading }

// Apply to body
new Color { Val = colors.Body }

Principles:

  • Maximum 3 primary colors
  • Use muted/desaturated tones
  • Ensure sufficient contrast (heading vs body)

Scene-color mapping:

SceneRecommended Palette
Corporate/FinanceStone, Monochrome
Tech/ProductOcean, Stone
AcademicOcean, Forest
Creative/EventAmethyst, Ember
ESG/NatureForest

4.2 Spacing & Margins

Location: src/Core/Layout.cs, src/Core/Primitives.cs

ElementPropertyDefaultSmall Paper (A5/B5)
Page marginsPageMargin1440 twips (1")1080 twips (0.75")
Paragraph afterSpacingBetweenLines.After200 twips (10pt)120-160 twips
Line heightSpacingBetweenLines.Line360 (1.5x)300-360
Section gapBefore major heading480 twips (24pt)280-360 twips

Unit reference: 1 pt = 20 twips, 1 inch = 1440 twips

4.3 Structure Modifications

Add cover page:

// 1. Add cover content
body.Append(CreateCoverPage(title, subtitle, date));

// 2. End cover section (CRITICAL for small paper)
body.Append(new Paragraph(
    new ParagraphProperties(
        new SectionProperties(
            new SectionType { Val = SectionMarkValues.NextPage }
        )
    )
));

// 3. Continue with body content

Add TOC:

// Use Fields.cs helper
body.Append(Fields.TableOfContents());

// Add refresh hint (gray, smaller font)
body.Append(new Paragraph(
    new ParagraphProperties(new ParagraphStyleId { Val = "TOCHint" }),
    new Run(
        new RunProperties(
            new Color { Val = "808080" },
            new FontSize { Val = "18" }
        ),
        new Text("(Right-click TOC → Update Field to refresh page numbers)")
    )
));

Remove headers/footers: Simply don't append HeaderPart/FooterPart.

4.4 Paper Size Adaptation

Small paper (A5/B5) checklist:

  • Use section breaks, not spacing hacks, for cover isolation
  • Reduce all spacing proportionally (see 4.2)
  • Test that cover content fits on one page
  • Consider removing TOC if document is short

Reference: src/Templates/PoetryCollection.cs demonstrates A5/B5 patterns.


7. Scenario Completeness

When creating from scratch, verify role-critical blocks are present:

Document TypeRequired Blocks
Exam/QuizCandidate info zone, score columns, grader signature
ContractParty info, signature/seal slots, effective date, annexes
Meeting MinutesAttendees, action items with owners, due dates
ProposalDecision summary, scope, milestones, budget, acceptance terms
InvoiceInvoice number, line items, subtotal/tax/total, payment details
ResumeContact info, experience timeline, skills summary
Event ProgramSchedule, performer/speaker info, venue details

8. Visual Exit Checklist

Before delivery, verify:

  • Hierarchy: H1 > H2 > H3 visually distinct (size, weight, spacing)
  • Spacing: Consistent paragraph gaps, no cramped sections
  • Alignment: Text aligned consistently (usually left/justified)
  • Colors: ≤3 primary colors, no clashing tones
  • Whitespace: Margins ≥72pt, content not edge-to-edge
  • Flow: KeepNext on headings, PageBreakBefore on chapters
  • Navigation: Page numbers present if multi-page
  • TOC: Includes refresh hint if present

9. Build Commands

# 1. Check environment
python3 <skill-path>/docx_engine.py doctor

# 2. Generate document
python3 <skill-path>/docx_engine.py render output.docx

# 3. Validate
python3 <skill-path>/docx_engine.py audit output.docx

# 4. Preview content
python3 <skill-path>/docx_engine.py preview output.docx

10. Code References

NeedReference File
Page/section layoutsrc/Core/Layout.cs
Text/paragraph primitivessrc/Core/Primitives.cs
TOC/bookmarks/fieldssrc/Core/Fields.cs
Image embeddingsrc/Core/Media.cs
Unit conversionssrc/Core/Metrics.cs
Academic document examplesrc/Templates/AcademicPaper.cs
Technical manual examplesrc/Templates/TechManual.cs
Book/collection examplesrc/Templates/PoetryCollection.cs
Color themessrc/Templates/Themes.cs
Background renderingrender/page_art.py