Samples

The sample project creates several realistic .docx files and writes them to Desktop\SampleDocs.

Run All Samples

dotnet run --project samples\TerraFluent.Docx.Reporting.Sample\TerraFluent.Docx.Reporting.Sample.csproj

Sample Files

Sample Source Demonstrates
Feature showcase FeatureShowcaseSample.cs Headings, text, headers, footers, images, barcodes, hyperlinks, and general document structure.
Barcode showcase BarcodeShowcaseSample.cs Shipping manifest with barcodes in a header, a table column, and standalone printable labels.
Market analysis MarketAnalysisSample.cs Auto-numbered figure/table captions, table of figures and list of tables, sized/stacked/labeled charts, and comments-only document protection.
Invoice InvoiceSample.cs Invoice layout, branding, totals, and tables.
Long invoice LongInvoiceSample.cs Multi-page invoice behavior and repeated tabular content.
Annual report AnnualReportSample.cs Realistic business report with sections, images, tables, and rich formatting.
Layout features LayoutFeaturesSample.cs Page size, orientation, margins, columns, watermarks, and layout behavior.
Template replacement TemplateReplacementSample.cs Placeholder and content-control replacement.
API reference document ApiReferenceSample.cs Broad tour of the public descriptor API in generated document form.

Support files:

Copy A Sample Pattern

For a new report, start with this structure:

using TerraFluent.Docx.Reporting;

public static class ReportSample
{
    public static string Generate(string outputDirectory)
    {
        var path = Path.Combine(outputDirectory, "report.docx");

        Document.Create(doc =>
        {
            doc.MetadataTitle("Report")
               .MetadataAuthor("Reporting Team")
               .Theme(theme => theme.DefaultFont("Aptos", 10.5f));

            doc.Page(page =>
            {
                page.Size(PageSize.A4);
                page.Margin(Unit.Centimetre(2));
                page.Content().H1("Report");
                page.Content().Text("Add report content here.");
            });
        }).PublishDocx(path);

        return path;
    }
}

Visual QA Checklist

After running samples:

  • Open each generated .docx in Microsoft Word.
  • Confirm there are no repair prompts.
  • Refresh fields if you use a table of contents.
  • Open or convert the same files in LibreOffice when cross-application compatibility matters.
  • Check images, charts, page numbers, watermarks, and table layout.

View this page's source on GitHub →