@turbodocx/html-to-docx 1.15.3 → 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 +39 -0
- package/dist/html-to-docx.esm.js +2 -2
- package/dist/html-to-docx.umd.js +2 -2
- package/index.d.ts +31 -0
- package/package.json +20 -7
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
|
+
[](https://github.com/TurboDocx/html-to-docx/actions/workflows/codeql.yml)
|
|
6
7
|
[](https://github.com/turbodocx/html-to-docx)
|
|
7
8
|
[](https://typescript.org)
|
|
8
9
|
[](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>";
|
|
@@ -203,11 +220,33 @@ full fledged examples can be found under `example/`
|
|
|
203
220
|
- `restart` <"continuous"|"newPage"|"newSection"> numbering restart strategy. Defaults to `continuous`.
|
|
204
221
|
- `numbering` <?[Object]>
|
|
205
222
|
- `defaultOrderedListStyleType` <?[String]> default ordered list style type. Defaults to `decimal`.
|
|
223
|
+
- `heading` <?[Object]> custom heading styles configuration
|
|
224
|
+
- `heading1`-`heading6` <?[Object]> heading style configuration
|
|
225
|
+
- `font` <?[String]> font family
|
|
226
|
+
- `fontSize` <?[Number]> font size in half-points
|
|
227
|
+
- `bold` <?[Boolean]> whether text is bold. Defaults to `true`
|
|
228
|
+
- `spacing` <?[Object]> paragraph spacing configuration
|
|
229
|
+
- `before` <?[Number]> spacing before heading in twips
|
|
230
|
+
- `after` <?[Number]> spacing after heading in twips
|
|
231
|
+
- `keepLines` <?[Boolean]> keep lines together. Defaults to `true`
|
|
232
|
+
- `keepNext` <?[Boolean]> keep with next paragraph. Defaults to `true`
|
|
233
|
+
- `outlineLevel` <?[Number]> outline level (0-5)
|
|
206
234
|
- `decodeUnicode` <?[Boolean]> flag to enable unicode decoding of header, body and footer. Defaults to `false`.
|
|
207
235
|
- `lang` <?[String]> language localization code for spell checker to work properly. Defaults to `en-US`.
|
|
208
236
|
- `direction` <?[String]> text direction for RTL (right-to-left) languages. Set to `'rtl'` for Arabic, Hebrew, etc. Defaults to `'ltr'`.
|
|
209
237
|
- `preProcessing` <?[Object]>
|
|
210
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`.
|
|
211
250
|
- `footerHTMLString` <[String]> clean html string equivalent of footer. Defaults to `<p></p>` if footer flag is `true`.
|
|
212
251
|
|
|
213
252
|
### Returns
|