# PdfTextSpan

A piece of text extracted from a PDF page with basic font and position info.

Class 

`OfficeIMO.Pdf`

**Namespace**

`OfficeIMO.Pdf`

**Assembly**

`OfficeIMO.Pdf`

**Source revision**

`be6c300e4ab1` with working tree changes

**Source**

[PdfTextSpan.cs:211](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L211)

**Modifiers**

sealed

A piece of text extracted from a PDF page with basic font and position info. Coordinates are in the page's native user-space units as emitted by content stream Tm/Td.

## Inheritance

- object
- PdfTextSpan

## Remarks

Native page coordinates use default user-space units: one unit is /UserUnit physical points (1/72 inch each), defaulting to 1. Local text/font and matrix values retain their native coordinate spaces. Explicit visual projections use their documented coordinates.

## Usage

Explore 10 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 8

- Method [IPdfGlyphDecodingStage.Decode](/api/pdf/officeimo-pdf-ipdfglyphdecodingstage/#method-decode-officeimo-pdf-pdfunderstandingpagecontext)
- Property [PdfLogicalTextBlock.Spans](/api/pdf/officeimo-pdf-pdflogicaltextblock/#property-spans)
- Property [PdfLogicalTextRun.SourceSpan](/api/pdf/officeimo-pdf-pdflogicaltextrun/#property-sourcespan)
- Method [PdfReadPage.GetTextSpans](/api/pdf/officeimo-pdf-pdfreadpage/#method-gettextspans)
- Property [PdfRegionText.Spans](/api/pdf/officeimo-pdf-pdfregiontext/#property-spans)
- Property [PdfStructuredLine.Spans](/api/pdf/officeimo-pdf-pdfstructuredline/#property-spans)
- Property [PdfUnderstandingPageResult.DecodedRuns](/api/pdf/officeimo-pdf-pdfunderstandingpageresult/#property-decodedruns)
- Property [PdfUnderstandingWord.SourceRuns](/api/pdf/officeimo-pdf-pdfunderstandingword/#property-sourceruns)

### Accepted by parameters 2

- Method [IPdfWordGroupingStage.GroupWords](/api/pdf/officeimo-pdf-ipdfwordgroupingstage/#method-groupwords-officeimo-pdf-pdfunderstandingpagecontext-collections-generic-ireadonlylist-officeimo-pdf-pdftextspan) parameter `runs`
- Constructor [PdfUnderstandingWord.PdfUnderstandingWord](/api/pdf/officeimo-pdf-pdfunderstandingword/#constructor-ctor-string-double-double-double-double-double-collections-generic-ireadonlylist-officeimo-pdf-pdftextspan-double-collections-generic-ienumerable-officeimo-pdf-pdfinferenceevidence-nullable-system-double-officeimo-pdf-pdflogicalvisualbounds-nullable-system-int32) parameter `sourceRuns`

Filter members 

Show inherited

## Constructors

PdfTextSpan 2 overloads

`public PdfTextSpan(string text, string fontResource, double fontSize, double x, double y, double advance = 0, OfficeColor? color = null, bool isVisible = true, double rotationDegrees = 0, string? baseFont = null)` [#](#constructor-ctor-string-string-double-double-double-double-nullable-officeimo-officecolor-boolean-double-string)

[PdfTextSpan.cs:211](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L211)

Creates a new text span.

Parameters

**text string required**

**fontResource string required**

**fontSize double required**

**x double required**

**y double required**

**advance double = 0 optional**

**color OfficeIMO.OfficeColor? = null optional**

**isVisible bool = true optional**

**rotationDegrees double = 0 optional**

**baseFont string? = null optional**

`public PdfTextSpan(string text, string fontResource, double fontSize, double x, double y, double advance, OfficeColor? color, bool isVisible, double rotationDegrees, string? baseFont, int? fontWeight, int? fontDescriptorFlags)` [#](#constructor-ctor-string-string-double-double-double-double-nullable-officeimo-officecolor-boolean-double-string-nullable-system-int32-nullable-system-int32)

[PdfTextSpan.cs:241](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L241)

Creates a new text span with explicit PDF font descriptor style evidence.

Parameters

**text string required**

**fontResource string required**

**fontSize double required**

**x double required**

**y double required**

**advance double required**

**color OfficeIMO.OfficeColor? required**

**isVisible bool required**

**rotationDegrees double required**

**baseFont string? required**

**fontWeight int? required**

**fontDescriptorFlags int? required**

## Methods

`public bool TryGetGlyphs(out IReadOnlyList<PdfTextGlyph> glyphs)` [#](#method-trygetglyphs-collections-generic-ireadonlylist-officeimo-pdf-pdftextglyph)

[PdfTextSpan.Glyphs.cs:12](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.Glyphs.cs#L12)

Projects the reader's glyph codes, text ranges and baseline origins into immutable evidence. Returns false with an empty list when glyph evidence is unavailable or the logical text cannot be mapped to painted glyphs, including ambiguous ActualText replacements. The origins describe the baseline; they are not exact glyph outlines or clipping bounds.

Parameters

**glyphs System.Collections.Generic.IReadOnlyList<OfficeIMO.Pdf.PdfTextGlyph> required**

Returns

`bool`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public string Text { get; }` [#](#property-text)

[PdfTextSpan.cs:11](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L11)

Text content of the span.

`public PdfTextDecodingEvidence DecodingEvidence { get; private set; }` [#](#property-decodingevidence)

[PdfTextSpan.cs:13](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L13)

Immutable evidence describing the mapping used for this native text run.

`public string FontResource { get; }` [#](#property-fontresource)

[PdfTextSpan.cs:16](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L16)

Font resource name from the page resources (e.g., F1).

`public string? BaseFont { get; }` [#](#property-basefont)

[PdfTextSpan.cs:18](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L18)

PDF base font name resolved from the active resource dictionary, when available.

`public int? FontWeight { get; }` [#](#property-fontweight)

[PdfTextSpan.cs:20](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L20)

Font descriptor weight from 1 through 1000, when declared by the PDF.

`public int? FontDescriptorFlags { get; }` [#](#property-fontdescriptorflags)

[PdfTextSpan.cs:22](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L22)

Raw PDF font descriptor flags, when declared by the PDF.

`public bool IsBold { get; }` [#](#property-isbold)

[PdfTextSpan.cs:24](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L24)

True when declared weight or legacy font-name evidence identifies a bold face.

`public bool IsItalic { get; }` [#](#property-isitalic)

[PdfTextSpan.cs:26](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L26)

True when descriptor flags or legacy font-name evidence identifies an italic face.

`public double FontSize { get; private set; }` [#](#property-fontsize)

[PdfTextSpan.cs:28](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L28)

Font size in points.

`public double X { get; }` [#](#property-x)

[PdfTextSpan.cs:30](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L30)

X position (points) in page user space.

`public double Y { get; }` [#](#property-y)

[PdfTextSpan.cs:32](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L32)

Y position (points) in page user space.

`public double Advance { get; }` [#](#property-advance)

[PdfTextSpan.cs:34](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L34)

Advance width in user space for this span (includes spacing and hscale).

`public OfficeColor? Color { get; }` [#](#property-color)

[PdfTextSpan.cs:76](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L76)

Fill color used for visual text rendering, when it could be read from the content stream.

`public bool IsVisible { get; }` [#](#property-isvisible)

[PdfTextSpan.cs:82](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L82)

True when the text span should be painted during visual rendering.

`public double RotationDegrees { get; }` [#](#property-rotationdegrees)

[PdfTextSpan.cs:84](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L84)

Baseline rotation in PDF user-space degrees, where positive angles are counter-clockwise.

`public int? MarkedContentId { get; }` [#](#property-markedcontentid)

[PdfTextSpan.cs:86](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L86)

Active content-stream-scoped marked-content identifier from a tagged PDF, when present.

`public int? ContentStreamObjectNumber { get; }` [#](#property-contentstreamobjectnumber)

[PdfTextSpan.cs:88](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L88)

Form XObject or other content-stream object owning the MCID, or null for page content.

`public int TextRenderingMode { get; }` [#](#property-textrenderingmode)

[PdfTextSpan.cs:119](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L119)

PDF text rendering mode active for this span (0 through 7).

`public bool HasActualText { get; }` [#](#property-hasactualtext)

[PdfTextSpan.cs:165](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L165)

True when marked-content ActualText replaced the logical text.

`public bool IsArtifactContent { get; }` [#](#property-isartifactcontent)

[PdfTextSpan.cs:198](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Pdf/Reading/Text/PdfTextSpan.cs#L198)

True when this span came from PDF content explicitly marked as an /Artifact.

<!-- PowerForge markdown artifact sha256:41885E95D1881160DEB026D187C4760B31C0BBAE7C523B56EDDDBF5CDD7C5B7D -->
