manuelbl / SwissQRBill.NET

.NET library for Swiss QR bill payment slips (aka QR-Rechnung)
MIT License
86 stars 32 forks source link

Convert PDF to PNG for test verification #36

Closed 0xced closed 2 years ago

0xced commented 2 years ago

It's not feasible to compare PDF files byte-by-byte because the PDF creation uses DeflateStream which produces different results on different platforms (Linux/macOS/Windows and .NET Framework/.NET Core), see https://github.com/dotnet/runtime/issues/30539

Running the tests on macOS would fails because the compressed stream computed on macOS is slightly different from the one computed on Windows.

The conversion uses Docnet.Core (which is a wrapper around the PDFium C++ library that is used by Chromium) for PDF rendering and ImageSharp to create the PNG from the rendered buffer. This method does not rely on any external tool such as ghostscript to be installed on the machine since the pdfium native dll is embedded in the Docnet.Core NuGet package for all platforms (Linux + macOS + Windows 32 and 64 bits).

0xced commented 2 years ago

Before this pull request: Windows: 100% (451/451) ✅ Linux: 96% (435/451) ❌ macOS: 95% (432/451) ❌

After this pull request: Windows: 100% (451/451) ✅ Linux: 98% (446/451) ❌ macOS: 98% (443/451) ❌