Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
Versions
- 5.15.3Latest
- 5.15.2
- 5.15.1
- 5.15.0
- 5.14.1
- 5.14.0
- 5.13.3
- 5.13.2
- 5.13.1
- 5.13.0
- 5.12.2
- 5.12.1
- 5.12.0
- 5.11.4
- 5.11.3
- 5.11.2
- 5.11.1
- 5.11.0
- 5.10.1
- 5.10.0
- 5.9.0
- 5.8.1
- 5.8.0
- 5.7.2
- 5.7.1
- 5.7.0
- 5.6.0
- 5.5.6
- 5.5.5
- 5.5.4
- 5.5.3
- 5.5.2
- 5.5.1
- 5.5.0
- 5.4.0
- 5.3.8
- 5.3.7
- 5.3.6
- 5.3.5
- 5.3.4
- 5.3.3
- 5.3.2
- 5.3.1
- 5.3.0
- 5.2.1
- 5.2.0
- 5.1.1
- 5.1.0
- 5.0.2
- 5.0.1
- 5.0.0
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.1
- 3.0.0
- 2.4.3
- 2.4.2
- 2.4.1
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
This is a Deno module for making .docx
files.
It can be used to create a .docx
using components, for example:
/** @jsx JSX */
import { Docx, JSX, Paragraph } from 'https://deno.land/x/docxml@1.0.0/mod.ts';
Docx.fromJsx(<Paragraph>This is the simplest document you could make.</Paragraph>)
.toArchive()
.toFile('test.docx');
Or it can be used to convert any XML to DOCX:
// TODO example code
Formatting options
Paragraph formatting
Paragraph styles may be applied via different ways;
// As a prop:
<Paragraph alignment="center" />
// As a style:
const style = api.styles.add({
type: 'paragraph',
paragraphProperties: {
alignment: 'center',
},
});
<Paragraph style={style} />;
Every style property, and every property of every style property, is optional;
{
alignment?: 'left' | 'right' | 'center' | 'both';
style?: string;
spacing?: {
before?: TwentiethPoint;
after?: TwentiethPoint;
line?: TwentiethPoint;
lineRule?: 'atLeast' | 'exactly' | 'auto';
afterAutoSpacing?: boolean;
beforeAutoSpacing?: boolean;
};
indentation?: {
left?: TwentiethPoint;
leftChars?: number;
right?: TwentiethPoint;
rightChars?: number;
hanging?: TwentiethPoint;
hangingChars?: number;
firstLine?: TwentiethPoint;
firstLineChars?: number;
};
}
Text formatting
// As a prop:
<Text isBold />
Every style property is optional again:
{
verticalAlign?: 'baseline' | 'subscript' | 'superscript';
isBold?: boolean;
isItalic?: boolean;
isSmallCaps?: boolean;
language?: string;
fontSize?: HalfPoint;
}
Paragraph formatting options may be merged with text formatting options. When used directly on a component (ie. not via a style) the formatting only applies to the paragraph pilcrow (“¶”) sign. In MS Word, the text styling options merged into a paragraph style definition do apply to the paragraph text – but may still be overriden with dedicated text formatting options.
<Paragraph isBold>Text not shown as bold, but the paragraph's pilcrow is.</Paragraph>
// As a style:
const style = api.styles.add({
type: 'paragraph',
textProperties: {
isItalic: true,
},
paragraphProperties: {
isBold: true,
},
});
<Paragraph style={style}>Text is shown as bold and italic</Paragraph>;