|
|
@@ -1,4 +1,6 @@
|
|
|
-using System.IO;
|
|
|
+using System;
|
|
|
+using System.IO;
|
|
|
+using QuestPDF.Drawing.Exceptions;
|
|
|
using QuestPDF.Helpers;
|
|
|
using SkiaSharp;
|
|
|
|
|
|
@@ -7,11 +9,23 @@ namespace QuestPDF.Drawing
|
|
|
internal class PdfCanvas : SkiaDocumentCanvasBase
|
|
|
{
|
|
|
public PdfCanvas(Stream stream, DocumentMetadata documentMetadata)
|
|
|
- : base(SKDocument.CreatePdf(stream, MapMetadata(documentMetadata)))
|
|
|
+ : base(CreatePdf(stream, documentMetadata))
|
|
|
{
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private static SKDocument CreatePdf(Stream stream, DocumentMetadata documentMetadata)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return SKDocument.CreatePdf(stream, MapMetadata(documentMetadata));
|
|
|
+ }
|
|
|
+ catch (TypeInitializationException exception)
|
|
|
+ {
|
|
|
+ throw new InitializationException("PDF", exception);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static SKDocumentPdfMetadata MapMetadata(DocumentMetadata metadata)
|
|
|
{
|
|
|
return new SKDocumentPdfMetadata
|