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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf --version 0.1.1
                    
#r "nuget: Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Arbeidstilsynet.Common.TestExtensions.Snapshots.Pdf&version=0.1.1
                    
Install as a Cake Tool

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.png files, run with SNAPSHOT_ACCEPT=1 and commit the result.
  • Delete any #pdf.verified.pdf files. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.