Verify.QuestPDF
April 9, 2026 ยท View on GitHub
Extends Verify to allow verification of documents via QuestPDF.
See Milestones for release notes.
Designed to help assert the output of projects using QuestPDF to generate PDFs.
Sponsors
Entity Framework Extensions
Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.
Developed using JetBrains IDEs
NuGet
Usage
[ModuleInitializer]
public static void Init()
{
VerifyImageMagick.RegisterComparers(0.015);
VerifyQuestPdf.Initialize();
}
This sample uses Verify.ImageMagick to ignore small rendering differences that are expected between differens operating systesm.
Other compares options:
- https://github.com/VerifyTests/Verify.ImageHash
- https://github.com/VerifyTests/Verify.ImageMagick
- https://github.com/VerifyTests/Verify.Phash
- https://github.com/VerifyTests/Verify.ImageSharp.Compare
Code that generates a document
static IDocument GenerateDocument() =>
Document.Create(container =>
{
container.Page(AddPage);
container.Page(AddPage);
});
static void AddPage(PageDescriptor page)
{
page.Size(PageSizes.A5);
page.Margin(1, Unit.Centimetre);
page.PageColor(Colors.Grey.Lighten3);
page.DefaultTextStyle(_ => _.FontSize(20));
page.Header()
.Text("Hello PDF!")
.SemiBold().FontSize(36);
page.Content()
.Column(_ => _.Item()
.Text(Placeholders.LoremIpsum()));
page.Footer()
.AlignCenter()
.Text(_ =>
{
_.Span("Page ");
_.CurrentPageNumber();
});
}
Verify a Document
[Test]
public Task VerifyDocument()
{
var document = GenerateDocument();
return Verify(document);
}
Results
Metadata
{
Pages: 2,
Metadata: {
CreationDate: DateTimeOffset_1,
ModifiedDate: DateTimeOffset_2
},
Settings: {
ContentDirection: LeftToRight,
PDFA_Conformance: None,
PDFUA_Conformance: None,
ImageCompressionQuality: High,
ImageRasterDpi: 288
}
}
Pdf as image
PagesToInclude
To render only a defined number of pages at the start of a document:
[Test]
public Task PagesToInclude()
{
var document = GenerateDocument();
return Verify(document)
.PagesToInclude(1);
}
Dynamic
To dynamically control what pages are rendered:
[Test]
public Task PagesToIncludeDynamic()
{
var document = GenerateDocument();
return Verify(document)
.PagesToInclude(pageNumber => pageNumber == 2);
}

