PdfTextSpan
OfficeIMO.Pdf
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
- Property PdfLogicalTextBlock.Spans
- Property PdfLogicalTextRun.SourceSpan
- Method PdfReadPage.GetTextSpans
- Property PdfRegionText.Spans
- Property PdfStructuredLine.Spans
- Property PdfUnderstandingPageResult.DecodedRuns
- Property PdfUnderstandingWord.SourceRuns
Accepted by parameters 2
- Method IPdfWordGroupingStage.GroupWords
- Constructor PdfUnderstandingWord.PdfUnderstandingWord
Constructors
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) #Creates a new text span.
Parameters
- text string
- fontResource string
- fontSize double
- x double
- y double
- advance double = 0
- color OfficeIMO.OfficeColor? = null
- isVisible bool = true
- rotationDegrees double = 0
- baseFont string? = null
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) #Creates a new text span with explicit PDF font descriptor style evidence.
Parameters
- text string
- fontResource string
- fontSize double
- x double
- y double
- advance double
- color OfficeIMO.OfficeColor?
- isVisible bool
- rotationDegrees double
- baseFont string?
- fontWeight int?
- fontDescriptorFlags int?
Methods
public bool TryGetGlyphs(out IReadOnlyList<PdfTextGlyph> glyphs) #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>
Returns
boolInherited Methods
Properties
public PdfTextDecodingEvidence DecodingEvidence { get; private set; } #Immutable evidence describing the mapping used for this native text run.
public string FontResource { get; } #Font resource name from the page resources (e.g., F1).
public string? BaseFont { get; } #PDF base font name resolved from the active resource dictionary, when available.
public int? FontWeight { get; } #Font descriptor weight from 1 through 1000, when declared by the PDF.
public int? FontDescriptorFlags { get; } #Raw PDF font descriptor flags, when declared by the PDF.
public bool IsBold { get; } #True when declared weight or legacy font-name evidence identifies a bold face.
public bool IsItalic { get; } #True when descriptor flags or legacy font-name evidence identifies an italic face.
public double Advance { get; } #Advance width in user space for this span (includes spacing and hscale).
public OfficeColor? Color { get; } #Fill color used for visual text rendering, when it could be read from the content stream.
public bool IsVisible { get; } #True when the text span should be painted during visual rendering.
public double RotationDegrees { get; } #Baseline rotation in PDF user-space degrees, where positive angles are counter-clockwise.
public int? MarkedContentId { get; } #Active content-stream-scoped marked-content identifier from a tagged PDF, when present.
public int? ContentStreamObjectNumber { get; } #Form XObject or other content-stream object owning the MCID, or null for page content.
public int TextRenderingMode { get; } #PDF text rendering mode active for this span (0 through 7).
public bool HasActualText { get; } #True when marked-content ActualText replaced the logical text.
public bool IsArtifactContent { get; } #True when this span came from PDF content explicitly marked as an /Artifact.