Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf
0.1.1
Prefix Reserved
dotnet add package Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf --version 0.1.1
NuGet\Install-Package Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf -Version 0.1.1
<PackageReference Include="Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf" Version="0.1.1" />
<PackageVersion Include="Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf" Version="0.1.1" />
<PackageReference Include="Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf" />
paket add Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf --version 0.1.1
#r "nuget: Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf, 0.1.1"
#:package Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf@0.1.1
#addin nuget:?package=Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf&version=0.1.1
#tool nuget:?package=Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf&version=0.1.1
Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf
PDF snapshot testing on top of Arbeidstilsynet.Common.TestExtensions.Snapshots.
A PDF is verified as:
{name}.verified.txt: the PDF version, the page count and the text of each page. Text diffs are readable in pull requests.{name}.verified.png(one page) or{name}#00.verified.png,#01, … (several pages): every page rendered with PDFium. Images are compared with SSIM, so small rasterisation differences between machines are tolerated while layout and content changes still fail.
Usage
using Arbeidstilsynet.Common.TestExtensions.Snapshots;
using Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf;
[Theory]
[InlineData(Språk.Bokmål)]
[InlineData(Språk.Nynorsk)]
public async Task Confirmation_MatchesSnapshot(Språk språk)
{
await using var pdf = await _brevgen.GenerateConfirmation(melding, språk);
await PdfSnapshot.VerifyPdf(pdf, new SnapshotSettings().UseDirectory("Snapshots").ScrubInlineGuids());
}
The text snapshot looks like this:
{
Version: 1.7,
PageCount: 2,
Pages: [
{
Text:
Forhåndsmelding
Referanse: Guid_1
},
{
Index: 1,
Text: Side 2 av 2
}
]
}
Options
PdfSnapshotOptions |
Default | Meaning |
|---|---|---|
Dpi |
144 |
Render resolution. A4 is 1191×1684 pixels. |
SsimThreshold |
0.98 |
Minimum mean SSIM over content areas. |
MinWindowSsim |
0.5 |
Minimum SSIM for every 8×8 content window. Catches small local changes such as a single changed word. -1 disables it. |
IncludeImages |
true |
Set to false to verify only the text snapshot. |
The received/verified workflow, accept mode (SNAPSHOT_ACCEPT=1) and all SnapshotSettings work as in the core package. The algorithm is specified in SPEC.md §6.
Migrating from Verify.PdfPig / Verify.DocNet
- Text snapshots are compatible and can be kept as they are.
- Page images must be re-accepted once: delete the old
*.verified.pngfiles, run withSNAPSHOT_ACCEPT=1and commit the result. - Delete any
#pdf.verified.pdffiles. They are no longer produced.
Platforms
Native PDFium and Skia binaries are included for Linux (no extra system dependencies), macOS and Windows.
PNG snapshots are only stable across operating systems when the PDF embeds its fonts. Non-embedded fonts, such as the standard-14 Helvetica, are replaced by a system font, and that font differs between macOS, Linux and Windows. PDFs from QuestPDF embed their fonts. For hand-built test PDFs, embed a TrueType font, or set IncludeImages = false.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Arbeidstilsynet.Common.TestExtensions.Snapshots (>= 0.2.1)
- PdfPig (>= 0.1.16)
- PDFtoImage (>= 5.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.1 | 114 | 10/15/2026 |
| 0.1.0 | 708 | 10/5/2026 |
| 0.1.0-preview.1 | 51 | 10/5/2026 |
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added <!-- for new features. -->
### Changed <!-- for changes in existing functionality. -->
### Deprecated <!-- for soon-to-be removed features. -->
### Removed <!-- for now removed features. -->
### Fixed <!-- for any bug fixes. -->
### Security <!-- in case of vulnerabilities. -->
## 0.1.1
### Fixed
- Standardized NuGet metadata with Arbeidstilsynet as author, an MIT license expression, an embedded icon and Git repository details.
## 0.1.0
### Added
- feat: `PdfSnapshot.VerifyPdf` writes a text snapshot (PdfPig) and one PNG per page (PDFtoImage/PDFium). Pages are compared with SSIM using a mean threshold and a per-window threshold.