docx
Version:
Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
21 lines (15 loc) • 500 B
text/typescript
import { nanoid } from "nanoid/non-secure";
let currentCount = 0;
// Twip - twentieths of a point
export const convertMillimetersToTwip = (millimeters: number): number => {
return Math.floor((millimeters / 25.4) * 72 * 20);
};
export const convertInchesToTwip = (inches: number): number => {
return Math.floor(inches * 72 * 20);
};
export const uniqueNumericId = (): number => {
return ++currentCount;
};
export const uniqueId = (): string => {
return nanoid().toLowerCase();
};