Skip to content

Commit 109cea7

Browse files
.
1 parent 34d8d9d commit 109cea7

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

roles/lib/files/FWO.Report/ReportBase.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public static string ToUtcString(string? timestring)
258258

259259
if (installedBrowser == null)
260260
{
261-
throw new Exception($"Browser {wantedBrowser} is not installed!");
261+
throw new Exception($"Browser {wantedBrowser} is not installed!");
262262
}
263263

264264
using IBrowser? browser = await Puppeteer.LaunchAsync(new LaunchOptions
@@ -267,28 +267,28 @@ public static string ToUtcString(string? timestring)
267267
Headless = true
268268
});
269269

270-
try
271-
{
272-
using IPage page = await browser.NewPageAsync();
273-
await page.SetContentAsync(html);
274-
275-
PuppeteerSharp.Media.PaperFormat? pupformat = GetPuppeteerPaperFormat(format) ?? throw new Exception();
276-
277-
PdfOptions pdfOptions = new() { DisplayHeaderFooter = true, Landscape = true, PrintBackground = true, Format = pupformat, MarginOptions = new MarginOptions { Top = "1cm", Bottom = "1cm", Left = "1cm", Right = "1cm" } };
278-
using Stream? pdfData = await page.PdfStreamAsync(pdfOptions);
279-
280-
byte[]? pdfWithToCData = AddToCBookmarksToPDF(pdfData, html);
281-
282-
return Convert.ToBase64String(pdfWithToCData);
283-
}
284-
catch (Exception)
285-
{
286-
throw new Exception("This paper kind is currently not supported. Please choose another one or \"Custom\" for a custom size.");
287-
}
288-
finally
289-
{
290-
await browser.CloseAsync();
291-
}
270+
//try
271+
//{
272+
using IPage page = await browser.NewPageAsync();
273+
await page.SetContentAsync(html);
274+
275+
//PuppeteerSharp.Media.PaperFormat? pupformat = GetPuppeteerPaperFormat(format) ?? throw new Exception();
276+
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" } };
277+
//PdfOptions pdfOptions = new() { DisplayHeaderFooter = true, Landscape = true, PrintBackground = true, Format = pupformat, MarginOptions = new MarginOptions { Top = "1cm", Bottom = "1cm", Left = "1cm", Right = "1cm" } };
278+
using Stream? pdfData = await page.PdfStreamAsync(pdfOptions);
279+
280+
byte[]? pdfWithToCData = AddToCBookmarksToPDF(pdfData, html);
281+
282+
return Convert.ToBase64String(pdfWithToCData);
283+
//}
284+
//catch (Exception)
285+
//{
286+
// throw new Exception("This paper kind is currently not supported. Please choose another one or \"Custom\" for a custom size.");
287+
//}
288+
//finally
289+
//{
290+
// await browser.CloseAsync();
291+
//}
292292
}
293293

294294
private static List<ToCHeader> CreateTOCContent(string html)

0 commit comments

Comments
 (0)