@@ -13,13 +13,14 @@ public abstract class HtmlConverter
1313 /// <param name="html">The HTML content to render.</param>
1414 /// <param name="outputDirectory">Directory where PNG files will be saved.</param>
1515 /// <param name="options">Conversion options (optional).</param>
16+ /// <param name="cancel">Cancellation token.</param>
1617 /// <returns>Result containing paths to generated images and page count.</returns>
17- public ConversionResult ConvertToImages ( string html , string outputDirectory , ConversionOptions ? options = null )
18+ public async Task < ConversionResult > ConvertToImages ( string html , string outputDirectory , ConversionOptions ? options = null , CancellationToken cancel = default )
1819 {
1920 options ??= new ( ) ;
2021 Directory . CreateDirectory ( outputDirectory ) ;
2122
22- var document = ParseHtml ( html ) ;
23+ var document = await ParseHtml ( html , cancel ) ;
2324 var imagePaths = new List < string > ( ) ;
2425
2526 var pageIndex = 0 ;
@@ -42,12 +43,13 @@ public ConversionResult ConvertToImages(string html, string outputDirectory, Con
4243 /// </summary>
4344 /// <param name="html">The HTML content to render.</param>
4445 /// <param name="options">Conversion options (optional).</param>
46+ /// <param name="cancel">Cancellation token.</param>
4547 /// <returns>List of PNG image data for each page.</returns>
46- public IReadOnlyList < byte [ ] > ConvertToImageData ( string html , ConversionOptions ? options = null )
48+ public async Task < IReadOnlyList < byte [ ] > > ConvertToImageData ( string html , ConversionOptions ? options = null , CancellationToken cancel = default )
4749 {
4850 options ??= new ( ) ;
4951
50- var document = ParseHtml ( html ) ;
52+ var document = await ParseHtml ( html , cancel ) ;
5153 var imageData = new List < byte [ ] > ( ) ;
5254
5355 RenderPages ( document , options , writePng =>
@@ -60,12 +62,12 @@ public IReadOnlyList<byte[]> ConvertToImageData(string html, ConversionOptions?
6062 return imageData ;
6163 }
6264
63- static ParsedDocument ParseHtml ( string html )
65+ static async Task < ParsedDocument > ParseHtml ( string html , CancellationToken cancel )
6466 {
65- var elements = HtmlParser . Parse ( html ) ;
66- return new ParsedDocument
67+ var elements = await HtmlParser . Parse ( html , cancel ) ;
68+ return new ( )
6769 {
68- PageSettings = new PageSettings
70+ PageSettings = new ( )
6971 {
7072 WidthPoints = DefaultPageSize . WidthPoints ,
7173 HeightPoints = DefaultPageSize . HeightPoints ,
0 commit comments