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

# ContentStreamBuilder

## Overview

`ContentStreamBuilder` is a class in Aspose.PDF FOSS for .NET.

Builds PDF content stream bytes using the operator syntax from PDF32000 §8-9.

This class provides 49 methods for working with ContentStreamBuilder objects in .NET programs.
Available methods include: `BeginMarkedContent`, `BeginMarkedContentWithProps`, `BeginText`, `Build`, `Clip`, `ClipEvenOdd`, `CloseAndStroke`, `ClosePath`, `CurveTo`, `DrawXObject`, `EndMarkedContent`, `EndPath`, and 33 additional methods.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.

## Methods

| Signature | Description |
|-----------|-------------|
| `SaveState()` | Calls SaveState on this ContentStreamBuilder instance. |
| `RestoreState()` | Calls RestoreState on this ContentStreamBuilder instance. |
| `SetMatrix(a: double, b: double, c: double, d: double, e: double, f: double)` | Sets the matrix value. |
| `SetFillColor(r: double, g: double, b: double)` | Sets the fill color value. |
| `SetFillColor(color: Color)` | Sets the fill color value. |
| `SetStrokeColor(r: double, g: double, b: double)` | Sets the stroke color value. |
| `SetStrokeColor(color: Color)` | Sets the stroke color value. |
| `SetFillGray(gray: double)` | Sets the fill gray value. |
| `SetStrokeGray(gray: double)` | Sets the stroke gray value. |
| `SetLineWidth(width: double)` | Sets the line width value. |
| `SetDashPattern(pattern: double[], phase: double)` | Sets the dash pattern value. |
| `SetLineCap(cap: int)` | Sets the line cap value. |
| `SetLineJoin(join: int)` | Sets the line join value. |
| `MoveTo(x: double, y: double)` | Calls MoveTo on this ContentStreamBuilder instance. |
| `LineTo(x: double, y: double)` | Calls LineTo on this ContentStreamBuilder instance. |
| `CurveTo(x1: double, y1: double, x2: double, y2: double, x3: double, y3: double)` | Calls CurveTo on this ContentStreamBuilder instance. |
| `Rectangle(x: double, y: double, width: double, height: double)` | Calls Rectangle on this ContentStreamBuilder instance. |
| `ClosePath()` | Calls ClosePath on this ContentStreamBuilder instance. |
| `Stroke()` | Calls Stroke on this ContentStreamBuilder instance. |
| `Fill()` | Calls Fill on this ContentStreamBuilder instance. |
| `FillEvenOdd()` | Calls FillEvenOdd on this ContentStreamBuilder instance. |
| `FillAndStroke()` | Calls FillAndStroke on this ContentStreamBuilder instance. |
| `CloseAndStroke()` | Calls CloseAndStroke on this ContentStreamBuilder instance. |
| `EndPath()` | Calls EndPath on this ContentStreamBuilder instance. |
| `Clip()` | Calls Clip on this ContentStreamBuilder instance. |
| `ClipEvenOdd()` | Calls ClipEvenOdd on this ContentStreamBuilder instance. |
| `BeginText()` | Calls BeginText on this ContentStreamBuilder instance. |
| `EndText()` | Calls EndText on this ContentStreamBuilder instance. |
| `SetFont(fontName: string, size: double)` | Sets the font value. |
| `MoveTextPosition(tx: double, ty: double)` | Calls MoveTextPosition on this ContentStreamBuilder instance. |
| `SetTextMatrix(a: double, b: double, c: double, d: double, e: double, f: double)` | Sets the text matrix value. |
| `SetLeading(leading: double)` | Sets the leading value. |
| `NextLine()` | Calls NextLine on this ContentStreamBuilder instance. |
| `SetCharSpacing(spacing: double)` | Sets the char spacing value. |
| `SetWordSpacing(spacing: double)` | Sets the word spacing value. |
| `SetTextRenderingMode(mode: int)` | Sets the text rendering mode value. |
| `ShowText(text: string)` | Calls ShowText on this ContentStreamBuilder instance. |
| `ShowTextBytes(bytes: byte[])` | Show pre-encoded single-byte text. |
| `ShowTextHex(glyphIds: byte[])` | Show text using a hex-encoded string (for CIDFont glyph IDs). |
| `DrawXObject(name: string)` | Calls DrawXObject on this ContentStreamBuilder instance. |
| `SetExtGState(name: string)` | Sets the ext g state value. |
| `BeginMarkedContent(tag: string)` | Calls BeginMarkedContent on this ContentStreamBuilder instance. |
| `BeginMarkedContent(tag: string, mcid: int)` |  |
| `BeginMarkedContentWithProps(tag: string, propsDictInline: string)` | BDC with an inline properties dictionary (already-serialized PDF dict literal). |
| `EndMarkedContent()` | Calls EndMarkedContent on this ContentStreamBuilder instance. |
| `BeginMarkedContent(info: Tagged.MarkedContentInfo)` | Begin a marked content sequence using a MarkedContentInfo from a StructureElementBuilder. |
| `Raw(operatorText: string)` | Calls Raw on this ContentStreamBuilder instance. |
| `Build()` | Build the content stream as a byte array. |
| `ToString()` | Build the content stream as a string. |

## See Also

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