QDG Knowledge Base Read-only viewer QWebHub
general

Data.PdfGen

Version 1 · Document the Data.PdfGen MVC + API app for racing PDF generation

Data.PdfGen

An ASP.NET Core MVC + API application that generates racing PDFs — review PDFs and final-report / form PDFs — from the rs MySQL database using iText7.

SDK: Microsoft.NET.Sdk.Web. Key packages: itext7 8.0.5, itext7.bouncy-castle-adapter 8.0.5, MySqlConnector 2.3.7.

Startup

Program.cs registers the code-pages encoding provider, AddControllersWithViews, static files, and the scoped services DbService, MeetingDataService, ReviewPdfService, FinalReportPdfService. Routing uses the default MVC route {controller=Home}/{action=Index}/{id?} plus attribute-routed API controllers.

Endpoints

  • HomeController (MVC) — Index, Privacy, Error.
  • ReviewController (MVC) — Index(...) renders a review view via MeetingDataService.
  • PdfController (API, [Route("api/[controller]")]):
    • GET /api/Pdf/review?meetingId&date&discipline=T
    • GET /api/Pdf/finalreport?date&discipline=T
    • GET /api/Pdf/download?path=

Services

  • DbService — raw SQL via MySqlConnector (QueryAsync / ExecuteAsync / ScalarAsync).
  • MeetingDataService — queries rs.tblprerace_*, tblrsratings, and horse forms.
  • ReviewPdfService / FinalReportPdfService — build PDFs with iText PdfDocument; inject IWebHostEnvironment and IConfiguration.
  • PdfHelper — static text / formatting / time helpers (AutoSizeCell, etc.).

Views and resources

Razor views live under Views/ (Home, Review, and shared layout / error partials). The resources/ folder holds fonts (Arial, Arial Narrow, Courier, Lato) and logos / icons used in the PDFs; sample output PDFs are under data/pdf/reviewPDF/.

Configuration

appsettings.json defines ConnectionStrings:RS (the rs database) and a PdfGen section with OutputPath (data/pdf) and ResourcesPath (resources).

The RS connection string is a live credential committed in source — treat it as a secret.

Updated by Claude on Aug. 4, 2026, 12:30 p.m. · Task: updatewiki create project documentation