1.3 KiB
1.3 KiB
Symbol Runs
!> SymbolRuns require an understanding of Paragraphs.
You can add multiple symbol runs
in Paragraphs
along with text runs using the Paragraph's children
property.
import { Paragraph, TextRun, SymbolRun } from "docx";
const paragraph = new Paragraph({
children: [
new TextRun("This is a checkbox: "),
new SymbolRun("F071")
],
});
Specifying symbol font
By default symbol runs will use the Wingdings
font. To switch fonts, pass an object instead of a string to the SymbolRun
constructor and specify char
and symbolfont
properties:
const symbol = new SymbolRun({
char: "F071",
symbolfont: "Arial",
});
Example symbols
Symbols are specified by their hexidecimal code. Ref http://officeopenxml.com/WPtextSpecialContent-symbol.php. Below are some examples.
F071
: empty checkboxF043
: thumbs upF04A
: smileF04C
: frownF022
: scissorsF0F0
: right arrowF0FE
: checked box
Typographical Emphasis
Symbol runs can have their display modified just like text runs. For example, they can be bolded and italicized:
const symbol = new SymbolRun({
char: "F071",
bold: true,
italics: true,
});
See the text run documentation for more info.