-
-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61f5310
commit 95637a0
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using QuestPDF.Drawing.Exceptions; | ||
using QuestPDF.Helpers; | ||
using QuestPDF.Infrastructure; | ||
using QuestPDF.Skia; | ||
|
||
namespace QuestPDF.Drawing | ||
{ | ||
internal sealed class SvgCanvas : SkiaCanvasBase | ||
{ | ||
internal SkWriteStream WriteStream { get; set; } | ||
internal ICollection<string> Images { get; } = new List<string>(); | ||
|
||
~SvgCanvas() | ||
{ | ||
WriteStream?.Dispose(); | ||
} | ||
|
||
public override void BeginDocument() | ||
{ | ||
|
||
} | ||
|
||
public override void EndDocument() | ||
{ | ||
|
||
} | ||
|
||
public override void BeginPage(Size size) | ||
{ | ||
WriteStream?.Dispose(); | ||
WriteStream = new SkWriteStream(); | ||
Canvas = SkSvgCanvas.CreateSvg(size.Width, size.Height, WriteStream); | ||
} | ||
|
||
public override void EndPage() | ||
{ | ||
Canvas.Save(); | ||
Canvas.Dispose(); | ||
|
||
using var data = WriteStream.DetachData(); | ||
var svgImage = Encoding.UTF8.GetString(data.ToBytes()); | ||
Images.Add(svgImage); | ||
|
||
WriteStream.Dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters