@docx-editor.dev/docx-to-pdf 0.0.1 → 2.23.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/LICENSE.md ADDED
@@ -0,0 +1,121 @@
1
+ # EigenPal Pro Evaluation License 1.0
2
+
3
+ Copyright (c) 2026 EigenPal, Inc. All rights reserved.
4
+
5
+ By copying, modifying, or using the Software, you agree to these terms.
6
+
7
+ ## 1. Covered Software
8
+
9
+ “Software” means all source code, object code, documentation, assets, and other
10
+ materials contained in the “packages/docx-to-pdf/” directory of the EigenPal DOCX
11
+ Editor repository, except for any material that expressly states that it is
12
+ subject to a different license.
13
+
14
+ ## 2. Evaluation Permission; Modifications
15
+
16
+ Subject to these terms, EigenPal, Inc. grants you a limited, non-exclusive,
17
+ non-transferable, non-sublicensable, royalty-free license to:
18
+
19
+ 1. view, clone, and copy the Software;
20
+ 2. run the Software internally in a non-production environment solely to
21
+ evaluate its suitability for your intended application; and
22
+ 3. modify the Software solely as reasonably necessary for that internal,
23
+ non-production evaluation.
24
+
25
+ For any such modification, the following applies:
26
+
27
+ You may keep any modification to yourself. If you do not disclose it to EigenPal, Inc. or to anyone else, it remains yours
28
+ If you disclose a modification to EigenPal, Inc. or to any third party, in any form, you assign all right, title, and interest in it to EigenPal, Inc. at the moment of disclosure. The same applies to any feedback you give EigenPal, Inc. You will promptly send EigenPal, Inc. the source code of any modification you disclose, and will sign any document needed to record the assignment.
29
+ Disclosing a modification to a third party grants that third party no rights in it or in the Software. You will not license or purport to license any modification to anyone.
30
+ You may continue using an assigned modification for the internal, non-production evaluation permitted by Section 2 for as long as this license is in effect. EigenPal, Inc. is not obliged to use or support any modification or feedback, and owes you nothing for it.
31
+ You confirm that any modification or feedback you disclose is yours to assign and is not subject to any license that would impose obligations on EigenPal, Inc. or grant rights to any third party.
32
+
33
+
34
+ No other rights are granted.
35
+
36
+ ## 3. No Production Use
37
+
38
+ You may not use the Software for Production Use.
39
+
40
+ “Production Use” means any use of the Software:
41
+
42
+ 1. in a live, operational, or customer-facing environment;
43
+ 2. to provide, operate, support, or enhance a product or service for another
44
+ person or organization;
45
+ 3. to process live, customer, or business-operational data; or
46
+ 4. as part of your ordinary internal business operations, other than evaluation
47
+ and testing.
48
+
49
+ For the avoidance of doubt, Production Use includes embedding the Software in a product made available to
50
+ others, offering the Software through a hosted or managed service, and using it
51
+ in a customer pilot or paid proof of concept.
52
+
53
+ ## 4. No Distribution or Sublicensing
54
+
55
+ You may not sell, sublicense, distribute, publish, transfer, or otherwise make
56
+ the Software or modifications to the Software available to any third party.
57
+
58
+ You may allow your employees and contractors to access the Software solely for
59
+ your evaluation, provided they are bound by restrictions at least as protective
60
+ as these terms. You are responsible for their compliance.
61
+
62
+ ## 5. Commercial Rights
63
+
64
+ Production Use and any rights not expressly granted by this license require a
65
+ separate written commercial agreement signed by EigenPal, Inc.
66
+
67
+ Commercial licenses are available by contacting licensing@eigenpal.com.
68
+
69
+ Access to the Software, correspondence with EigenPal, Inc., or payment of an
70
+ invoice does not by itself grant production or commercial rights unless those
71
+ rights are set out in a written agreement signed by EigenPal, Inc.
72
+
73
+ ## 6. Ownership
74
+
75
+ EigenPal, Inc. and its licensors retain all rights, title, and interest in the
76
+ Software. This license does not transfer ownership or grant any rights by
77
+ implication.
78
+
79
+ Modifying the Software does not grant you the right to use the Software or those
80
+ modifications in production.
81
+
82
+ ## 7. Termination
83
+
84
+ Your rights under this license terminate automatically if you breach these
85
+ terms or if EigenPal terminates this license.
86
+
87
+ Following termination, you must stop using the Software and delete your copies
88
+ and modifications, except for copies that you are legally required to retain.
89
+ EigenPal, Inc. may reinstate your rights in writing.
90
+
91
+ ## 8. No Warranty
92
+
93
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED “AS IS” AND
94
+ WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS, IMPLIED, OR STATUTORY,
95
+ INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
96
+ TITLE, AND NON-INFRINGEMENT.
97
+
98
+ ## 9. Limitation of Liability
99
+
100
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, EIGENPAL, INC. AND ITS LICENSORS WILL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES, OR FOR ANY LOSS OF DATA, REVENUE, PROFITS, OR BUSINESS, ARISING FROM OR RELATING TO THE SOFTWARE OR THIS LICENSE. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE TOTAL AGGREGATE LIABILITY OF EIGENPAL, INC. AND ITS LICENSORS FOR ALL CLAIMS ARISING FROM OR RELATING TO THE SOFTWARE OR THIS LICENSE, WHETHER IN CONTRACT, TORT, STRICT LIABILITY, OR ANY OTHER THEORY, WILL NOT EXCEED TEN UNITED STATES DOLLARS (US$10). THE FOREGOING LIMITATIONS APPLY EVEN IF EIGENPAL, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND EVEN IF ANY LIMITED REMEDY IS FOUND TO HAVE FAILED OF ITS ESSENTIAL PURPOSE.
101
+
102
+ ## 10. Trademarks
103
+
104
+ This license does not grant permission to use the names, trademarks, service
105
+ marks, or logos of EigenPal, Inc., except to identify the origin of an
106
+ unmodified copy of the Software.
107
+
108
+ ## 11. Governing Law and Jurisdiction
109
+
110
+ This license is governed by the laws of the State of California, without regard
111
+ to its conflict-of-laws rules.
112
+
113
+ Any dispute arising from or relating to this license will be subject to the
114
+ exclusive jurisdiction of the state and federal courts located in California,
115
+ and you consent to their jurisdiction.
116
+
117
+ ## 12. Separate Commercial Agreements
118
+
119
+ If EigenPal, Inc. and you enter into a separate written commercial agreement,
120
+ that agreement controls to the extent it grants additional rights or conflicts
121
+ with this license.
package/README.md CHANGED
@@ -1,4 +1,128 @@
1
- # @docx-editor.dev/docx-to-pdf
1
+ # DOCX to PDF
2
2
 
3
- This package name is reserved. The real release is published from
4
- https://github.com/eigenpal/docx-editor.
3
+ `@docx-editor.dev/docx-to-pdf` converts DOCX documents to PDF on Node.js. It uses Core's pagination, font resolution, and positioned glyphs to produce searchable text.
4
+
5
+ The package uses the [EigenPal Pro License](LICENSE.md). Production use requires a commercial agreement.
6
+
7
+ ## Before you begin
8
+
9
+ Use Node.js 20.16.0 or later in the 20.x release line, or Node.js 22.3.0 or later. The converter needs WebAssembly and its packaged font assets. Install a compatible `@docx-editor.dev/core` peer alongside the converter. Keep one Core copy in your application.
10
+
11
+ ## Install the package
12
+
13
+ ```sh
14
+ npm install @docx-editor.dev/docx-to-pdf @docx-editor.dev/core
15
+ ```
16
+
17
+ For Chinese, Japanese, or Korean text, supply suitable fonts or install the optional `@docx-editor.dev/fonts-cjk` package. The converter finds the package without configuration.
18
+
19
+ If you previously relied on bundled CJK coverage, add the optional package to your production dependencies. For installation and deployment details, see [Configure PDF fonts](docs/fonts.md).
20
+
21
+ ## Convert a document
22
+
23
+ ```ts
24
+ import { readFile, writeFile } from 'node:fs/promises';
25
+ import { exportPdf } from '@docx-editor.dev/docx-to-pdf';
26
+
27
+ const source = await readFile('document.docx');
28
+ const result = await exportPdf(source, {
29
+ displayMode: 'proposed',
30
+ comments: true,
31
+ });
32
+
33
+ await writeFile('document.pdf', result.bytes);
34
+ ```
35
+
36
+ Conversion preserves the source DOCX. Browser applications must send the document to a Node.js server for conversion.
37
+
38
+ ## Reuse a layout
39
+
40
+ Use `openDocumentForExport` and `exportPdfFrom` to reuse font resolution and layout. The session also works with Markdown's `exportMarkdownFrom`. Dispose the session after all exports, including failed exports. For an example, see [Compare PDF and Markdown conversion](docs/markdown-contract.md#reuse-one-session).
41
+
42
+ ## Configure output
43
+
44
+ | Option | Default | Behavior |
45
+ | --- | --- | --- |
46
+ | `fidelityPolicy` | `'strict'` | Rejects unsupported or approximate output. Use `'best-effort'` to return available output with diagnostics. |
47
+ | `displayMode` | `'proposed'` | Includes proposed revisions. Use `'original'` for the original content or `'all-markup'` to show revisions. |
48
+ | `comments` | `true` | Includes native PDF annotations. Set to `false` to omit them. |
49
+ | `useSystemFonts` | `true` | Searches standard operating system directories for supported font files. Set to `false` to disable this search. |
50
+ | `timeoutMs` | `60000` | Sets the conversion deadline in milliseconds. |
51
+ | `maxOutputBytes` | `67108864` | Limits output to 64 MiB. You can lower this limit. |
52
+ | `maxPages` | `10000` | Limits output pages after layout. You can lower this limit. |
53
+ | `signal` | — | Cancels conversion through an `AbortSignal`. |
54
+
55
+ The result includes `bytes`, `pageCount`, `layoutRevision`, `displayMode`, `fontResolution`, `diagnostics`, and `timings`. Timings report milliseconds spent opening the document, laying out pages, painting content, and encoding the PDF. Each result owns its byte buffer.
56
+
57
+ ### Fonts
58
+
59
+ Use `fonts` to provide font sources before the installed and packaged sources. Use `fallbackFonts` to add sources after the packaged fonts. The exporter also reads embedded fonts before using a generic substitute for an unresolved family. Use `lastResortFonts` after embedded fonts and before generic substitutes.
60
+
61
+ `glyphFallbacks` specifies an ordered list of fonts for missing glyphs. The defaults cover symbols, Arabic, Hebrew, mathematics, and color emoji. They also cover CJK text when `@docx-editor.dev/fonts-cjk` is installed. Emoji from a COLR font retain their palette colors and extractable text.
62
+
63
+ Core's `fontPolicy` controls failed font sources and incomplete face coverage. Generic substitutions can change line breaks and page count, so strict export rejects them with a `font-substitution` diagnostic. Best-effort export uses the substitute and reports it. Inspect `result.fontResolution` for the selected fonts.
64
+
65
+ For custom font files and policy choices, see [Configure PDF fonts](docs/fonts.md).
66
+
67
+ ### Comments
68
+
69
+ Comments become range highlights or text notes. PDF viewers determine whether they display authors, dates, replies, and resolved state. Cross-page comments create an annotation on each affected page. Comments without a visible anchor become labeled notes on the first page.
70
+
71
+ Editing PDF annotations does not update the DOCX.
72
+
73
+ ## Supported content
74
+
75
+ - Searchable multilingual text, small caps, text decorations, and tab leaders.
76
+ - Arabic joining across formatting runs and logical word order for Arabic, Persian, and Hebrew text extraction.
77
+ - Synthetic bold and italic when selected font faces lack those variants.
78
+ - Static TrueType and CFF fonts, including selected faces from font collections.
79
+ - Page sizes, page frames, headers, footers, footnotes, and endnotes.
80
+ - Text and image list markers, paragraph fills, and paragraph borders.
81
+ - Table text, shading, and resolved borders.
82
+ - Textboxes and structured equations.
83
+ - Supported vector shapes, horizontal and vertical lines, and outlines that retain their full width.
84
+ - PNG and JPEG images with cropping, transforms, alpha transparency, and fixed opacity.
85
+ - Links, destinations, document metadata, and comments.
86
+
87
+ The converter reads PNG and JPEG images even when DOCX metadata declares another supported raster format. Supported declarations include PNG, JPEG, GIF, BMP, and WebP.
88
+
89
+ ## Limitations
90
+
91
+ Charts, rotated table-cell text, unsupported equation fallbacks, advanced image effects, some revision presentation, and non-PNG/JPEG media produce diagnostics. Brightness and grayscale adjustments are not supported.
92
+
93
+ The writer rejects variable fonts, missing glyphs, prohibited embedding, fonts that prohibit subsetting, and font containers that cannot be encoded. Tagged PDF, PDF/A, encryption, and forms are not supported.
94
+
95
+ ## Errors and resource limits
96
+
97
+ | Error | Cause |
98
+ | --- | --- |
99
+ | `PdfDocumentOpenError` | Core rejected the input document. Inspect `reason` and `detail`. |
100
+ | `PdfFidelityError` | Strict export encountered unsupported or approximate content. Inspect `diagnostics`. |
101
+ | `ExportResourceError` | Cancellation, deadlines, font-policy refusals, or layout failures. Inspect `code`. |
102
+ | `PdfWorkLimitError` | Content exceeded a processing limit. |
103
+ | `PdfOutputLimitError` | Encoded bytes exceeded `maxOutputBytes`. Inspect `limit` and `actual`. Extends `PdfEncodingError`. |
104
+ | `PdfPageLimitError` | Layout exceeded `maxPages`. Inspect `limit` and `actual`. Extends `RangeError`. |
105
+ | `PdfEncodingError` | PDF encoding failed. Inspect `cause`. |
106
+ | `TypeError` or `RangeError` | An argument is invalid or a size limit was exceeded. |
107
+
108
+ The writer compresses content streams and embeds font subsets. It retains layout records and font data until conversion finishes. Core's resource limits also apply.
109
+
110
+ Cancellation is checked between layout, paint, and encoding batches. Synchronous font and image operations cannot be interrupted mid-call. For a hard deadline or heap limit, run conversion in a worker and configure `resourceLimits.maxOldGenerationSizeMb`.
111
+
112
+ ## Developer guides
113
+
114
+ - [Compare PDF and Markdown conversion](docs/markdown-contract.md): shared controls and intentional differences.
115
+ - [PDF export API](docs/api.md): options, result fields, diagnostics, stable error codes, and resource boundaries.
116
+ - [Configure PDF fonts](docs/fonts.md): custom files, source order, policies, and troubleshooting.
117
+ - [Integrate PDF conversion](docs/integrations.md): HTTP responses, Next.js, deployment, and batches.
118
+
119
+ ## Run the demo
120
+
121
+ From the repository root, run:
122
+
123
+ ```sh
124
+ bun install
125
+ bun run dev:pdf
126
+ ```
127
+
128
+ Open <http://127.0.0.1:5180>. For upload limits, server configuration, and production commands, see the [demo README](../../examples/docx-to-pdf/README.md).
@@ -0,0 +1,32 @@
1
+ # Third-party notices
2
+
3
+ `@docx-editor.dev/docx-to-pdf` is distributed under LicenseRef-EigenPal-Pro-Evaluation-1.0. Its published bundles also contain
4
+ source from the open-source packages listed below, redistributed here under
5
+ their own licenses, reproduced in full.
6
+
7
+ Those copies are not verbatim. The build inlines, minifies and tree-shakes
8
+ them, and includes only the parts each bundle reaches, so what ships is a
9
+ modified form of the original source.
10
+
11
+ The terms of LicenseRef-EigenPal-Pro-Evaluation-1.0 do not apply to the portions of these bundles
12
+ derived from the packages listed below. Those portions are licensed to you
13
+ under their own terms.
14
+
15
+ This file covers code copied INTO the published bundles. Packages this one
16
+ declares as `dependencies` or `peerDependencies` are installed separately by
17
+ the consumer and are not repeated here.
18
+
19
+ Generated by `bun run notices:generate` from the build's esbuild metafile.
20
+ Do not edit by hand.
21
+
22
+ This package also ships prebuilt third-party assets that are not esbuild inputs,
23
+ so they cannot appear below. Their licenses travel with the package in
24
+ `licenses/`:
25
+
26
+ - `licenses/NotoEmoji-OFL.txt`
27
+ - `licenses/NotoSansArabic-OFL.txt`
28
+ - `licenses/NotoSansMath-OFL.txt`
29
+ - `licenses/NotoSansSymbols2-OFL.txt`
30
+ - `licenses/TwemojiMozilla-LICENSE.md`
31
+
32
+ No third-party code is bundled into this package.
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ # PDF fallback fonts
2
+
3
+ These third-party fonts load from local files. Conversion does not download fonts. The resolver can also use installed fonts from supported operating system directories; installed fonts are not redistributed.
4
+
5
+ The Noto fonts use the SIL Open Font License. Twemoji Mozilla uses the Apache License 2.0 for code and CC BY 4.0 for emoji artwork. Original licenses are in [`../licenses/`](../licenses/). [`sources.json`](sources.json) records source URLs and SHA-256 hashes.
6
+
7
+ Noto Emoji and Noto Sans Arabic are static instances generated with FontTools `instantiateVariableFont` at weight 400. The Arabic instance also uses width 100. The remaining fonts are unchanged upstream binaries. PDF export creates subsets for each document.
Binary file
@@ -0,0 +1,60 @@
1
+ {
2
+ "NotoEmoji.variable.ttf": {
3
+ "url": "https://raw.githubusercontent.com/google/fonts/main/ofl/notoemoji/NotoEmoji%5Bwght%5D.ttf",
4
+ "sha256": "de6c18832938afc99caf132b39d6a30a19bac7f2e812e28db2535b4608d27551"
5
+ },
6
+ "NotoEmoji-OFL.txt": {
7
+ "url": "https://raw.githubusercontent.com/google/fonts/main/ofl/notoemoji/OFL.txt",
8
+ "sha256": "500bb1ccf43df7bbb522112f9133a52b16e1c35e809632f5d8609b179152de5b"
9
+ },
10
+ "NotoSansMath-Regular.ttf": {
11
+ "url": "https://raw.githubusercontent.com/google/fonts/main/ofl/notosansmath/NotoSansMath-Regular.ttf",
12
+ "sha256": "3f495fe933c06786e4d5f6d86b8ee70b6753a68ee3b9d87528726de0f6e2c47d",
13
+ "installedSha256": "3f495fe933c06786e4d5f6d86b8ee70b6753a68ee3b9d87528726de0f6e2c47d"
14
+ },
15
+ "NotoSansMath-OFL.txt": {
16
+ "url": "https://raw.githubusercontent.com/google/fonts/main/ofl/notosansmath/OFL.txt",
17
+ "sha256": "403a95275b469061b7d4371c328e0ada3bc7d63328abe2e88aad5cd243b2fe21"
18
+ },
19
+ "NotoSansArabic.variable.ttf": {
20
+ "url": "https://raw.githubusercontent.com/google/fonts/main/ofl/notosansarabic/NotoSansArabic%5Bwdth,wght%5D.ttf",
21
+ "sha256": "63111b5b2e074dd48cc67692e0a2726d86ee94c1c37fe8598257b7b4e87e869e"
22
+ },
23
+ "NotoSansArabic-OFL.txt": {
24
+ "url": "https://raw.githubusercontent.com/google/fonts/main/ofl/notosansarabic/OFL.txt",
25
+ "sha256": "07fc70bfeb985cc1a87a8587d0a0c80bab11c86c9dc3fd95b6f0cb332f983e96"
26
+ },
27
+ "NotoSansSymbols2-Regular.ttf": {
28
+ "url": "https://raw.githubusercontent.com/google/fonts/main/ofl/notosanssymbols2/NotoSansSymbols2-Regular.ttf",
29
+ "sha256": "7d5fb73b7ca67a6798101741f5d280a3d016a56a197afcd4199dbb57b4b82a21",
30
+ "installedSha256": "7d5fb73b7ca67a6798101741f5d280a3d016a56a197afcd4199dbb57b4b82a21"
31
+ },
32
+ "NotoSansSymbols2-OFL.txt": {
33
+ "url": "https://raw.githubusercontent.com/google/fonts/main/ofl/notosanssymbols2/OFL.txt",
34
+ "sha256": "b118dd41337806a5d4797052c77caf3bd096aed783e5eb21b4d11154351e1ac0"
35
+ },
36
+ "NotoEmoji-Regular.ttf": {
37
+ "derivedFrom": "NotoEmoji.variable.ttf",
38
+ "axes": {
39
+ "wght": 400
40
+ },
41
+ "installedSha256": "8db3470f6990515b6c3303667c133d41c94a6465797ff27b88a07595378d5f07"
42
+ },
43
+ "NotoSansArabic-Regular.ttf": {
44
+ "derivedFrom": "NotoSansArabic.variable.ttf",
45
+ "axes": {
46
+ "wght": 400,
47
+ "wdth": 100
48
+ },
49
+ "installedSha256": "97ad7c9db540d795730cda54885e1e5741a0494ef13681d78a73f8a0fbc60b9f"
50
+ },
51
+ "TwemojiMozilla.ttf": {
52
+ "url": "https://github.com/mozilla/twemoji-colr/releases/download/v0.7.0/Twemoji.Mozilla.ttf",
53
+ "sha256": "6d90152ee0d29e82fe2a87793af5aa4b7ad13e6538360889e141e81ed299ee8e",
54
+ "installedSha256": "6d90152ee0d29e82fe2a87793af5aa4b7ad13e6538360889e141e81ed299ee8e"
55
+ },
56
+ "TwemojiMozilla-LICENSE.md": {
57
+ "url": "https://raw.githubusercontent.com/mozilla/twemoji-colr/master/LICENSE.md",
58
+ "sha256": "64419edc28e9163204c3be73f835a8dfc34cd6c9b8f7d067bb685f119f839a99"
59
+ }
60
+ }