Files
docx-js/docs/usage/symbols.md

54 lines
1.3 KiB
Markdown
Raw Normal View History

# Symbol Runs
2021-05-18 17:15:29 +03:00
!> SymbolRuns require an understanding of [Paragraphs](usage/paragraph.md).
2021-05-18 17:15:29 +03:00
You can add multiple `symbol runs` in `Paragraphs` along with [text runs](usage/text.md) using the Paragraph's `children` property.
```ts
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:
```ts
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 checkbox
- `F043`: thumbs up
- `F04A`: smile
- `F04C`: frown
- `F022`: scissors
- `F0F0`: right arrow
- `F0FE`: checked box
## Typographical Emphasis
Symbol runs can have their display modified just like text runs. For example, they can be bolded and italicized:
```ts
const symbol = new SymbolRun({
char: "F071",
bold: true,
italics: true,
});
```
2021-05-18 17:15:29 +03:00
See the [text run](usage/text.md) documentation for more info.