XtudioPdf

Get started

From zero to your first PDF in 10 minutes

You design the template visually inside Visual Studio or VS Code. When you build, it is embedded in your DLL. In production your code generates the PDF on the server, without a browser and without files to copy.

1

Your data: a C# class

[PdfDataSource("Invoice")]
public record InvoiceDto(
    string Number,
    CustomerDto Customer,
    List<LineDto> Lines,
    decimal Total);
2

The design: a .pdfx file

A template in the designer, with the fields of the DTO on the sheet
3

The result: your API returns the PDF

The generated invoice PDF with real data

1Install the package

Install only one. XtudioPdf.AspNetCore already includes the engine.

Your projectPackage
Web API, Minimal API, MVC or Razor Pages (ASP.NET Core)XtudioPdf.AspNetCore
Worker Service, console, desktop (WPF, WinForms, MAUI), Azure Functions or your own libraryXtudioPdf.Core
$ dotnet add package XtudioPdf.AspNetCore

Requires .NET 8 or .NET 10. Runs on Windows, Linux, macOS and Docker. .NET Framework (4.x) is not supported.

2Install the extension (once per computer)

Visual Studio 2022+

Extensions → Manage Extensions → search for “XtudioPdf” → Install, and restart Visual Studio.

VS Code

Extensions (Ctrl+Shift+X) → search for “XtudioPdf” → Install.

$ code --install-extension xtudiopdf.xtudiopdf

That's all. The first time you open a .pdfx, the extension installs the designer by itself (the xtudiopdf tool) and keeps it up to date. Without an extension, install it by hand: dotnet tool install -g XtudioPdf.Tool

3Create your document

Right-click the folder where you keep your reports and add an XtudioPdf document. Give it a name, for example Invoice.

Solution Explorer
▾ MyApi
▸ Models
▸ Reports
Program.cs
Visual Studio: Add → XtudioPdf document… · VS Code: New XtudioPdf document…
What gets created
▾ Reports
Invoice.pdfxthe design: double-click it to open the designer
Invoice.sample.jsonsample data for the preview
InvoiceReport.csthe class that generates the PDF
InvoiceDto.csyour data (only if you didn't choose an existing class)
From the terminal it is the same: xtudiopdf new Invoice

4Design

Double-click Invoice.pdfx and the designer opens as one more tab of your editor. You don't need to run your app.

The XtudioPdf designer with an invoice template 1 2 3 4
  1. Blocks. Drag them onto the sheet: text, tables, images, QR, charts… A Row puts blocks side by side; a Column stacks them.
  2. The sheet. Header and footer repeat on every page; the body grows with your data and jumps to new pages by itself.
  3. Properties. Click any block to change its text, font, colors, borders, spacing and when it is shown.
  4. Preview (Ctrl+Enter) shows the real PDF. Save with Ctrl+S.

5Connect your data

The Data tab lists the properties of your class. You never type a field by hand: you choose it.

The Data tab with the fields of the DTO and a table bound to a list 1 2 3 4
  1. Your fields. Click one (or drag it) to insert it in the selected text, for example {{Customer.Name}}.
  2. On the sheet each field is a blue label. The database button at the top shows the sample values instead.
  3. A table repeats one row per item of a list, and jumps to the next page when it doesn't fit.
  4. Choose the list (Lines, Items…) and the field of each column. Formats like {{Total:N2}} or the amount in words {{Total:letras}} go after the colon.
Preview of the invoice PDF with sample data

The preview uses your sample data: the .sample.json file next to the template, or a static GetSampleData() method in your class.

6Generate the PDF in your code

Every .pdfx in the project is embedded when you build and checked against its class: if a field doesn't exist, the compiler warns you.

// Program.cs
builder.Services.AddPdfReports();

// Reports/InvoiceReport.cs: created for you; XtudioPdf completes it from the .pdfx
public sealed partial class InvoiceReport
{
    public byte[] Generate(InvoiceDto data) => Render(data);
}

// Your endpoint returns the PDF
app.MapGet("/invoices/{id:int}/pdf", async (int id, InvoiceReport report, AppDb db) =>
    await db.Invoices.FindAsync(id) is { } invoice
        ? Results.File(report.Generate(invoice), "application/pdf", $"invoice-{id}.pdf")
        : Results.NotFound());

Without ASP.NET Core (XtudioPdf.Core):

var templates = new PdfTemplates().AddAssembly(typeof(Program).Assembly);
byte[] pdf = templates.Render("Invoice", invoice);

What you do with the bytes is up to you: return them from your API, save them, attach them to an email or send them to the tax authority with the XML.

7Activate Pro (optional)

Community works without a key and includes 100% of features for individuals and companies under $1M USD annual revenue. With a Pro key, put it in appsettings.json or in the XTUDIOPDF_LICENSE_KEY environment variable.

"XtudioPdf": { "LicenseKey": "XTPD.…" }
  • Validated 100% offline in both the designer and production — never contacts external servers.
  • Embeds your organization's name in the PDF Creator metadata and includes priority support.