๐Ÿ“Š CSV Renderer โ€” Accessible PDFs from Spreadsheets

ObviousPDF.Csv renders CSV documents into tagged, accessible PDFs. Set accessible,true in the [DOCUMENT] section for automatic PDF/UA-1 compliance โ€” designed for authoring in Excel, Google Sheets, or any text editor.

๐Ÿ“ฆ Installation

The CSV renderer ships as a separate NuGet package:

dotnet add package ObviousPDF
dotnet add package ObviousPDF.Csv

๐Ÿ†š Three Input Formats โ€” Same Accessible Output

ObviousPDF offers three input pipelines that all produce identical PDF output. Choose the format that fits your workflow:

Pipeline Package Best For
JSONObviousPDF.JsonWeb APIs, JavaScript tooling, LLM/AI generation
XMLObviousPDF.XmlEnterprise workflows, XSLT transforms, schema validation
CSVObviousPDF.CsvSpreadsheet authoring (Excel, Google Sheets), bulk data
C# โ€” Render Accessible PDF from CSV
using ObviousPDF.Csv;

// Render from a CSV file to a PDF file
PdfCsvRenderer.RenderFromFile(
    csvPath:    "form-1040ea.csv",
    outputPath: "form-1040ea.pdf");

// โ€” or โ€” render from a CSV string in memory
string csv = File.ReadAllText("form-1040ea.csv");
PdfCsvRenderer.Render(csv, "form-1040ea.pdf");

// โ€” or โ€” validate before rendering
var validator = new PdfCsvValidator();
var validation = validator.Validate(csv);
if (!validation.IsValid)
{
    Console.WriteLine(validation);
    return;
}

// โ€” or โ€” build a PdfDocument for further manipulation
using ObviousPDF;
using ObviousPDF.Accessibility;

PdfDocument doc = PdfCsvRenderer.BuildDocument(csv);

var checker = new PdfAccessibilityChecker();
PdfAccessibilityReport report = checker.Check(doc);

foreach (var result in report.Results)
    Console.WriteLine($"[{result.Feature}] {result.Description}");

doc.Save("form-1040ea.pdf");
Add-Type -Path "ObviousPDF.dll"
Add-Type -Path "ObviousPDF.Csv.dll"

# Render from CSV file to PDF
[ObviousPDF.Csv.PdfCsvRenderer]::RenderFromFile(
    "form-1040ea.csv",
    "form-1040ea.pdf")

# Or render from a CSV string
$csv = Get-Content "form-1040ea.csv" -Raw
[ObviousPDF.Csv.PdfCsvRenderer]::Render($csv, "form-1040ea.pdf")

The form-1040ea.csv file is a complete 3-page IRS Form 1040 (2024) with Schedule 1 โ€” identical visual output to the JSON and XML versions, using accessible,true for automatic PDF/UA-1 conformance.

Form 1040 (Easy Accessibility) โ€” CSV

The same IRS Form 1040 from the JSON example and the XML Renderer page, expressed as CSV. The [DOCUMENT] section sets accessible,true to enable all automatic accessibility features.

form-1040ea.csv โ€” Document & First Page (Excerpt)
# Form 1040 - U.S. Individual Income Tax Return (2024)
# Enhanced Accessibility version: uses structureTag auto-tagging.

[DOCUMENT]
coordinateOrigin,topLeft
accessible,true
language,en-US
displayDocTitle,true
pdfVersion,2.0
info.title,"Form 1040 - U.S. Individual Income Tax Return (2024)"
info.author,Department of the Treasury - Internal Revenue Service

[FONTS]
id,mode,standardFont,bundledFont,path,description,data
title-font,standardFont,HelveticaBold,,,,
body-font,standardFont,Helvetica,,,,
section-font,standardFont,HelveticaBold,,,,

[PAGE 1 size=Letter]
type,x,y,...,text,...,structureTag,artifact,artifactType
rectangle,0,0,...,,,,true,background
text,160,28,...,U.S. Individual Income Tax Return,...,H1,,
text,36,90,...,Filing Status,...,H2,,
checkboxField,40,110,...,,,,,
textField,36,185,...,,,,,

๐Ÿ”‘ Key CSV Features

  • Section-based format โ€” [DOCUMENT], [FONTS], [IMAGES], [PAGE n] etc. organize the document logically.
  • Spreadsheet-friendly โ€” design your PDF layout in Excel or Google Sheets, export as CSV, and render.
  • accessible,true โ€” one line in [DOCUMENT] enables full PDF/UA-1 compliance.
  • structureTag column โ€” override the default <P> auto-tag with H1, H2, BlockQuote, etc.
  • artifact,true โ€” mark decorative elements as artifacts to exclude them from the tag tree.
  • Validation โ€” PdfCsvValidator.Validate() checks for errors before rendering (rules CV001โ€“CV025).

Same Element โ€” Three Formats

A single text field expressed in JSON, XML, and CSV:

JSON
{
  "type": "textField",
  "name": "first_name",
  "x": 36, "y": 185,
  "width": 200, "height": 18,
  "required": true,
  "tooltip": "Your first name"
}
XML
<TextField name="first_name"
           x="36" y="185"
           width="200" height="18"
           required="true"
           tooltip="Your first name" />
CSV
textField,36,185,,,,,200,18,,,,,,,,,,,,first_name,true,,Your first name,,,,

๐Ÿ“‹ When to Use CSV

  • Spreadsheet authoring โ€” build layouts in Excel/Google Sheets
  • Batch generation โ€” merge CSV data with template rows
  • Simple documents โ€” the flat structure is easy to understand
  • Non-developer teams โ€” no JSON/XML syntax knowledge needed
Rendered Form 1040 PDF showing Page 1 with Filing Status, Name and Address, Income, and Adjustments to Income sections โ€” rendered from CSV with easy accessibility
Form 1040 Page 1 โ€” rendered from CSV with accessible,true

Override structureTag for Semantic Structure

By default, accessible,true auto-tags every non-artifact text element as <P>. Use the structureTag column to apply richer semantics:

CSV โ€” structureTag Examples
# structureTag column values: H1, H2, H3, H4, H5, H6, P, BlockQuote, Caption, Span

[PAGE 1 size=Letter]
type,x,y,...,text,...,structureTag,artifact,artifactType
text,160,28,...,Form Title,...,H1,,
text,36,90,...,Filing Status,...,H2,,
text,36,130,...,Check the box,...,P,,
text,36,500,...,* See instructions,...,BlockQuote,,
rectangle,0,780,...,,,,true,background

๐Ÿ“‹ Available Structure Tags

Tag Usage Standard
H1โ€“H6Headings (must start at H1, no skipped levels)ISO 14289-1 ยง7.4
PParagraph (default for auto-tagged text)ISO 32000-2 ยง14.8.4
BlockQuoteBlock-level quotationISO 32000-2 ยง14.8.4
CaptionCaption for a figure or tableISO 32000-2 ยง14.8.4
SpanInline span of textISO 32000-2 ยง14.8.4

Built-in Accessibility Report

Enable generateAccessibilityReport,true in the [DOCUMENT] section โ€” or set it via PdfCsvRendererOptions โ€” to receive a detailed accessibility report after rendering:

CSV โ€” Enable Accessibility Report
[DOCUMENT]
accessible,true
generateAccessibilityReport,true
language,en-US
C# โ€” Access the Accessibility Report
using ObviousPDF.Csv;

string csv = File.ReadAllText("form-1040ea.csv");

// Option 1: RenderWithReport returns the report
PdfCsvRenderResult result = PdfCsvRenderer.RenderWithReport(csv, "output.pdf");

if (result.AccessibilityReport != null)
{
    foreach (var item in result.AccessibilityReport.Results)
        Console.WriteLine($"[{item.Feature}] {item.Description}");
}

// Option 2: Set via options object
var options = new PdfCsvRendererOptions
{
    GenerateAccessibilityReport = true
};
PdfCsvRenderer.RenderFromFile("form-1040ea.csv", "output.pdf", options);

โš ๏ธ Disclaimer

The automated accessibility report assists in assessment but is not a comprehensive audit. To confirm WCAG or PDF/UA conformance, human assessment by an accessibility specialist is recommended.

โ™ฟ Accessibility Notes

  • PAC Validated: PDFs rendered from the CSV pipeline pass PAC for both PDF/UA and WCAG 2.2.
  • Form fields โ€” always include a label column value (becomes /TU, Matterhorn checkpoint 28).
  • Artifacts โ€” decorative elements must have artifact set to true (ISO 14289-1 ยง7.1).
  • Language โ€” set language in [DOCUMENT] to a valid BCP-47 tag (ISO 14289-1 ยง7.2).
  • All three pipelines produce identical PDF output when given equivalent input.