advanced-html-to-docx 1.0.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 ADDED
@@ -0,0 +1,110 @@
1
+ html-to-docx
2
+ ============
3
+
4
+ html-to-docx converts HTML content to a DOCX file. It runs in Node.js and produces a buffer/blob that you can write to disk.
5
+
6
+ ## Installation
7
+
8
+ Install from local source or your preferred distribution method.
9
+
10
+ ## Usage
11
+
12
+ ```js
13
+ const fileBuffer = await HTMLtoDOCX(htmlString, headerHTMLString, documentOptions, footerHTMLString);
14
+ ```
15
+
16
+ Examples are under `example/`.
17
+
18
+ ## Header, Footer, Page Number
19
+
20
+ - Enable with `header: true` and/or `footer: true` in `documentOptions`.
21
+ - `headerHTMLString` and `footerHTMLString` should be simple HTML. Use a top-level `<p>` for reliable rendering.
22
+ - Page numbers are appended to the first footer paragraph when `pageNumber: true` is set.
23
+
24
+ ## Supported HTML (Common)
25
+
26
+ - Headings: `h1` to `h6`
27
+ - Text: `p`, `span`, `strong`, `b`, `i`, `u`, `s`, `del`, `strike`, `sub`, `sup`
28
+ - Lists: `ol`, `ul`, `li`
29
+ - Tables: `table`, `thead`, `tbody`, `tr`, `td`, `th`, `colgroup`, `col`
30
+ - Images: `img` (base64 data URLs are supported; external URLs require network access)
31
+ - Blockquote: `blockquote`
32
+ - Page break: `<div class="page-break" style="page-break-after: always;"></div>`
33
+
34
+ ## Lists
35
+
36
+ `list-style-type` on `<ol>` is supported:
37
+
38
+ ```
39
+ <ol style="list-style-type:lower-alpha;">
40
+ <li>List item</li>
41
+ </ol>
42
+ ```
43
+
44
+ Supported ordered list styles:
45
+ - upper-alpha
46
+ - lower-alpha
47
+ - upper-roman
48
+ - lower-roman
49
+ - lower-alpha-bracket-end
50
+ - decimal-bracket-end
51
+ - decimal-bracket
52
+ - decimal (default)
53
+
54
+ To start at a specific value, set `data-start="n"`. Example: `<ol data-start="3">` starts at `c.` for lower-alpha.
55
+
56
+ ## Tables
57
+
58
+ Table widths are based on `width` in pixels, cm, or inches. Column widths can be set on `<col>` or on cells:
59
+
60
+ ```
61
+ <table style="width: 600px; table-layout: fixed;">
62
+ <tr>
63
+ <td style="width: 200px;">Col 1</td>
64
+ <td style="width: 200px;">Col 2</td>
65
+ <td style="width: 200px;">Col 3</td>
66
+ </tr>
67
+ </table>
68
+ ```
69
+
70
+ ## Images
71
+
72
+ Use base64 data URLs for reliable output:
73
+
74
+ ```
75
+ <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" />
76
+ ```
77
+
78
+ External image URLs depend on network access and may be blocked in some environments.
79
+
80
+ ## Document Options
81
+
82
+ - `orientation`: `portrait` or `landscape`
83
+ - `pageSize`: `{ width, height }` (TWIP or px/cm/in)
84
+ - `margins`: `{ top, right, bottom, left, header, footer, gutter }`
85
+ - `headerType`: `default`, `first`, `even`
86
+ - `footerType`: `default`, `first`, `even`
87
+ - `header`: boolean
88
+ - `footer`: boolean
89
+ - `pageNumber`: boolean (only if footer is enabled)
90
+ - `font`, `fontSize`, `complexScriptFontSize`
91
+ - `table.row.cantSplit`: boolean
92
+ - `skipFirstHeaderFooter`: boolean
93
+ - `lineNumber`, `lineNumberOptions`
94
+ - `numbering.defaultOrderedListStyleType`
95
+ - `decodeUnicode`: boolean
96
+ - `lang`: language code
97
+
98
+ ## Returns
99
+
100
+ `Promise<Buffer|Blob>`
101
+
102
+ ## Notes
103
+
104
+ - Font family mapping varies across word processors.
105
+ - For browser usage, a blob polyfill may be required.
106
+
107
+ ## License
108
+
109
+ MIT
110
+