diff --git a/roles/lib/files/FWO.Report/FWO.Report.csproj b/roles/lib/files/FWO.Report/FWO.Report.csproj
index 84c581812..f080b3896 100644
--- a/roles/lib/files/FWO.Report/FWO.Report.csproj
+++ b/roles/lib/files/FWO.Report/FWO.Report.csproj
@@ -7,7 +7,6 @@
-
diff --git a/roles/middleware/files/FWO.Middleware.Server/ReportScheduler.cs b/roles/middleware/files/FWO.Middleware.Server/ReportScheduler.cs
index 5d8a8691a..77eb40d7b 100644
--- a/roles/middleware/files/FWO.Middleware.Server/ReportScheduler.cs
+++ b/roles/middleware/files/FWO.Middleware.Server/ReportScheduler.cs
@@ -8,7 +8,6 @@
using FWO.Report;
using FWO.Report.Filter;
using System.Timers;
-using WkHtmlToPdfDotNet;
using FWO.Config.File;
using PuppeteerSharp.Media;
diff --git a/roles/test/files/FWO.Test/FWO.Test.csproj b/roles/test/files/FWO.Test/FWO.Test.csproj
index 87b38c2e9..9051ae3ab 100644
--- a/roles/test/files/FWO.Test/FWO.Test.csproj
+++ b/roles/test/files/FWO.Test/FWO.Test.csproj
@@ -8,7 +8,6 @@
-
diff --git a/roles/test/files/FWO.Test/HtmlToPdfTest.cs b/roles/test/files/FWO.Test/HtmlToPdfTest.cs
index 0271485fe..3805dbe53 100644
--- a/roles/test/files/FWO.Test/HtmlToPdfTest.cs
+++ b/roles/test/files/FWO.Test/HtmlToPdfTest.cs
@@ -1,12 +1,8 @@
using NUnit.Framework;
using NUnit.Framework.Legacy;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using WkHtmlToPdfDotNet;
using FWO.Logging;
+using PuppeteerSharp.Media;
+using PuppeteerSharp;
namespace FWO.Test
{
@@ -14,52 +10,42 @@ namespace FWO.Test
[Parallelizable]
internal class HtmlToPdfTest
{
- // Pdf converter
- protected readonly SynchronizedConverter converter;
-
- public HtmlToPdfTest()
- {
- converter = new SynchronizedConverter(new PdfTools());
- }
-
+
[Test]
[Parallelizable]
- public void GeneratePdf()
+ public async Task GeneratePdf()
{
Log.WriteInfo("Test Log", "starting PDF generation");
// HTML
string html = " test test ";
- GlobalSettings globalSettings = new GlobalSettings
+ using IBrowser? browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
- ColorMode = ColorMode.Color,
- Orientation = Orientation.Landscape,
- PaperSize = PaperKind.A4
- };
+ Headless = true
+ });
- HtmlToPdfDocument doc = new HtmlToPdfDocument()
+ string filePath = "pdffile.pdf";
+
+ try
{
- GlobalSettings = globalSettings,
- Objects =
- {
- new ObjectSettings()
- {
- PagesCount = true,
- HtmlContent = html,
- WebSettings = { DefaultEncoding = "utf-8" },
- HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true, Spacing = 2.812 }
- }
- }
- };
+ using IPage page = await browser.NewPageAsync();
+ await page.SetContentAsync(html);
+
+ PdfOptions pdfOptions = new() { DisplayHeaderFooter = true, Landscape = true, PrintBackground = true, Format = PuppeteerSharp.Media.PaperFormat.A4, MarginOptions = new MarginOptions { Top = "1cm", Bottom = "1cm", Left = "1cm", Right = "1cm" } };
+ await page.PdfAsync(filePath);
- byte[] pdf = converter.Convert(doc);
- string filePath = "test.pdf";
- using (var s = File.OpenWrite(filePath)) {
- var bw = new BinaryWriter(s);
- bw.Write(pdf);
}
+ catch (Exception)
+ {
+ throw new Exception("This paper kind is currently not supported. Please choose another one or \"Custom\" for a custom size.");
+ }
+ finally
+ {
+ await browser.CloseAsync();
+ }
+
Assert.That(filePath, Does.Exist);
- ClassicAssert.Greater(new System.IO.FileInfo(filePath).Length, 5000);
+ ClassicAssert.Greater(new FileInfo(filePath).Length, 5000);
}
[OneTimeTearDown]
diff --git a/roles/ui/files/FWO.UI/Pages/Reporting/ReportExport.razor b/roles/ui/files/FWO.UI/Pages/Reporting/ReportExport.razor
index 6f3945c9f..64c07ed99 100644
--- a/roles/ui/files/FWO.UI/Pages/Reporting/ReportExport.razor
+++ b/roles/ui/files/FWO.UI/Pages/Reporting/ReportExport.razor
@@ -2,7 +2,6 @@
@using FWO.Report
@using FWO.Config.Api
@using System.Reflection
-@using WkHtmlToPdfDotNet
@using System.Linq
@using FWO.Report.Filter
@using System.IO