@@ -58,20 +58,20 @@ public HtmlConverter(MainDocumentPart mainPart, IWebRequest? webRequester = null
5858 }
5959
6060 /// <summary>
61- /// Parse some HTML content where the output is intented to be inserted in <see cref="MainDocumentPart"/>.
61+ /// Parse some HTML content where the output is intended to be inserted in <see cref="MainDocumentPart"/>.
6262 /// </summary>
6363 /// <param name="html">The HTML content to parse</param>
6464 /// <returns>Returns a list of parsed paragraph.</returns>
6565 public IList < OpenXmlCompositeElement > Parse ( string html )
6666 {
67- bodyImageLoader ??= new ImagePrefetcher < MainDocumentPart > ( mainPart , webRequester ) ;
67+ bodyImageLoader ??= new ImagePrefetcher < MainDocumentPart > ( mainPart , webRequester , ImageProcessing ) ;
6868 return ParseCoreAsync ( html , mainPart , bodyImageLoader ,
6969 new ParallelOptions ( ) { CancellationToken = CancellationToken . None } )
7070 . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) . ToList ( ) ;
7171 }
7272
7373 /// <summary>
74- /// Start the asynchroneous parse processing where the output is intented to be inserted in <see cref="MainDocumentPart"/>.
74+ /// Start the asynchronous parse processing where the output is intended to be inserted in <see cref="MainDocumentPart"/>.
7575 /// </summary>
7676 /// <param name="html">The HTML content to parse</param>
7777 /// <param name="cancellationToken">The cancellation token.</param>
@@ -84,7 +84,7 @@ public Task<IEnumerable<OpenXmlCompositeElement>> Parse(string html, Cancellatio
8484 }
8585
8686 /// <summary>
87- /// Start the asynchroneous parse processing where the output is intented to be inserted in <see cref="MainDocumentPart"/>.
87+ /// Start the asynchronous parse processing where the output is intended to be inserted in <see cref="MainDocumentPart"/>.
8888 /// </summary>
8989 /// <param name="html">The HTML content to parse</param>
9090 /// <param name="cancellationToken">The cancellation token.</param>
@@ -95,20 +95,20 @@ public Task<IEnumerable<OpenXmlCompositeElement>> ParseAsync(string html, Cancel
9595 }
9696
9797 /// <summary>
98- /// Start the asynchroneous parse processing where the output is intented to be inserted in <see cref="MainDocumentPart"/>.
98+ /// Start the asynchronous parse processing where the output is intended to be inserted in <see cref="MainDocumentPart"/>.
9999 /// </summary>
100100 /// <param name="html">The HTML content to parse</param>
101101 /// <param name="parallelOptions">The configuration of parallelism while downloading the remote resources.</param>
102102 /// <returns>Returns a list of parsed paragraph.</returns>
103103 public Task < IEnumerable < OpenXmlCompositeElement > > ParseAsync ( string html , ParallelOptions parallelOptions )
104104 {
105- bodyImageLoader ??= new ImagePrefetcher < MainDocumentPart > ( mainPart , webRequester ) ;
105+ bodyImageLoader ??= new ImagePrefetcher < MainDocumentPart > ( mainPart , webRequester , ImageProcessing ) ;
106106
107107 return ParseCoreAsync ( html , mainPart , bodyImageLoader , parallelOptions ) ;
108108 }
109109
110110 /// <summary>
111- /// Parse asynchroneously the Html and append the output into the Header of the document.
111+ /// Parse asynchronously the Html and append the output into the Header of the document.
112112 /// </summary>
113113 /// <param name="html">The HTML content to parse</param>
114114 /// <param name="headerType">Determines the page(s) on which the current header shall be displayed.
@@ -122,7 +122,7 @@ public async Task ParseHeader(string html, HeaderFooterValues? headerType = null
122122 var headerPart = ResolveHeaderFooterPart < HeaderReference , HeaderPart > ( headerType ) ;
123123
124124 headerPart . Header ??= new ( ) ;
125- headerImageLoader ??= new ImagePrefetcher < HeaderPart > ( headerPart , webRequester ) ;
125+ headerImageLoader ??= new ImagePrefetcher < HeaderPart > ( headerPart , webRequester , ImageProcessing ) ;
126126
127127 var paragraphs = await ParseCoreAsync ( html , headerPart , headerImageLoader ,
128128 new ParallelOptions ( ) { CancellationToken = cancellationToken } ,
@@ -133,7 +133,7 @@ public async Task ParseHeader(string html, HeaderFooterValues? headerType = null
133133 }
134134
135135 /// <summary>
136- /// Parse asynchroneously the Html and append the output into the Footer of the document.
136+ /// Parse asynchronously the Html and append the output into the Footer of the document.
137137 /// </summary>
138138 /// <param name="html">The HTML content to parse</param>
139139 /// <param name="footerType">Determines the page(s) on which the current footer shall be displayed.
@@ -147,7 +147,7 @@ public async Task ParseFooter(string html, HeaderFooterValues? footerType = null
147147 var footerPart = ResolveHeaderFooterPart < FooterReference , FooterPart > ( footerType ) ;
148148
149149 footerPart . Footer ??= new ( ) ;
150- footerImageLoader ??= new ImagePrefetcher < FooterPart > ( footerPart , webRequester ) ;
150+ footerImageLoader ??= new ImagePrefetcher < FooterPart > ( footerPart , webRequester , ImageProcessing ) ;
151151
152152 var paragraphs = await ParseCoreAsync ( html , footerPart , footerImageLoader ,
153153 new ParallelOptions ( ) { CancellationToken = cancellationToken } ,
@@ -158,14 +158,14 @@ public async Task ParseFooter(string html, HeaderFooterValues? footerType = null
158158 }
159159
160160 /// <summary>
161- /// Parse asynchroneously the Html and append the output into the Body of the document.
161+ /// Parse asynchronously the Html and append the output into the Body of the document.
162162 /// </summary>
163163 /// <param name="html">The HTML content to parse</param>
164164 /// <param name="cancellationToken">The cancellation token.</param>
165165 /// <seealso cref="MainDocumentPart"/>
166166 public async Task ParseBody ( string html , CancellationToken cancellationToken = default )
167167 {
168- bodyImageLoader ??= new ImagePrefetcher < MainDocumentPart > ( mainPart , webRequester ) ;
168+ bodyImageLoader ??= new ImagePrefetcher < MainDocumentPart > ( mainPart , webRequester , ImageProcessing ) ;
169169 var paragraphs = await ParseCoreAsync ( html , mainPart , bodyImageLoader ,
170170 new ParallelOptions ( ) { CancellationToken = cancellationToken } ,
171171 htmlStyles . GetParagraphStyle ( htmlStyles . DefaultStyles . Paragraph ) )
@@ -201,7 +201,7 @@ public async Task ParseBody(string html, CancellationToken cancellationToken = d
201201 }
202202
203203 /// <summary>
204- /// Start the asynchroneous parse processing. Use this overload if you want to control the downloading of images.
204+ /// Start the asynchronous parse processing. Use this overload if you want to control the downloading of images.
205205 /// </summary>
206206 /// <param name="html">The HTML content to parse</param>
207207 /// <param name="parallelOptions">The configuration of parallelism while downloading the remote resources.</param>
@@ -210,13 +210,13 @@ public async Task ParseBody(string html, CancellationToken cancellationToken = d
210210 [ System . Diagnostics . CodeAnalysis . ExcludeFromCodeCoverage ]
211211 public Task < IEnumerable < OpenXmlCompositeElement > > Parse ( string html , ParallelOptions parallelOptions )
212212 {
213- bodyImageLoader ??= new ImagePrefetcher < MainDocumentPart > ( mainPart , webRequester ) ;
213+ bodyImageLoader ??= new ImagePrefetcher < MainDocumentPart > ( mainPart , webRequester , ImageProcessing ) ;
214214
215215 return ParseCoreAsync ( html , mainPart , bodyImageLoader , parallelOptions ) ;
216216 }
217217
218218 /// <summary>
219- /// Start the asynchroneous parse processing and append the output into the Body of the document.
219+ /// Start the asynchronous parse processing and append the output into the Body of the document.
220220 /// </summary>
221221 /// <param name="html">The HTML content to parse</param>
222222 /// <param name="cancellationToken">The cancellation token.</param>
@@ -236,7 +236,7 @@ public void RefreshStyles()
236236 }
237237
238238 /// <summary>
239- /// Start the asynchroneous parse processing. Use this overload if you want to control the downloading of images.
239+ /// Start the asynchronous parse processing. Use this overload if you want to control the downloading of images.
240240 /// </summary>
241241 /// <param name="html">The HTML content to parse</param>
242242 /// <param name="hostingPart">The OpenXml container where the content will be inserted into.</param>
@@ -394,6 +394,26 @@ public WordDocumentStyle HtmlStyles
394394 /// <remarks>The table will contains only one cell.</remarks>
395395 public bool RenderPreAsTable { get ; set ; }
396396
397+ /// <summary>
398+ /// Gets or sets how images should be processed during conversion.
399+ /// </summary>
400+ /// <remarks>
401+ /// <para>
402+ /// Use <see cref="ImageProcessingMode.Embed"/> (default) to download and embed all images,
403+ /// creating self-contained documents but potentially large file sizes.
404+ /// </para>
405+ /// <para>
406+ /// Use <see cref="ImageProcessingMode.LinkExternal"/> to link to external images via relationships,
407+ /// keeping document size small but requiring internet access to view images.
408+ /// Data URI images (base64 encoded) are still embedded.
409+ /// </para>
410+ /// <para>
411+ /// Use <see cref="ImageProcessingMode.EmbedDataUriOnly"/> to only embed data URI images
412+ /// and skip external images entirely.
413+ /// </para>
414+ /// </remarks>
415+ public ImageProcessingMode ImageProcessing { get ; set ; } = ImageProcessingMode . Embed ;
416+
397417 /// <summary>
398418 /// Defines whether ordered lists (<c>ol</c>) continue incrementing existing numbering
399419 /// or restarts to 1 (defaults continues numbering).
0 commit comments