@turbodocx/html-to-docx 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  @turbodocx/html-to-docx
4
4
  ====================
5
5
  [![NPM Version][npm-image]][npm-url]
6
+ [![CodeQL](https://github.com/TurboDocx/html-to-docx/workflows/CodeQL/badge.svg)](https://github.com/TurboDocx/html-to-docx/actions/workflows/codeql.yml)
6
7
  [![GitHub Stars](https://img.shields.io/github/stars/turbodocx/html-to-docx?style=social)](https://github.com/turbodocx/html-to-docx)
7
8
  [![Type Script](https://shields.io/badge/TypeScript-3178C6?logo=TypeScript&logoColor=FFF&style=flat-square)](https://typescript.org)
8
9
  [![Discord](https://img.shields.io/badge/Discord-Join%20Us-7289DA?logo=discord)](https://discord.gg/NYKwz4BcpX)
@@ -88,6 +89,22 @@ async function withOptions() {
88
89
  });
89
90
  }
90
91
 
92
+ // With image processing options
93
+ async function withImageOptions() {
94
+ const htmlWithImages = `<div>
95
+ <img src="https://example.com/image.jpg" alt="Example">
96
+ </div>`;
97
+
98
+ const docx = await HtmlToDocx(htmlWithImages, null, {
99
+ imageProcessing: {
100
+ maxRetries: 3, // Retry failed image downloads up to 3 times
101
+ verboseLogging: true, // Enable detailed logging for debugging
102
+ downloadTimeout: 10000, // 10 second timeout per download attempt
103
+ maxImageSize: 5242880 // 5MB max image size
104
+ }
105
+ });
106
+ }
107
+
91
108
  // With all parameters
92
109
  async function complete() {
93
110
  const headerHtml = "<p>Document Header</p>";
@@ -219,6 +236,17 @@ full fledged examples can be found under `example/`
219
236
  - `direction` <?[String]> text direction for RTL (right-to-left) languages. Set to `'rtl'` for Arabic, Hebrew, etc. Defaults to `'ltr'`.
220
237
  - `preProcessing` <?[Object]>
221
238
  - `skipHTMLMinify` <?[Boolean]> flag to skip minification of HTML. Defaults to `false`.
239
+ - `imageProcessing` <?[Object]>
240
+ - `maxRetries` <?[Number]> maximum number of retry attempts for failed image downloads. Defaults to `2`.
241
+ - `verboseLogging` <?[Boolean]> flag to enable detailed logging of image processing operations. Defaults to `false`.
242
+ - `downloadTimeout` <?[Number]> timeout in milliseconds for each image download attempt. Defaults to `5000` (5 seconds).
243
+ - `maxImageSize` <?[Number]> maximum allowed image size in bytes. Defaults to `10485760` (10MB).
244
+ - `retryDelayBase` <?[Number]> base delay in milliseconds for exponential backoff between retries. Defaults to `500` (500ms).
245
+ - `minTimeout` <?[Number]> minimum timeout in milliseconds. Defaults to `1000` (1 second).
246
+ - `maxTimeout` <?[Number]> maximum timeout in milliseconds. Defaults to `30000` (30 seconds).
247
+ - `minImageSize` <?[Number]> minimum image size in bytes. Defaults to `1024` (1KB).
248
+ - `maxCacheSize` <?[Number]> maximum total cache size in bytes (LRU cache limit to prevent OOM). Defaults to `20971520` (20MB).
249
+ - `maxCacheEntries` <?[Number]> maximum number of unique images in cache (LRU eviction). Defaults to `100`.
222
250
  - `footerHTMLString` <[String]> clean html string equivalent of footer. Defaults to `<p></p>` if footer flag is `true`.
223
251
 
224
252
  ### Returns