CORE

@office-open/core

Shared XML components, value validation, formatting, and unit converters

You typically don't install this package directly — it's a dependency of @office-open/docx and @office-open/pptx. However, if you are building custom OOXML elements or extending the library, @office-open/core provides the building blocks.

Module Overview

XML Components

All OOXML XML elements are built on top of XmlComponent. Every element in a .docx or .pptx file ultimately extends this base class.

import { XmlComponent } from "@office-open/core";

class MyElement extends XmlComponent {
    constructor() {
        super("w:myElement");
    }
}

Values & Validation

Runtime validation functions for OOXML specification value types:

FunctionDescription
decimalNumber(val)Validates and floors to integer
hexColorValue(val)Validates hex color
twipsMeasureValue(val)TWIP measurement
hpsMeasureValue(val)Half-point measurement (font sizes)
percentageValue(val)Normalizes percentage string

Unit Converters

import {
    convertMillimetersToTwip,
    convertInchesToTwip,
    convertPixelsToEmu,
    convertEmuToPixels,
    convertPointsToEmu,
} from "@office-open/core";

convertMillimetersToTwip(25.4); // 1440 (1 inch)
convertPixelsToEmu(100); // 952500
convertPointsToEmu(12); // 152400

Charts & SmartArt

Shared chart components (BarChart, LineChart, PieChart, AreaChart, ScatterChart) and SmartArt components used by both @office-open/docx and @office-open/pptx.

DrawingML

Shared primitives for colors, fills, outlines, effects, and geometry.

Copyright © 2026