# PDF 리치 텍스트

## Content

**PdfDocument**에서는 텍스트에 색상을 채울 수 있습니다. 또한, 텍스트를 선으로 그리거나, 채우고 선을 동시에 적용할 수 있습니다.

**drawText**'s 의 options 인수에는 **fill**과 **stroke** 속성이 있습니다. 기본적으로 텍스트는 채워지도록 설정되어 있으므로, 이 속성들을 비워두면 텍스트가 채워진다는 의미입니다. **stroke**를 true로 설정하면 텍스트가 선으로 그려지게 되고, **fill**과 **stroke**를 모두 true로 설정하면 텍스트가 채워지고 선이 동시에 적용됩니다.

**drawText** 를 호출할 때마다 새로운 단락이 시작됩니다. 이후 텍스트가 이전 텍스트 바로 아래에 배치되도록 하려면, options 인수의 continued 속성을 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
    }
);
```

##### 결과

![Lorem Ipsum Rich Text](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/4153b498-0e9e-452c-b1b8-6a8130043972/pdf/lorem-ipsum-rich-text.png)

## 채우기 색상 설정

**fill** 색상은 두 가지 방법으로 설정할 수 있습니다:

브러시를 직접 **drawText** 의 **options.brush** 속성으로 전달하기:

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

**doc.setBrush** 메서드를 사용하여 기본 문서 브러시를 변경하기. 이렇게 설정된 브러시는 **drawText** 메서드를 호출할 때 브러시를 전달하지 않으면 자동으로 사용됩니다.

```javascript
doc.setBrush(new wjPdf.PdfSolidBrush("#ff0000"));
doc.drawText("Lorem");
```

##### 결과

![Lorem Red Text](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/4153b498-0e9e-452c-b1b8-6a8130043972/pdf/lorem-red-text.png)

## 선 색상 설정

**fill** 색상과 마찬가지로, **stroke** 색상은 동일한 방법으로 설정할 수 있습니다. **options.pen** 속성에 펜을 전달하거나 **doc.setPen** 메서드를 사용하여 설정할 수 있습니다.

```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')
});
```

##### 결과

![Lorem Set Pen Example](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/4153b498-0e9e-452c-b1b8-6a8130043972/pdf/lorem-set-pen.png)
브러시와 펜에 대한 자세한 정보는 **[그래픽 그리기](https://demo.mescius.co.kr/wijmo/docs/Topics/PDF/Drawing-Graphics)** 주제를 참조해주세요.

**PdfDocument** 는 텍스트 색상과 벡터 그래픽 색상을 구분하지 않으므로, 기본 문서 브러시나 펜을 변경하면 벡터 그래픽 API에도 영향을 미칩니다.