---
Product: Aspose.PDF
Platform: net
Page Type: reference
Canonical URL: https://reference.aspose.org/pdf/net/HtmlFragment
---

# HtmlFragment

## Overview

`HtmlFragment` is a class in Aspose.PDF FOSS for .NET.
Inherits from: `BaseParagraph`.

Represents an HTML content fragment that can be added to PDF pages via HeaderFooter.Paragraphs or Page.Paragraphs.

This class provides 2 methods for working with HtmlFragment objects in .NET programs.
Available methods include: `Clone`, `HtmlFragment`.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: `HorizontalAlignment`, `HtmlContent`, `HtmlLoadOptions`, `Hyperlink`, `HyperlinkText`, `IsBreakWords`, and 10 more.

## Properties

| Name | Type | Access | Description |
|------|------|--------|-------------|
| `IsBreakWords` | `bool` | Read/Write | Whether the HTML loader is allowed to break words at line ends. |
| `IsParagraphHasMargin` | `bool` | Read/Write | Whether the resulting paragraph carries the fragment's own margin. |
| `HtmlContent` | `string?` | Read/Write | The raw HTML content. |
| `HtmlLoadOptions` | `HtmlLoadOptions?` | Read/Write | Options for HTML loading (font embedding, encoding, etc.). |
| `Margin` | `MarginInfo` | Read/Write | Margins for the fragment. |
| `IsInNewPage` | `bool` | Read/Write | Whether this fragment should start on a new page. |
| `IsKeptWithNext` | `bool` | Read/Write | Keep this fragment together with the next paragraph on the same page. |
| `TextState` | `Aspose.Pdf.Text.TextState?` | Read/Write | Default text state applied to the converted HTML output. |
| `Rectangle` | `System.Drawing.RectangleF` | Read | Bounding rectangle of the rendered fragment on the page. |
| `HorizontalAlignment` | `HorizontalAlignment` | Read/Write | Horizontal alignment applied to this paragraph. |
| `VerticalAlignment` | `VerticalAlignment` | Read/Write | Vertical alignment applied to this paragraph. |
| `IsFirstParagraphInColumn` | `bool` | Read/Write | Force the paragraph to start a new column. |
| `IsInLineParagraph` | `bool` | Read/Write | Inline paragraph flag (does not start a new line). |
| `HyperlinkText` | `string?` | Read/Write | Legacy string-typed hyperlink target. |
| `Hyperlink` | `Hyperlink?` | Read/Write | Typed hyperlink decoration applied to the paragraph. |
| `ZIndex` | `int` | Read/Write | Z-order index used by the DOM renderer. |

## Methods

| Signature | Description |
|-----------|-------------|
| `HtmlFragment(text: string)` | Create an HtmlFragment from an HTML string. |
| `Clone()` | Shallow clone — the HTML string and reference-typed properties are shared. |

## See Also

- [Aspose.PDF for .NET — Enterprise API Reference](https://reference.aspose.com/pdf/net/)