{{ title }}

This sample shows how to add text to a page. Read More

Each of the drawing areas provide drawText method to draw text. It takes the following arguments:

For example:

doc.drawText("Lorem.");
doc.drawText("Ipsum.", 0, 30);

Current text coordinates

There is a concept of the current text coordinates, represented by the drawing area's x and y properties. These coordinates are used by the drawText method if positioning arguments are not defined. Each call to the drawText method updates the current text coordinates internally (even if the coordinates were passed into the method explicitly), so, any subsequent text is placed below the previous one.

Use the drawing area's moveDown and moveUp methods to move the Y-coordinate lower or upper with a given number of lines (default = 1).

Wrapping, clipping and alignment

The text is drawn within a rectangular area defined as follows:

The text is wrapped and clipped automatically within the area. If options.height is not defined, then the text will be extended to a new page automatically if it exceeds the bottom edge of the body section.

Use the options.align property to determine how text should be aligned horizontally within the area. The following alignment methods are supported: left (default), center, right, justify.

For example, the following code draws a text within a 300x100 rectangle using current text coordinates and aligns it to the right.

doc.drawText("Lorem", null, null, {
    height: 100,
    width: 300,
    align: wijmo.pdf.PdfTextHorizontalAlign.Right
});

This sample illustrates basic usage of the drawText method.