> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/create/document-creation-api/paragraphs-and-text.md).

# Paragraphs and text

Use the doc creation API to add paragraphs and text.

A `Paragraph` is the basic building block of a document. Its text flows automatically and wraps at the page margins, so you never position text yourself.

## Add a paragraph

`AddParagraph` appends a paragraph to a document, a section, a table cell, a list item, a float or a shape text box. The overload taking a string is a shortcut for adding a paragraph and a single text run.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
doc.AddParagraph("A paragraph is the basic building block of a document. " +
                 "Its text flows automatically and wraps at the page margins.");
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
doc.AddParagraph("A paragraph is the basic building block of a document. "
                 "Its text flows automatically and wraps at the page margins.");
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
doc.AddParagraph("A paragraph is the basic building block of a document. " +
    "Its text flows automatically and wraps at the page margins.")
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
doc.addParagraph("A paragraph is the basic building block of a document. "
        + "Its text flows automatically and wraps at the page margins.");
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
await doc.addParagraphWithText('A paragraph is the basic building block of a document. ' +
    'Its text flows automatically and wraps at the page margins.');
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objectivec
[doc AddParagraphWithText:@"A paragraph is the basic building block of a document. "
                           "Its text flows automatically and wraps at the page margins."];
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$doc->AddParagraph("A paragraph is the basic building block of a document. " .
                   "Its text flows automatically and wraps at the page margins.");
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
doc.AddParagraph("A paragraph is the basic building block of a document. "
                 "Its text flows automatically and wraps at the page margins.")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
doc.AddParagraph("A paragraph is the basic building block of a document. " +
                 "Its text flows automatically and wraps at the page margins.")
```

{% endcode %}
{% endtab %}
{% endtabs %}

<figure><img src="https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2FqV47Hg8H72fQIDL59wFo%2Fparagraph_basic.png?alt=media&amp;token=808bad9f-80a0-4034-9b91-f5e4aefb6e10" alt="an example of a paragraph."><figcaption></figcaption></figure>

## Text runs and character styling

A paragraph contains a sequence of `TextRun` objects. Each run carries its own character style, so mixed formatting is expressed by adding several runs. `AddText` returns the run it created, and `GetTextStyledElement` exposes the style.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
Paragraph para = doc.AddParagraph();

para.AddText("Normal, ");
para.AddText("bold, ").GetTextStyledElement().SetBold(true);
para.AddText("italic, ").GetTextStyledElement().SetItalic(true);

TextRun colored = para.AddText("colored, ");
colored.GetTextStyledElement().SetTextColor(0, 102, 204);

TextRun highlighted = para.AddText("highlighted");
highlighted.GetTextStyledElement().SetBackgroundColor(255, 245, 180);

para.AddText(" and ");
TextRun big = para.AddText("larger");
big.GetTextStyledElement().SetFontSize(18);
para.AddText(" text runs.");
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
Paragraph para = doc.AddParagraph();

para.AddText("Normal, ");
para.AddText("bold, ").GetTextStyledElement().SetBold(true);
para.AddText("italic, ").GetTextStyledElement().SetItalic(true);

TextRun colored = para.AddText("colored, ");
colored.GetTextStyledElement().SetTextColor(0, 102, 204);

TextRun highlighted = para.AddText("highlighted");
highlighted.GetTextStyledElement().SetBackgroundColor(255, 245, 180);

para.AddText(" and ");
TextRun big = para.AddText("larger");
big.GetTextStyledElement().SetFontSize(18);
para.AddText(" text runs.");
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
para := doc.AddParagraph()

para.AddText("Normal, ")
para.AddText("bold, ").GetTextStyledElement().SetBold(true)
para.AddText("italic, ").GetTextStyledElement().SetItalic(true)

colored := para.AddText("colored, ")
colored.GetTextStyledElement().SetTextColor(0, 102, 204)

highlighted := para.AddText("highlighted")
highlighted.GetTextStyledElement().SetBackgroundColor(255, 245, 180)

para.AddText(" and ")
big := para.AddText("larger")
big.GetTextStyledElement().SetFontSize(18)
para.AddText(" text runs.")
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
Paragraph para = doc.addParagraph();

para.addText("Normal, ");
para.addText("bold, ").getTextStyledElement().setBold(true);
para.addText("italic, ").getTextStyledElement().setItalic(true);

TextRun colored = para.addText("colored, ");
colored.getTextStyledElement().setTextColor(0, 102, 204);

TextRun highlighted = para.addText("highlighted");
highlighted.getTextStyledElement().setBackgroundColor(255, 245, 180);

para.addText(" and ");
TextRun big = para.addText("larger");
big.getTextStyledElement().setFontSize(18);
para.addText(" text runs.");
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
const para = await doc.addParagraph();

await para.addText('Normal, ');
(await (await para.addText('bold, ')).getTextStyledElement()).setBold(true);
(await (await para.addText('italic, ')).getTextStyledElement()).setItalic(true);

const colored = await para.addText('colored, ');
(await colored.getTextStyledElement()).setTextColor(0, 102, 204);

const highlighted = await para.addText('highlighted');
(await highlighted.getTextStyledElement()).setBackgroundColor(255, 245, 180);

await para.addText(' and ');
const big = await para.addText('larger');
(await big.getTextStyledElement()).setFontSize(18);
await para.addText(' text runs.');
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objectivec
PTParagraph* para = [doc AddParagraph];

[para AddText:@"Normal, "];
[[[para AddText:@"bold, "] GetTextStyledElement] SetBold:YES];
[[[para AddText:@"italic, "] GetTextStyledElement] SetItalic:YES];

PTTextRun* colored = [para AddText:@"colored, "];
[[colored GetTextStyledElement] SetTextColor:0 green:102 blue:204];

PTTextRun* highlighted = [para AddText:@"highlighted"];
[[highlighted GetTextStyledElement] SetBackgroundColor:255 green:245 blue:180];

[para AddText:@" and "];
PTTextRun* big = [para AddText:@"larger"];
[[big GetTextStyledElement] SetFontSize:18];
[para AddText:@" text runs."];
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$para = $doc->AddParagraph();

$para->AddText("Normal, ");
$para->AddText("bold, ")->GetTextStyledElement()->SetBold(true);
$para->AddText("italic, ")->GetTextStyledElement()->SetItalic(true);

$colored = $para->AddText("colored, ");
$colored->GetTextStyledElement()->SetTextColor(0, 102, 204);

$highlighted = $para->AddText("highlighted");
$highlighted->GetTextStyledElement()->SetBackgroundColor(255, 245, 180);

$para->AddText(" and ");
$big = $para->AddText("larger");
$big->GetTextStyledElement()->SetFontSize(18);
$para->AddText(" text runs.");
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
para = doc.AddParagraph()

para.AddText("Normal, ")
para.AddText("bold, ").GetTextStyledElement().SetBold(True)
para.AddText("italic, ").GetTextStyledElement().SetItalic(True)

colored = para.AddText("colored, ")
colored.GetTextStyledElement().SetTextColor(0, 102, 204)

highlighted = para.AddText("highlighted")
highlighted.GetTextStyledElement().SetBackgroundColor(255, 245, 180)

para.AddText(" and ")
big = para.AddText("larger")
big.GetTextStyledElement().SetFontSize(18)
para.AddText(" text runs.")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
para = doc.AddParagraph()

para.AddText("Normal, ")
para.AddText("bold, ").GetTextStyledElement().SetBold(true)
para.AddText("italic, ").GetTextStyledElement().SetItalic(true)

colored = para.AddText("colored, ")
colored.GetTextStyledElement().SetTextColor(0, 102, 204)

highlighted = para.AddText("highlighted")
highlighted.GetTextStyledElement().SetBackgroundColor(255, 245, 180)

para.AddText(" and ")
big = para.AddText("larger")
big.GetTextStyledElement().SetFontSize(18)
para.AddText(" text runs.")
```

{% endcode %}
{% endtab %}
{% endtabs %}

<figure><img src="https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2F6m8PbN4Sba1rvaOFeNuD%2Fparagraph_text_runs.png?alt=media&amp;token=cc8825b6-82de-47fc-b0d2-4d46e47bf11c" alt="An example of types of text like highlight, italics, bold."><figcaption></figcaption></figure>

Setting the style on the paragraph instead of a run establishes the default for everything the paragraph contains.

## Justification

`SetJustificationMode` accepts a left (the default), center, or right justification value.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
Paragraph left = doc.AddParagraph("Left: The quick brown fox ...");
left.SetJustificationMode(Paragraph.TextJustification.e_left);

Paragraph center = doc.AddParagraph("Center: The quick brown fox ...");
center.SetJustificationMode(Paragraph.TextJustification.e_center);

Paragraph right = doc.AddParagraph("Right: The quick brown fox ...");
right.SetJustificationMode(Paragraph.TextJustification.e_right);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
Paragraph left = doc.AddParagraph("Left: The quick brown fox ...");
left.SetJustificationMode(Paragraph::e_text_justify_left);

Paragraph center = doc.AddParagraph("Center: The quick brown fox ...");
center.SetJustificationMode(Paragraph::e_text_justify_center);

Paragraph right = doc.AddParagraph("Right: The quick brown fox ...");
right.SetJustificationMode(Paragraph::e_text_justify_right);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
left := doc.AddParagraph("Left: The quick brown fox ...")
left.SetJustificationMode(ParagraphE_text_justify_left)

center := doc.AddParagraph("Center: The quick brown fox ...")
center.SetJustificationMode(ParagraphE_text_justify_center)

right := doc.AddParagraph("Right: The quick brown fox ...")
right.SetJustificationMode(ParagraphE_text_justify_right)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
Paragraph left = doc.addParagraph("Left: The quick brown fox ...");
left.setJustificationMode(Paragraph.TextJustification.e_text_justify_left);

Paragraph center = doc.addParagraph("Center: The quick brown fox ...");
center.setJustificationMode(Paragraph.TextJustification.e_text_justify_center);

Paragraph right = doc.addParagraph("Right: The quick brown fox ...");
right.setJustificationMode(Paragraph.TextJustification.e_text_justify_right);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
const left = await doc.addParagraphWithText('Left: The quick brown fox ...');
left.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_left);

const center = await doc.addParagraphWithText('Center: The quick brown fox ...');
center.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_center);

const right = await doc.addParagraphWithText('Right: The quick brown fox ...');
right.setJustificationMode(PDFNet.Paragraph.TextJustification.e_text_justify_right);
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objectivec
PTParagraph* left = [doc AddParagraphWithText:@"Left: The quick brown fox ..."];
[left SetJustificationMode:e_ptpara_text_justify_left];

PTParagraph* center = [doc AddParagraphWithText:@"Center: The quick brown fox ..."];
[center SetJustificationMode:e_ptpara_text_justify_center];

PTParagraph* right = [doc AddParagraphWithText:@"Right: The quick brown fox ..."];
[right SetJustificationMode:e_ptpara_text_justify_right];
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$left = $doc->AddParagraph("Left: The quick brown fox ...");
$left->SetJustificationMode(Paragraph::e_text_justify_left);

$center = $doc->AddParagraph("Center: The quick brown fox ...");
$center->SetJustificationMode(Paragraph::e_text_justify_center);

$right = $doc->AddParagraph("Right: The quick brown fox ...");
$right->SetJustificationMode(Paragraph::e_text_justify_right);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
left = doc.AddParagraph("Left: The quick brown fox ...")
left.SetJustificationMode(Paragraph.e_text_justify_left)

center = doc.AddParagraph("Center: The quick brown fox ...")
center.SetJustificationMode(Paragraph.e_text_justify_center)

right = doc.AddParagraph("Right: The quick brown fox ...")
right.SetJustificationMode(Paragraph.e_text_justify_right)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
left = doc.AddParagraph("Left: The quick brown fox ...")
left.SetJustificationMode(Paragraph::E_text_justify_left)

center = doc.AddParagraph("Center: The quick brown fox ...")
center.SetJustificationMode(Paragraph::E_text_justify_center)

right = doc.AddParagraph("Right: The quick brown fox ...")
right.SetJustificationMode(Paragraph::E_text_justify_right)
```

{% endcode %}
{% endtab %}
{% endtabs %}

<figure><img src="https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2FW1QC4xabDdo2yxoE7Fz1%2Fparagraph_justification.png?alt=media&amp;token=01f35a92-e40d-4fac-8ff1-b371cfacf8e7" alt="Example of justification."><figcaption></figcaption></figure>

## Indents, spacing, and borders

`SetTextIndent` indents only the first line, while `SetStartIndent` and `SetEndIndent` indent the whole block. `SetSpaceBefore` and `SetSpaceAfter` add vertical space, and `SetBorder` draws a frame around the paragraph.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// First-line indent.
Paragraph firstLine = doc.AddParagraph(text);
firstLine.SetTextIndent(24);
firstLine.SetSpaceAfter(10);

// Whole block indented from both sides.
Paragraph indented = doc.AddParagraph(text);
indented.SetStartIndent(36);
indented.SetEndIndent(36);
indented.SetSpaceAfter(10);

// Framed paragraph.
Paragraph bordered = doc.AddParagraph(text);
bordered.SetBorder(1, 0, 51, 102);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// First-line indent.
Paragraph first_line = doc.AddParagraph(text);
first_line.SetTextIndent(24);
first_line.SetSpaceAfter(10);

// Whole block indented from both sides.
Paragraph indented = doc.AddParagraph(text);
indented.SetStartIndent(36);
indented.SetEndIndent(36);
indented.SetSpaceAfter(10);

// Framed paragraph.
Paragraph bordered = doc.AddParagraph(text);
bordered.SetBorder(1, 0, 51, 102);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
// First-line indent.
firstLine := doc.AddParagraph(text)
firstLine.SetTextIndent(24)
firstLine.SetSpaceAfter(10)

// Whole block indented from both sides.
indented := doc.AddParagraph(text)
indented.SetStartIndent(36)
indented.SetEndIndent(36)
indented.SetSpaceAfter(10)

// Framed paragraph.
bordered := doc.AddParagraph(text)
bordered.SetBorder(1, 0, 51, 102)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// First-line indent.
Paragraph firstLine = doc.addParagraph(text);
firstLine.setTextIndent(24);
firstLine.setSpaceAfter(10);

// Whole block indented from both sides.
Paragraph indented = doc.addParagraph(text);
indented.setStartIndent(36);
indented.setEndIndent(36);
indented.setSpaceAfter(10);

// Framed paragraph.
Paragraph bordered = doc.addParagraph(text);
bordered.setBorder(1, 0, 51, 102);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
// First-line indent.
const firstLine = await doc.addParagraphWithText(text);
firstLine.setTextIndent(24);
firstLine.setSpaceAfter(10);

// Whole block indented from both sides.
const indented = await doc.addParagraphWithText(text);
indented.setStartIndent(36);
indented.setEndIndent(36);
indented.setSpaceAfter(10);

// Framed paragraph.
const bordered = await doc.addParagraphWithText(text);
bordered.setBorder(1, 0, 51, 102);
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objectivec
// First-line indent.
PTParagraph* first_line = [doc AddParagraphWithText:text];
[first_line SetTextIndent:24];
[first_line SetSpaceAfter:10];

// Whole block indented from both sides.
PTParagraph* indented = [doc AddParagraphWithText:text];
[indented SetStartIndent:36];
[indented SetEndIndent:36];
[indented SetSpaceAfter:10];

// Framed paragraph.
PTParagraph* bordered = [doc AddParagraphWithText:text];
[bordered SetBorder:1 red:0 green:51 blue:102];
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
// First-line indent.
$first_line = $doc->AddParagraph($text);
$first_line->SetTextIndent(24);
$first_line->SetSpaceAfter(10);

// Whole block indented from both sides.
$indented = $doc->AddParagraph($text);
$indented->SetStartIndent(36);
$indented->SetEndIndent(36);
$indented->SetSpaceAfter(10);

// Framed paragraph.
$bordered = $doc->AddParagraph($text);
$bordered->SetBorder(1, 0, 51, 102);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
# First-line indent.
first_line = doc.AddParagraph(text)
first_line.SetTextIndent(24)
first_line.SetSpaceAfter(10)

# Whole block indented from both sides.
indented = doc.AddParagraph(text)
indented.SetStartIndent(36)
indented.SetEndIndent(36)
indented.SetSpaceAfter(10)

# Framed paragraph.
bordered = doc.AddParagraph(text)
bordered.SetBorder(1, 0, 51, 102)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
# First-line indent.
first_line = doc.AddParagraph(text)
first_line.SetTextIndent(24)
first_line.SetSpaceAfter(10)

# Whole block indented from both sides.
indented = doc.AddParagraph(text)
indented.SetStartIndent(36)
indented.SetEndIndent(36)
indented.SetSpaceAfter(10)

# Framed paragraph.
bordered = doc.AddParagraph(text)
bordered.SetBorder(1, 0, 51, 102)
```

{% endcode %}
{% endtab %}
{% endtabs %}

<figure><img src="https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2FZ20fpZyOIRGS5XpOgOyr%2Fparagraph_indents.png?alt=media&amp;token=08e1644f-3b6d-45e3-99b5-7cd565056493" alt="Example of spacing and borders around text."><figcaption></figcaption></figure>

{% hint style="info" %}
**Info**

`SetStartIndent` and `SetEndIndent` are writing-direction aware. In a right-to-left paragraph the start indent applies to the right edge.
{% endhint %}

## Tab stops

Tab stops align columns of text without the overhead of a table. Add explicit stops with `AddTabStop`, or set a repeating interval with `SetDefaultTabStop`.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
Paragraph para = doc.AddParagraph();
para.AddTabStop(70);
para.AddText("Apr 02\tBuilding documents from scratch");
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
Paragraph para = doc.AddParagraph();
para.AddTabStop(70);
para.AddText("Apr 02\tBuilding documents from scratch");
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
para := doc.AddParagraph()
para.AddTabStop(70)
para.AddText("Apr 02\tBuilding documents from scratch")
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
Paragraph para = doc.addParagraph();
para.addTabStop(70);
para.addText("Apr 02\tBuilding documents from scratch");
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
const para = await doc.addParagraph();
para.addTabStop(70);
await para.addText('Apr 02\tBuilding documents from scratch');
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objectivec
PTParagraph* para = [doc AddParagraph];
[para AddTabStop:70];
[para AddText:@"Apr 02\tBuilding documents from scratch"];
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$para = $doc->AddParagraph();
$para->AddTabStop(70);
$para->AddText("Apr 02\tBuilding documents from scratch");
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
para = doc.AddParagraph()
para.AddTabStop(70)
para.AddText("Apr 02\tBuilding documents from scratch")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
para = doc.AddParagraph()
para.AddTabStop(70)
para.AddText("Apr 02\tBuilding documents from scratch")
```

{% endcode %}
{% endtab %}
{% endtabs %}

<figure><img src="https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2Ffh78Ek1ju1IbxDSEvIyO%2Fparagraph_tab_stops.png?alt=media&amp;token=abf04f87-57b4-45c4-a892-456ccdec67c5" alt="Example of tabbing with text."><figcaption></figcaption></figure>

Use a table instead when the columns need borders, shading, or cells that wrap onto several lines.

## Hyperlinks

`AddHyperlink` creates a text run with a link target attached. The visual styling is up to you. Links are not colored or underlined automatically.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
Paragraph para = doc.AddParagraph();
para.AddText("Read more about the API at ");

TextRun link = para.AddHyperlink("apryse.com", "https://www.apryse.com");
link.GetTextStyledElement().SetTextColor(0, 102, 204);

para.AddText(".");
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
Paragraph para = doc.AddParagraph();
para.AddText("Read more about the API at ");

TextRun link = para.AddHyperlink("apryse.com", "https://www.apryse.com");
link.GetTextStyledElement().SetTextColor(0, 102, 204);

para.AddText(".");
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
para := doc.AddParagraph()
para.AddText("Read more about the API at ")

link := para.AddHyperlink("apryse.com", "https://www.apryse.com")
link.GetTextStyledElement().SetTextColor(0, 102, 204)

para.AddText(".")
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
Paragraph para = doc.addParagraph();
para.addText("Read more about the API at ");

TextRun link = para.addHyperlink("apryse.com", "https://www.apryse.com");
link.getTextStyledElement().setTextColor(0, 102, 204);

para.addText(".");
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
const para = await doc.addParagraph();
await para.addText('Read more about the API at ');

const link = await para.addHyperlink('apryse.com', 'https://www.apryse.com');
(await link.getTextStyledElement()).setTextColor(0, 102, 204);

await para.addText('.');
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objectivec
PTParagraph* para = [doc AddParagraph];
[para AddText:@"Read more about the API at "];

PTTextRun* link = [para AddHyperlink:@"apryse.com" url:@"https://www.apryse.com"];
[[link GetTextStyledElement] SetTextColor:0 green:102 blue:204];

[para AddText:@"."];
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$para = $doc->AddParagraph();
$para->AddText("Read more about the API at ");

$link = $para->AddHyperlink("apryse.com", "https://www.apryse.com");
$link->GetTextStyledElement()->SetTextColor(0, 102, 204);

$para->AddText(".");
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
para = doc.AddParagraph()
para.AddText("Read more about the API at ")

link = para.AddHyperlink("apryse.com", "https://www.apryse.com")
link.GetTextStyledElement().SetTextColor(0, 102, 204)

para.AddText(".")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
para = doc.AddParagraph()
para.AddText("Read more about the API at ")

link = para.AddHyperlink("apryse.com", "https://www.apryse.com")
link.GetTextStyledElement().SetTextColor(0, 102, 204)

para.AddText(".")
```

{% endcode %}
{% endtab %}
{% endtabs %}

<figure><img src="https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2Fn3BHNHbjN00ig0WSHwIL%2Fparagraph_hyperlink.png?alt=media&amp;token=faf80717-d2b3-4a36-850a-9a1dd2153b1c" alt="Example of a hyperlink with text."><figcaption></figcaption></figure>

An existing run can be turned into a link with `SetHyperlinkTarget`.

## Line breaks

A `\n` inside a text run forces a line break without starting a new paragraph, which is convenient for addresses and similar blocks.

{% tabs %}
{% tab title="C#" %}

```csharp
doc.AddParagraph("Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1");
```

{% endtab %}

{% tab title="C++" %}

```cpp
doc.AddParagraph("Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1");
```

{% endtab %}

{% tab title="Go" %}

```go
doc.AddParagraph("Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1")
```

{% endtab %}

{% tab title="Java" %}

```java
doc.addParagraph("Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1");
```

{% endtab %}

{% tab title="JavaScript" %}
{% code overflow="wrap" %}

```javascript
await doc.addParagraphWithText('Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1');
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code overflow="wrap" %}

```objectivec
[doc AddParagraphWithText:@"Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1"];
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code overflow="wrap" %}

```php
$doc->AddParagraph("Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1");
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
doc.AddParagraph("Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1")
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
doc.AddParagraph("Contoso Ltd.\n123 Maple Street\nVancouver, BC V6B 1A1")
```

{% endtab %}
{% endtabs %}

## Further Reading

* [Lists](/core/create/document-creation-api/lists.md) for automatically numbered paragraphs.
* [Tables](/core/create/document-creation-api/tables.md) for column layouts that need borders and shading.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/create/document-creation-api/paragraphs-and-text.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
