@@ -13,11 +13,12 @@ public abstract class DocumentConverter
1313 /// <param name="docxPath">Path to the DOCX file.</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 docxPath , string outputDirectory , ConversionOptions ? options = null )
18+ public async Task < ConversionResult > ConvertToImages ( string docxPath , string outputDirectory , ConversionOptions ? options = null , CancellationToken cancel = default )
1819 {
1920 using var stream = File . OpenRead ( docxPath ) ;
20- return ConvertToImages ( stream , outputDirectory , options ) ;
21+ return await ConvertToImages ( stream , outputDirectory , options , cancel ) ;
2122 }
2223
2324 /// <summary>
@@ -26,13 +27,14 @@ public ConversionResult ConvertToImages(string docxPath, string outputDirectory,
2627 /// <param name="docxStream">Stream containing the DOCX document.</param>
2728 /// <param name="outputDirectory">Directory where PNG files will be saved.</param>
2829 /// <param name="options">Conversion options (optional).</param>
30+ /// <param name="cancel">Cancellation token.</param>
2931 /// <returns>Result containing paths to generated images and page count.</returns>
30- public ConversionResult ConvertToImages ( Stream docxStream , string outputDirectory , ConversionOptions ? options = null )
32+ public async Task < ConversionResult > ConvertToImages ( Stream docxStream , string outputDirectory , ConversionOptions ? options = null , CancellationToken cancel = default )
3133 {
3234 options ??= new ( ) ;
3335 Directory . CreateDirectory ( outputDirectory ) ;
3436
35- var document = parser . Parse ( docxStream ) ;
37+ var document = await parser . Parse ( docxStream , cancel ) ;
3638 var imagePaths = new List < string > ( ) ;
3739
3840 var pageIndex = 0 ;
@@ -55,24 +57,26 @@ public ConversionResult ConvertToImages(Stream docxStream, string outputDirector
5557 /// </summary>
5658 /// <param name="docxPath">Path to the DOCX file.</param>
5759 /// <param name="options">Conversion options (optional).</param>
60+ /// <param name="cancel">Cancellation token.</param>
5861 /// <returns>List of PNG image data for each page.</returns>
59- public IReadOnlyList < byte [ ] > ConvertToImageData ( string docxPath , ConversionOptions ? options = null )
62+ public async Task < IReadOnlyList < byte [ ] > > ConvertToImageData ( string docxPath , ConversionOptions ? options = null , CancellationToken cancel = default )
6063 {
6164 using var stream = File . OpenRead ( docxPath ) ;
62- return ConvertToImageData ( stream , options ) ;
65+ return await ConvertToImageData ( stream , options , cancel ) ;
6366 }
6467
6568 /// <summary>
6669 /// Converts a DOCX stream to PNG image data in memory.
6770 /// </summary>
6871 /// <param name="docxStream">Stream containing the DOCX document.</param>
6972 /// <param name="options">Conversion options (optional).</param>
73+ /// <param name="cancel">Cancellation token.</param>
7074 /// <returns>List of PNG image data for each page.</returns>
71- public IReadOnlyList < byte [ ] > ConvertToImageData ( Stream docxStream , ConversionOptions ? options = null )
75+ public async Task < IReadOnlyList < byte [ ] > > ConvertToImageData ( Stream docxStream , ConversionOptions ? options = null , CancellationToken cancel = default )
7276 {
7377 options ??= new ( ) ;
7478
75- var document = parser . Parse ( docxStream ) ;
79+ var document = await parser . Parse ( docxStream , cancel ) ;
7680 var imageData = new List < byte [ ] > ( ) ;
7781
7882 RenderPages ( document , options , writePng =>
0 commit comments