Skip to content

TxtConverter

TxtConverter is the BaseConverter subclass selected by ConverterFactory for .txt source files. It is the only converter that reads its source with an ASCII-only encoding and lays text out itself, drawing a fixed number of lines per page with a public field controlling that page density, rather than delegating to a dedicated Syncfusion document engine.

Purpose

  • Convert plain text to a paginated PDF by drawing fixed-size line blocks (BR-SFC-003, BR-SFC-004).
  • Read source text using an ASCII-only encoding, which can corrupt non-ASCII characters (BR-SFC-012).
  • Expose the page density (lines per page) as a public, mutable field rather than a fixed constant (BR-SFC-014).
  • Identify itself to ConverterFactory and downstream consumers as the Text conversion type.

Context

  • Namespace: PdfAPI.SyncFusionCore
  • Assembly/package: PdfAPI.SyncFusionCore (Pdf.Local.Client NuGet package)

Public members

Member Signature Purpose
TxtConverter TxtConverter() Creates a ready-to-use TxtConverter instance for ConverterFactory to invoke against plain-text source documents (.txt) as the first step of the intermediate-PDF conversion path; the constructor body is empty*, so no state is established beyond the base type's fields.
ConversionType override SourceConversionType ConversionType { get; } Returns SourceConversionType.Text, identifying this converter's source format to ConverterFactory and to the assembled PdfResult.
LinesPerPage public int LinesPerPage = 40 Public field controlling how many lines of text are drawn per output page before starting a new page; defaults to 40 (BR-SFC-014).

Inherited public members

Members in this section are inherited from BaseConverter in PdfAPI.SyncFusionCore. They are available on this type through inheritance.

Member Signature Purpose Origin
Convert PdfResult Convert(Stream stream, ConvertRequest request) Executes the full conversion: times the operation, invokes ConfigureConverter and ConvertItem, and assembles a PdfResult with Status, Elapsed, and PdfProcessorType = Syncfusion; captures rather than propagates conversion exceptions (BR-SFC-006, BR-SFC-010). PdfAPI.SyncFusionCore — BaseConverter

Behavioral notes

  • Because the field is public and mutable, a caller with a direct reference to this converter instance could change page density before conversion; ConverterFactory always constructs a fresh instance, so the default of 40 is what actually executes on the standard conversion path.
  • Reading the source with an ASCII-only encoding means characters outside the ASCII range may be altered or lost during conversion (BR-SFC-012).
  • A conversion failure is captured by the inherited Convert method and reported through the result rather than thrown (BR-SFC-010).

Constraints and usage notes

  • Not intended to be constructed directly by application code; ConverterFactory constructs and invokes it based on the source file extension.
  • Text typography (font/size) is fixed within the converter, not configurable via a public member (BR-SFC-015).

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

Sources

  • PdfApi.SyncFusionCore\Convert\TxtConverter.cs