# Rich Text in PDF

Learn about Rich Text in Wijmo's PDF module in this tutorial

## Content



In __PdfDocument__, the text can be filled with any color. It can also be stroked or filled and stroked simultaneously.

The __drawText__'s options argument has the fill and stroke properties. Leave these properties empty to indicate that the text should be filled, by default. Set __stroke__ to true to indicate that the text should be stroked. Set __fill__ and __stroke__, both to true to indicate that text should be both stroked and filled.

Each call to __drawText__ starts a new paragraph. To indicate that subsequent text should be placed right after the previous one, set the options argument's continued property to true:

```javascript
import * as wijmo from '@mescius/wijmo';
import * as wjPdf from '@mescius/wijmo.pdf';

doc.drawText("Lorem ", null, null, { continued: true });
doc.drawText('ipsum ', null, null, {
        continued: true,
        stroke: true
    }
);
```

##### Result
![Lorem Ipsum Rich Text](https://cdn.mescius.io/document-site-files/images/3c7113e2-10b3-45ed-8f3b-9fb1e0af2b74/pdf/lorem-ipsum-rich-text.png)

## Setting Up the Fill Color
The __fill__ color can be specified in two ways:

By passing a brush directly to __drawText__ as the __options.brush__ property:

```javascript
doc.drawText("Lorem", null, null, {
    brush: new wjPdf.PdfSolidBrush("#ff0000")
});
```

By changing the default document brush using the __doc.setBrush__ method first. This brush will be used if you call __drawText__ method without passing a brush to it:

```javascript
doc.setBrush(new wjPdf.PdfSolidBrush("#ff0000"));
doc.drawText("Lorem");
```
##### Result
![Lorem Red Text](https://cdn.mescius.io/document-site-files/images/3c7113e2-10b3-45ed-8f3b-9fb1e0af2b74/pdf/lorem-red-text.png)


## Setting up the stroke color
Like the __fill__ color, the __stroke__ color can be specified in the same way by passing a pen to the __options.pen__ property or __doc.setPen method__.

```javascript
doc.setPen(new wijmo.Color('#e69500'));
doc.drawText("Lorem", null, null, {
    stroke: true,
    fill: new wijmo.Color('#3173c0')
});

// or
doc.drawText("Lorem", null, null, {
    stroke: true,
    fill: new wijmo.Color('#3173c0'),
    pen: new wijmo.Color('#e69500')
});
```

##### Result
![Lorem Set Pen Example](https://cdn.mescius.io/document-site-files/images/3c7113e2-10b3-45ed-8f3b-9fb1e0af2b74/pdf/lorem-set-pen.png)


For more information about brushes and pens, see the [Drawing Graphics](/wijmo/docs/Topics/PDF/Drawing-Graphics) topic.

__PdfDocument__ doesn't differentiate between text color and vector graphics color, so changing the default document brush or pen affects the vector graphics API too.