Skip to content

# PDFFormattedContent

Namespace: O2S.Components.PDF4NET.Graphics.FormattedContent

Defines a piece of formatted content that can be drawn on a page.

    public class PDFFormattedContent

Inheritance Object → PDFFormattedContent

## Constructors

### PDFFormattedContent()

Initializes a new PDFFormattedContent object.

    public PDFFormattedContent()

### PDFFormattedContent(String)

Initializes a new PDFFormattedContent object with a text paragraph.

    public PDFFormattedContent(string text)

Parameters

`text` String
Paragraph text.

### PDFFormattedContent(String, PDFFont)

Initializes a new PDFFormattedContent object with a text paragraph.

    public PDFFormattedContent(string text, PDFFont font)

Parameters

`text` String
Paragraph text.

`font` PDFFont
Paragraph font

### PDFFormattedContent(PDFFormattedContent)

Initializes a new PDFFormattedContent object with another formatted content.

    public PDFFormattedContent(PDFFormattedContent source)

Parameters

`source` PDFFormattedContent
Source content

## Properties

### Height

Gets the height of the formatted content.

    public double Height { get; }

Property Value

Double
The height of the formatted content wrapped at a specific width.

Remarks

The PDFFormattedContent.Wrap(Double) method must be called before reading this property. This property can also be read after the formatted content has been drawn on the page.

### ParagraphHeights

Gets the height of each paragraph in the formatted content.

    public Double[] ParagraphHeights { get; }

Property Value

Double[]
The height of each paragraph in the formatted content wrapped at a specific width.

Remarks

The PDFFormattedContent.Wrap(Double) method must be called before reading this property. This property can also be read after the formatted content has been drawn on the page.

### Paragraphs

Gets the list of paragraphs.

    public PDFFormattedParagraphCollection Paragraphs { get; }

Property Value

PDFFormattedParagraphCollection
The list of paragraphs that compose this formatted piece of content.

### StructureElement

Gets or sets the structure element.

    public PDFStructureElement StructureElement { get; set; }

Property Value

PDFStructureElement
The PDFStructureElement object associated with this formatted content object.

Remarks

When a formatted content object has an associated structure element, the paragraphs within the formatted content should not have their own structure elements otherwise the content will be tagged incorrectly.

### Width

Gets the width of the formatted content.

    public double Width { get; }

Property Value

Double
The actual width of the formatted content after is has been wrapped at a given width.

Remarks

The PDFFormattedContent.Wrap(Double) method must be called before reading this property. This property can also be read after the formatted content has been drawn on the page.

## Methods

### ClearWordWrapState()

Clears the internal word wrap state.

    public void ClearWordWrapState()

Remarks

This method must be called before re-drawing the PDFFormattedContent object if its content has changed.

### SplitByBox(Double, Double)

Gets the formatted content that fits in the given box.

    public PDFFormattedContent SplitByBox(double width, double height)

Parameters

`width` Double
The box width.

`height` Double
The box height.

Returns

PDFFormattedContent
The formatted content that fits in the given box.

Remarks

This method modifies the current object, the formatted content that fits the given box is removed from current object and returned as a new object.

### SplitByBox(Double, Double, Boolean)

Gets the formatted content that fits in the given box.

    public PDFFormattedContent SplitByBox(double width, double height, bool updateParagraphs)

Parameters

`width` Double
The box width.

`height` Double
The box height.

`updateParagraphs` Boolean
If true, the list of paragraphs is also updated to reflect the split.

Returns

PDFFormattedContent
The formatted content that fits in the given box.

Remarks

This method modifies the current object, the formatted content that fits the given box is removed from current object and returned as a new object.
If this method is called multiple times but with a different width then the 'updateParagraphs' parameter should be set to true.

### ToString()

Converts the object to string.

    public string ToString()

Returns

String

### Wrap(Double)

Executes a wrap operation on the formatted content at the specified width.

    public void Wrap(double width)

Parameters

`width` Double
The width at which the formatted content is wrapped.