This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/csharp/extraction/parse-document.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Parse documents in C# | Nutrient .NET SDK

Document parsing turns a PDF or image into reusable structured content. Use it when you need paragraphs, tables, figures, key-value regions, words, or Markdown rather than a converted document or a fixed set of extracted fields.

This guide uses DataExtraction.Parse to produce JSON and Markdown artifacts from the same document. The operation uses the same option names and output filenames as the hosted Nutrient data extraction service.

Download sample

Preparing the project

Import the Nutrient namespace:

using Nutrient;

Opening the document

Open the source document and bind a DataExtraction instance to it. Both are disposable, so use C#’s using statement(opens in a new tab) for each:

try
{
using Document document = Document.Open("input_repeated_column_groups.png");
using DataExtraction dataExtraction = DataExtraction.Set(document);

The bundled input_repeated_column_groups.png contains a payment register with two side-by-side groups of Name and Amount columns. The left group lists Alice through Emma; the right group lists Frank through James. Parse also works with supported PDF, TIFF, and other image inputs.

Selecting the output formats

Like every SDK operation, Parse() reads its options from the document settings. ParseSettings holds the options of the hosted parse service under the same names; options you don’t set keep the pipeline or SDK-wide default.

Set ExportFormats to request structured JSON and Markdown in one pass. Both the settings wrapper and the result wrapper hold native resources, so declare each with using:

using ParseSettings settings = document.Settings.ParseSettings;
settings.ExportFormats = new[] { "json", "markdown" };
settings.IncludeWords = true;

IncludeWords adds word-level details and bounding boxes to the JSON output. Leave it unassigned when the higher-level document structure is enough.

Enabling optional Markdown and table features

Two output features are disabled by default, and this sample opts in to both:

  • MarkdownSettings.EnableInlineFormatting includes recognized inline styles, such as bold, italic, superscript, and subscript, in the Markdown output.
  • TableRecognitionSettings.StackRepeatedColumnGroups reads a list printed in side-by-side column groups with repeated headers as one table.
document.Settings.MarkdownSettings.EnableInlineFormatting = true;
document.Settings.TableRecognitionSettings.StackRepeatedColumnGroups = true;

Then call Parse() once to produce every requested format:

using ParseResult result = dataExtraction.Parse();

Reading named artifacts

Parse returns named artifacts instead of one output string. A run requesting JSON and Markdown produces document.json and document.md:

Console.WriteLine($"Artifacts: {string.Join(", ", result.ArtifactNames)}");
File.WriteAllText("document.json", result.GetArtifact("document.json"));
File.WriteAllText("document.md", result.GetArtifact("document.md"));
Console.WriteLine("Parsed content written to document.json and document.md");
}
catch (NutrientException e)
{
Console.Error.WriteLine($"Error: {e.Message}");
Environment.Exit(1);
}

GetArtifact throws when the requested artifact isn’t present. If formats are selected dynamically, call HasArtifact before reading. The typed accessors DocumentJson and DocumentMd return the same content, or null when the run didn’t produce that artifact.

Call result.SaveTo("artifacts") when you want to write every produced artifact into one directory under its service-compatible filename.

Understanding parsed content

Parsing recognizes code blocks and numbered section headings as document structure. On scanned pages, it groups form labels with their values, preserves multicolumn reading order, and identifies table and figure captions. Paragraphs and table cells include font family, class, and size information when available. Scanned-page typography is recognized from the image; born-digital PDF text uses the document’s font information.

Markdown output preserves document structure. Inline text styles appear only when EnableInlineFormatting is enabled. Captions are plain text, pictures with alternative text use Markdown image syntax, and charts don’t receive generated summaries.

Repeated column groups

Some lists repeat the same column headers across side-by-side groups on a page. By default, those groups stay side by side in the output. With StackRepeatedColumnGroups enabled, the groups are read one after another as a single table, and groups with separate titles are returned as separate tables. The bundled payment register demonstrates this layout. With stacking enabled, look for a two-column table with 10 data rows: Alice through Emma, followed by Frank through James, with amounts from 10 to 100. To compare, set StackRepeatedColumnGroups to false and run the sample again. Without stacking, the table keeps four columns and five data rows. Each run overwrites document.json and document.md, so save a copy before comparing outputs.

Choosing between Parse, conversion, and Extract

Use the operation that matches the output you need:

  • Use Document.ExportAsMarkdown when you only need a direct PDF-to-Markdown conversion.
  • Use DataExtraction.Parse when you need reusable document structure, several output formats, word details, or service-compatible artifacts.
  • Use DataExtraction.Extract when you want an AI model to fill fields defined by your JSON Schema. Calling Parse first isn’t required.

Conclusion

The parsing workflow is:

  1. Open the document and bind DataExtraction with DataExtraction.Set().
  2. Select JSON, Markdown, or both with the document’s ParseSettings.
  3. Optionally, enable inline Markdown formatting and stacking of repeated table column groups.
  4. Call Parse() once.
  5. Read the named artifacts or save the complete result.
  6. Handle NutrientException for failures.

Download this ready-to-use sample package to explore document parsing.