documents.js 1.35.1 → 1.37.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 +17 -13
- package/dist/index.cjs +81 -1
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +76 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/ExaDev/documents.js) [](https://www.npmjs.com/package/documents.js) [](https://github.com/ExaDev/documents.js/releases/latest) [](https://github.com/ExaDev/documents.js/actions)
|
|
4
4
|
|
|
5
|
-
> Bidirectional docx/pptx ⇄ PDF conversion, a read-and-write live-view editor for docx/pptx content, and a fully hand-written PDF codec, built on [ooxml.js](https://github.com/ExaDev/ooxml.js).
|
|
5
|
+
> Bidirectional docx/pptx ⇄ PDF conversion, one-directional odt → PDF conversion, a read-and-write live-view editor for docx/pptx content, and a fully hand-written PDF codec, built on [ooxml.js](https://github.com/ExaDev/ooxml.js) and [odf.js](https://github.com/ExaDev/odf.js).
|
|
6
6
|
|
|
7
7
|
`documents.js` depends on `ooxml.js` for lossless docx/pptx/xlsx ⇄ JSON handling and extends it in two directions `ooxml.js` deliberately does not cover: full PDF support (parsing arbitrary real-world PDFs and generating new ones), and a read-**and-write** manipulation API for docx/pptx content — `ooxml.js`'s own typed readers (`readDocx`/`readPptx`) are one-way and explicitly forbid write-back. PDF reading, writing, and the docx⇄PDF/pptx⇄PDF conversion pipeline are entirely hand-written: no external PDF library (`pdf-lib`, `pdfjs-dist`, `mupdf`, or any other) is a dependency. The one exception is [`fflate`](https://github.com/101arrowz/fflate) for raw DEFLATE/zlib compression underneath PDF's `FlateDecode` filter and PNG's `IDAT` chunks — the same dependency `ooxml.js` itself already relies on for ZIP handling.
|
|
8
8
|
|
|
@@ -30,21 +30,23 @@ npm install documents.js
|
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
32
32
|
|
|
33
|
-
The four ergonomic conversions:
|
|
33
|
+
The four round-trip ergonomic conversions, plus odt's one-directional addition:
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
|
-
import { docxToPdf, pdfToDocx, pptxToPdf, pdfToPptx } from 'documents.js';
|
|
36
|
+
import { docxToPdf, odtToPdf, pdfToDocx, pptxToPdf, pdfToPptx } from 'documents.js';
|
|
37
37
|
|
|
38
38
|
const pdfBytes = docxToPdf(docxBytes);
|
|
39
39
|
const docxBytes2 = pdfToDocx(pdfBytes);
|
|
40
40
|
|
|
41
41
|
const pdfFromSlides = pptxToPdf(pptxBytes);
|
|
42
42
|
const pptxBytes2 = pdfToPptx(pdfFromSlides);
|
|
43
|
+
|
|
44
|
+
const pdfFromOdt = odtToPdf(odtBytes); // odt -> PDF only -- there is no pdfToOdt yet (no live-view odt editor exists to build one back)
|
|
43
45
|
```
|
|
44
46
|
|
|
45
|
-
Each accepts an optional `signal` (`AbortSignal`) and either a `onSubstitution` callback (docx/pptx → PDF, called once per character not representable in a standard-14 font) or a `sink` (PDF → docx/pptx, called once per recoverable parse diagnostic).
|
|
47
|
+
Each accepts an optional `signal` (`AbortSignal`) and either a `onSubstitution` callback (docx/pptx/odt → PDF, called once per character not representable in a standard-14 font) or a `sink` (PDF → docx/pptx, called once per recoverable parse diagnostic).
|
|
46
48
|
|
|
47
|
-
The same
|
|
49
|
+
The same conversions behind a swappable port, for a caller that wants to inject a different implementation later without changing call sites:
|
|
48
50
|
|
|
49
51
|
```ts
|
|
50
52
|
import { createLocalDocumentConverter } from 'documents.js';
|
|
@@ -97,13 +99,13 @@ const pdfFromDocx = z.decode(docxPdfCodec, docxBytes);
|
|
|
97
99
|
const docxBack = z.encode(docxPdfCodec, pdfFromDocx);
|
|
98
100
|
```
|
|
99
101
|
|
|
100
|
-
`readDocxContent`/`readPptxContent` (docx/pptx → `ContentDocument`), `convertWordprocessingToLayout`/`convertPresentationToLayout` (`ContentDocument` → `LayoutDocument`), and `reconstructWordprocessing`/`reconstructPresentation` (`LayoutDocument` → `ContentDocument`) are each exported individually too, for a caller that wants one stage of the pipeline without the rest.
|
|
102
|
+
`readDocxContent`/`readPptxContent`/`readOdtContent` (docx/pptx/odt → `ContentDocument`), `convertWordprocessingToLayout`/`convertPresentationToLayout` (`ContentDocument` → `LayoutDocument`), and `reconstructWordprocessing`/`reconstructPresentation` (`LayoutDocument` → `ContentDocument`) are each exported individually too, for a caller that wants one stage of the pipeline without the rest. `readDocxContent` and `readOdtContent` both produce the identical `wordprocessing`-variant `ContentDocument` shape from two completely unrelated package formats (OOXML and ODF), which is what lets `odtToPdf` feed `convertWordprocessingToLayout` without a single line of that engine changing.
|
|
101
103
|
|
|
102
104
|
## Architecture
|
|
103
105
|
|
|
104
106
|
The package is layered from generic primitives outward to the two conversion directions:
|
|
105
107
|
|
|
106
|
-
- **`src/model/`** — thin, documents.js-specific additions on top of the sibling [`document-content-model`](https://github.com/ExaDev/document-content-model) package, which now owns the two pivot models themselves: `LayoutDocument` (the PDF-side pivot: pages of positioned text/image/rect/line/ellipse/link items, PDF-native coordinates and units) and `ContentDocument` (the semantic pivot: a discriminated union of `wordprocessing` and `presentation` variants sharing paragraph/run/table/image building blocks) are both imported, not defined here — `document-content-model` exists specifically so `ooxml.js
|
|
108
|
+
- **`src/model/`** — thin, documents.js-specific additions on top of the sibling [`document-content-model`](https://github.com/ExaDev/document-content-model) package, which now owns the two pivot models themselves: `LayoutDocument` (the PDF-side pivot: pages of positioned text/image/rect/line/ellipse/link items, PDF-native coordinates and units) and `ContentDocument` (the semantic pivot: a discriminated union of `wordprocessing` and `presentation` variants sharing paragraph/run/table/image building blocks) are both imported, not defined here — `document-content-model` exists specifically so `ooxml.js`, `odf.js`, and `documents.js` share one schema instead of each maintaining an independent, drift-prone copy. What remains local: `bytes.ts` (magic-byte-validated `Uint8Array` schemas for docx/pptx/PDF, plus `Odt`/`Ods`/`Odp`/`OdgBytesSchema`, which check the package's actual declared media type against `odf.js`'s `ODF_MEDIA_TYPES` table rather than only the generic ZIP signature the OOXML schemas are limited to), `units.ts` (OOXML EMU/twip/point/half-point conversions), and `geometry.ts`/`color.ts`/`style.ts`, each now mostly a thin re-export of `document-content-model`'s `Box`/`Margins`/`PageSize`/`Color`/`Alignment`/`LayoutFont` — the one genuinely PDF-specific piece each still adds locally is `geometry.ts`'s `flipY` (the top-left/y-down ↔ bottom-left/y-up space conversion between OOXML/ODF and PDF coordinates); `LayoutFont`/`DEFAULT_LAYOUT_FONT` moved to `document-content-model` too (since `LayoutText`, part of the pivot, needs the field), leaving only the standard-14 font *resolution* logic that consumes it (`src/pdf/fonts.ts`/`font-read.ts`) as PDF-specific and local.
|
|
107
109
|
- **`src/bytes/`** and **`src/image/`** — generic byte and image-container primitives with zero PDF or OOXML knowledge: a chunked byte writer, a backtracking byte reader, CRC32, and a hand-written PNG decoder/encoder (palette/gray/RGB/alpha, multi-`IDAT` files, all five scanline filters) plus JPEG marker scanning for dimensions only — JPEG's compressed bytes pass through completely unchanged in both directions. `src/bytes/flate.ts` is the only file that imports `fflate`, mirroring how `ooxml.js`'s own `src/zip.ts` wraps it for ZIP handling.
|
|
108
110
|
- **`src/xml/`** and **`src/opc/`** — parent-aware XML query/mutation and OPC package mechanics (relationship IDs, content-type entries, atomic media-part insertion) built over `ooxml.js`'s `Package`/`XmlNode`, needed because `ooxml.js`'s own XML nodes have no parent pointers and `ooxml.js` never writes new parts into an existing package.
|
|
109
111
|
- **`src/edit/`** — the read-and-write editable model: live-view classes (`DocxEditor`/`DocxParagraph`/`DocxRun`/`DocxTable`, `PptxEditor`/`PptxSlide`/`PptxShape`) wrapping the actual `XmlElement` objects inside a decoded `Package`, plus `buildDocxPackage`/`buildPptxPackage` bridging a `ContentDocument` to a fresh package built entirely through those same primitives.
|
|
@@ -112,10 +114,11 @@ The package is layered from generic primitives outward to the two conversion dir
|
|
|
112
114
|
- **Read**: `lexer.ts`/`parse.ts` (byte tokenizer and tokens → `PdfObject`), `filters.ts`/`predictors.ts` (Flate/LZW/ASCII85/ASCIIHex/RunLength, TIFF/PNG predictors), `xref.ts`/`document.ts` (classic and cross-reference-stream resolution, object streams, `/Prev` chains, linear-scan recovery, the page tree with attribute inheritance), `content-read.ts`/`interpret.ts` (the content-stream tokenizer and graphics/text state machine, including form-XObject recursion), `cmap.ts`/`font-style.ts`/`font-read.ts` (`/ToUnicode` CMaps, font-dictionary resolution), `images-read.ts` (Image XObjects → PNG/JPEG bytes), `read.ts` (`readPdf`, assembling all of the above into a `LayoutDocument`).
|
|
113
115
|
- `codec.ts` — `pdfCodec`, a `z.codec()` pair over `readPdf`/`writePdf` (PDF bytes ⇄ `LayoutDocument`).
|
|
114
116
|
- **`src/ooxml/`** — resolves a `Package` into a `ContentDocument`: `docx/read.ts` and `pptx/read.ts` are now thin adapters over `ooxml.js`'s own `readDocx`/`readPptx`, wrapping their `{ metadata, sections }`/`{ metadata, slides }` result into `ContentDocument`'s `wordprocessing`/`presentation` shape. The docx style cascade (`docDefaults` → named-style `basedOn` chains → paragraph-mark run properties → character styles → direct formatting), the pptx placeholder → layout → master → theme inheritance cascade, and DrawingML geometry/colour resolution all now live upstream in `ooxml.js` itself, not in this package.
|
|
115
|
-
- **`src/
|
|
116
|
-
- **`src/
|
|
117
|
+
- **`src/odf/`** — the ODF-side counterpart to `src/ooxml/`, resolving an `odf.js` `Package` into a `ContentDocument`: `odt/read.ts`'s `readOdtContent` is a thin adapter over `odf.js`'s own `readOdt`, wrapping its `{ metadata, sections }` result into the identical `wordprocessing` shape `readDocxContent` produces — the concrete proof that odt and docx genuinely share one pivot and one layout engine. There is no `src/odf/odt/content.ts` (`buildOdtPackage`) yet: odt has no live-view editor, so the PDF → odt direction doesn't exist.
|
|
118
|
+
- **`src/layout/`** — the pure conversion algorithms, importing only `model` (no I/O): `engine.ts` (`ContentDocument` wordprocessing → `LayoutDocument`: flow, line-breaking, pagination — fed identically by docx- and odt-sourced content), `slides.ts` (`ContentDocument` presentation → `LayoutDocument`: direct EMU-to-point placement, no pagination needed), `reconstruct.ts` (`LayoutDocument` → `ContentDocument`, both variants: baseline-proximity line clustering, then paragraph/text-block clustering from geometry — PDF has no semantic paragraph or shape structure to recover, only positioned glyphs).
|
|
119
|
+
- **`src/convert/`** — `convert.ts` (the four round-trip ergonomic wrappers plus `odtToPdf`'s one-directional addition), `codec.ts` (`docxPdfCodec`/`pptxPdfCodec`, a `z.codec()` pair over each — there is no `odtPdfCodec`, since a `z.codec()` pair needs both directions), `port.ts`/`local.ts` (the swappable `DocumentConverter` contract and its synchronous local implementation, covering `docx`/`pptx`/`odt` → `pdf` and `pdf` → `docx`/`pptx`).
|
|
117
120
|
|
|
118
|
-
Dependency direction is strictly downward and checkable: `model`/`bytes` import nothing local; `image` imports `bytes` only; `pdf` imports `model`+`bytes`+`image` only; `ooxml/*` imports `xml`/`model` only (no PDF knowledge); `layout` imports `model` only; `convert` composes everything else. No `PdfObject`/`PdfDict`/`PdfStream` type appears outside `src/pdf/`.
|
|
121
|
+
Dependency direction is strictly downward and checkable: `model`/`bytes` import nothing local; `image` imports `bytes` only; `pdf` imports `model`+`bytes`+`image` only; `ooxml/*` imports `xml`/`model` only (no PDF knowledge); `odf/*` imports `model` only (no PDF knowledge, no `xml/*` — `odf.js` already owns its own XML query helpers); `layout` imports `model` only; `convert` composes everything else. No `PdfObject`/`PdfDict`/`PdfStream` type appears outside `src/pdf/`.
|
|
119
122
|
|
|
120
123
|
## Build, test, and lint
|
|
121
124
|
|
|
@@ -125,7 +128,7 @@ pnpm typecheck # tsc --noEmit
|
|
|
125
128
|
pnpm lint # eslint . --max-warnings 0
|
|
126
129
|
pnpm test # vitest run --project unit
|
|
127
130
|
pnpm test:watch # vitest --project unit
|
|
128
|
-
pnpm test:smoke # rebuilds dist/, then verifies ESM/CJS parity
|
|
131
|
+
pnpm test:smoke # rebuilds dist/, then verifies ESM/CJS parity, a real docxToPdf/pdfToDocx round trip, and a real odtToPdf conversion, from the built CJS bundle
|
|
129
132
|
pnpm test:corpus # optional real-world PDF conformance checks against a local, gitignored test/corpus/ (see Fidelity)
|
|
130
133
|
```
|
|
131
134
|
|
|
@@ -145,6 +148,7 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
|
|
|
145
148
|
|
|
146
149
|
- **`ooxml.js`'s typed readers (`readDocx`/`readPptx`) are now the actual basis for conversion** — `readDocxContent`/`readPptxContent` are thin wrappers around them, not an independent walk of `word/document.xml`/`ppt/slides/slideN.xml`. They are still deliberately not re-exported from this package's own public surface: `readDocx`/`readPptx` also carry `comments`/`footnotes`/`headers`/`footers` (docx) that `ContentDocument` doesn't model, so exposing both the wrapper and the thing it wraps would invite a caller to reach for the wrong one rather than genuinely offering two competing models.
|
|
147
150
|
- **The docx⇄PDF and pptx⇄PDF conversions are explicitly not round-trip-lossless** — in deliberate contrast to `ooxml.js`'s own `packageCodec`, which is byte/part-faithful by design. See [Fidelity](#fidelity).
|
|
151
|
+
- **`odtToPdf` is one-directional — there is no `pdfToOdt`.** The PDF → docx/pptx direction needs a live-view editor to build the output package (`buildDocxPackage`/`buildPptxPackage`); odt has no live-view editor in this package yet (no `openOdt`/`createOdt`), so there is nothing for a `pdfToOdt` to build a package through. `odtToPdf` itself needed zero new layout code: `readOdtContent` (`src/odf/odt/read.ts`) produces the identical `wordprocessing` `ContentDocument` shape `readDocxContent` does, so it feeds `convertWordprocessingToLayout` unmodified.
|
|
148
152
|
- **PDF output uses the standard 14 fonts only — no font embedding.** Helvetica/Times-Roman are genuinely metric-compatible substitutes for Arial/Times New Roman, but Word's actual current defaults (Calibri, Aptos) are not, so line wrapping and pagination will drift slightly from what Word itself would produce. Expect a faithful visual approximation, not a line-identical reproduction.
|
|
149
153
|
- **Reading arbitrary real-world PDFs is the single largest risk surface in this package**, and the parser is honest about its design target: cleanly-generated output from mainstream producers (Word, PowerPoint, Chrome, LibreOffice, Acrobat), recovering from the malformations those producers and their downstream tooling actually create, and failing loudly and specifically on anything else — not matching a mature library's robustness against adversarial input.
|
|
150
154
|
- **Encrypted PDFs are unsupported.** `/Encrypt` present in the trailer throws `PdfEncryptedError`, even for the common empty-user-password case.
|
|
@@ -157,7 +161,7 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
|
|
|
157
161
|
|
|
158
162
|
## Fidelity
|
|
159
163
|
|
|
160
|
-
**docx/pptx → PDF** is a genuine layout render: the docx flow/pagination engine and the pptx direct-placement engine both produce real positioned text, images, tables, and (for docx) numbered/bulleted lists, styled through the full cascade (theme fonts/colours, `basedOn` chains, placeholder inheritance). It is a faithful **visual approximation**, not a pixel- or line-identical reproduction of what Word/PowerPoint would themselves render — see the standard-14 font substitution gotcha above.
|
|
164
|
+
**docx/pptx/odt → PDF** is a genuine layout render: the docx/odt flow/pagination engine and the pptx direct-placement engine both produce real positioned text, images, tables, and (for docx/odt) numbered/bulleted lists, styled through the full cascade (theme fonts/colours, `basedOn` chains, placeholder inheritance for docx/pptx; `style:default-style`/`style:parent-style-name` chains for odt). It is a faithful **visual approximation**, not a pixel- or line-identical reproduction of what Word/PowerPoint/Writer would themselves render — see the standard-14 font substitution gotcha above.
|
|
161
165
|
|
|
162
166
|
**PDF → docx/pptx** is necessarily a **best-effort reconstruction** from geometry: a PDF page is just positioned glyphs and images, with no semantic paragraph or shape structure to recover. Reading order, bold/italic/colour/font-size, and page/slide count are preserved; paragraph and text-block boundaries are inferred from baseline spacing and left-margin indentation, not recovered exactly.
|
|
163
167
|
|
|
@@ -179,7 +183,7 @@ Commits follow Conventional Commits (`feat:`, `fix:`, `test:`, `chore:`, …), e
|
|
|
179
183
|
|
|
180
184
|
- [ooxml.js](https://github.com/ExaDev/ooxml.js) — the sibling package this depends on for all docx/pptx/xlsx ⇄ JSON handling and cascade-resolved typed reading.
|
|
181
185
|
- [document-content-model](https://github.com/ExaDev/document-content-model) — the sibling package that owns `ContentDocument`/`LayoutDocument` themselves; both `ooxml.js` and `documents.js` import from it rather than each maintaining an independent copy.
|
|
182
|
-
- [odf.js](https://github.com/ExaDev/odf.js) — a sibling package doing the equivalent lossless-codec job for the OpenDocument Format (odt/ods/odp/odg/…), also built on `document-content-model`.
|
|
186
|
+
- [odf.js](https://github.com/ExaDev/odf.js) — a sibling package doing the equivalent lossless-codec job for the OpenDocument Format (odt/ods/odp/odg/…), also built on `document-content-model`. A dependency of `documents.js` for: this package's `Odt`/`Ods`/`Odp`/`OdgBytesSchema` (`src/model/bytes.ts`), which validate against its `ODF_MEDIA_TYPES` table; `src/interop.test.ts`, a type-level guard that `ooxml.js`'s and `odf.js`'s raw `XmlElement`/`XmlNode`/`Attribute`/`Package` container types stay structurally compatible; and `src/odf/odt/read.ts`'s `readOdtContent`, a thin adapter over `odf.js`'s own `readOdt`, feeding `odtToPdf` (`src/convert/convert.ts`). odt → `ContentDocument` reading and PDF conversion are integrated; ods/odp/odg → `ContentDocument` reading (the equivalent for spreadsheets, presentations, and drawings) is not yet.
|
|
183
187
|
|
|
184
188
|
## License
|
|
185
189
|
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let ooxml_js = require("ooxml.js");
|
|
3
3
|
let document_content_model = require("document-content-model");
|
|
4
4
|
let zod = require("zod");
|
|
5
|
+
let odf_js = require("odf.js");
|
|
5
6
|
let fflate = require("fflate");
|
|
6
7
|
//#region src/model/content.ts
|
|
7
8
|
const CONTENT_FORMAT_VERSION = 1;
|
|
@@ -65,6 +66,43 @@ function zipBytesSchema(label) {
|
|
|
65
66
|
const DocxBytesSchema = zipBytesSchema("docx");
|
|
66
67
|
const PptxBytesSchema = zipBytesSchema("pptx");
|
|
67
68
|
const PdfBytesSchema = zod.z.instanceof(Uint8Array).refine((bytes) => containsBytesWithin(bytes, PDF_HEADER, PDF_HEADER_SEARCH_WINDOW), { message: "not a valid PDF file: missing the %PDF- header" });
|
|
69
|
+
const MIMETYPE_ENTRY_FILENAME = "mimetype";
|
|
70
|
+
const MIMETYPE_FILENAME_OFFSET = 30;
|
|
71
|
+
const MIMETYPE_CONTENT_OFFSET = 38;
|
|
72
|
+
const COMPRESSION_METHOD_OFFSET = 8;
|
|
73
|
+
const COMPRESSED_SIZE_OFFSET = 18;
|
|
74
|
+
function readUint16LE(bytes, offset) {
|
|
75
|
+
const b0 = bytes[offset];
|
|
76
|
+
const b1 = bytes[offset + 1];
|
|
77
|
+
if (b0 === void 0 || b1 === void 0) return;
|
|
78
|
+
return b0 | b1 << 8;
|
|
79
|
+
}
|
|
80
|
+
function readUint32LE(bytes, offset) {
|
|
81
|
+
const b0 = bytes[offset];
|
|
82
|
+
const b1 = bytes[offset + 1];
|
|
83
|
+
const b2 = bytes[offset + 2];
|
|
84
|
+
const b3 = bytes[offset + 3];
|
|
85
|
+
if (b0 === void 0 || b1 === void 0 || b2 === void 0 || b3 === void 0) return;
|
|
86
|
+
return (b0 | b1 << 8 | b2 << 16 | b3 << 24) >>> 0;
|
|
87
|
+
}
|
|
88
|
+
function readAsciiSlice(bytes, offset, length) {
|
|
89
|
+
if (bytes.length < offset + length) return;
|
|
90
|
+
return new TextDecoder().decode(bytes.subarray(offset, offset + length));
|
|
91
|
+
}
|
|
92
|
+
function hasOdfMimetypeEntry(bytes, mediaType) {
|
|
93
|
+
if (!startsWithBytes(bytes, ZIP_LOCAL_FILE_HEADER)) return false;
|
|
94
|
+
if (readUint16LE(bytes, COMPRESSION_METHOD_OFFSET) !== 0) return false;
|
|
95
|
+
if (readAsciiSlice(bytes, MIMETYPE_FILENAME_OFFSET, 8) !== MIMETYPE_ENTRY_FILENAME) return false;
|
|
96
|
+
if (readUint32LE(bytes, COMPRESSED_SIZE_OFFSET) !== mediaType.length) return false;
|
|
97
|
+
return readAsciiSlice(bytes, MIMETYPE_CONTENT_OFFSET, mediaType.length) === mediaType;
|
|
98
|
+
}
|
|
99
|
+
function odfBytesSchema(label, mediaType) {
|
|
100
|
+
return zod.z.instanceof(Uint8Array).refine((bytes) => hasOdfMimetypeEntry(bytes, mediaType), { message: `not a valid ${label} file: the first zip entry is not a stored "mimetype" part declaring "${mediaType}"` });
|
|
101
|
+
}
|
|
102
|
+
const OdtBytesSchema = odfBytesSchema("odt", odf_js.ODF_MEDIA_TYPES.odt);
|
|
103
|
+
const OdsBytesSchema = odfBytesSchema("ods", odf_js.ODF_MEDIA_TYPES.ods);
|
|
104
|
+
const OdpBytesSchema = odfBytesSchema("odp", odf_js.ODF_MEDIA_TYPES.odp);
|
|
105
|
+
const OdgBytesSchema = odfBytesSchema("odg", odf_js.ODF_MEDIA_TYPES.odg);
|
|
68
106
|
//#endregion
|
|
69
107
|
//#region src/xml/fragment.ts
|
|
70
108
|
function el(tag, attrs = {}, children = []) {
|
|
@@ -1091,7 +1129,7 @@ function appendBlock(body, block) {
|
|
|
1091
1129
|
altText: block.altText
|
|
1092
1130
|
});
|
|
1093
1131
|
else if (block.kind === "pageBreak") body.appendPageBreak();
|
|
1094
|
-
else appendTable(body, block);
|
|
1132
|
+
else if (block.kind === "table") appendTable(body, block);
|
|
1095
1133
|
}
|
|
1096
1134
|
//#endregion
|
|
1097
1135
|
//#region src/edit/pptx/scaffold.ts
|
|
@@ -6697,6 +6735,17 @@ function readPptxContent(pkg) {
|
|
|
6697
6735
|
};
|
|
6698
6736
|
}
|
|
6699
6737
|
//#endregion
|
|
6738
|
+
//#region src/odf/odt/read.ts
|
|
6739
|
+
function readOdtContent(pkg) {
|
|
6740
|
+
const odtDoc = (0, odf_js.readOdt)(pkg);
|
|
6741
|
+
return {
|
|
6742
|
+
kind: "wordprocessing",
|
|
6743
|
+
formatVersion: 1,
|
|
6744
|
+
metadata: { ...odtDoc.metadata },
|
|
6745
|
+
sections: odtDoc.sections
|
|
6746
|
+
};
|
|
6747
|
+
}
|
|
6748
|
+
//#endregion
|
|
6700
6749
|
//#region src/pdf/text-layout.ts
|
|
6701
6750
|
const WORD_OR_WHITESPACE_PATTERN = /\n|\s+|\S+/g;
|
|
6702
6751
|
function atomizeRuns(runs, measurer) {
|
|
@@ -7668,6 +7717,14 @@ function docxToPdf(bytes, options) {
|
|
|
7668
7717
|
onSubstitution: options?.onSubstitution
|
|
7669
7718
|
});
|
|
7670
7719
|
}
|
|
7720
|
+
function odtToPdf(bytes, options) {
|
|
7721
|
+
const content = readOdtContent((0, odf_js.decodePackage)(bytes));
|
|
7722
|
+
if (content.kind !== "wordprocessing") throw new Error("readOdtContent returned a non-wordprocessing ContentDocument");
|
|
7723
|
+
return writePdf(convertWordprocessingToLayout(content, { measurer: createStandardFontMeasurer() }), {
|
|
7724
|
+
signal: options?.signal,
|
|
7725
|
+
onSubstitution: options?.onSubstitution
|
|
7726
|
+
});
|
|
7727
|
+
}
|
|
7671
7728
|
function pptxToPdf(bytes, options) {
|
|
7672
7729
|
const content = readPptxContent(openPptx(bytes).toPackage());
|
|
7673
7730
|
if (content.kind !== "presentation") throw new Error("readPptxContent returned a non-presentation ContentDocument");
|
|
@@ -7711,6 +7768,10 @@ const SUPPORTED_CONVERSIONS = [
|
|
|
7711
7768
|
source: "pptx",
|
|
7712
7769
|
target: "pdf"
|
|
7713
7770
|
},
|
|
7771
|
+
{
|
|
7772
|
+
source: "odt",
|
|
7773
|
+
target: "pdf"
|
|
7774
|
+
},
|
|
7714
7775
|
{
|
|
7715
7776
|
source: "pdf",
|
|
7716
7777
|
target: "docx"
|
|
@@ -7769,6 +7830,19 @@ function createLocalDocumentConverter() {
|
|
|
7769
7830
|
diagnostics
|
|
7770
7831
|
});
|
|
7771
7832
|
}
|
|
7833
|
+
if (source.format === "odt" && targetFormat === "pdf") {
|
|
7834
|
+
const bytes = odtToPdf(source.bytes, {
|
|
7835
|
+
signal: options.signal,
|
|
7836
|
+
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c))
|
|
7837
|
+
});
|
|
7838
|
+
return Promise.resolve({
|
|
7839
|
+
document: {
|
|
7840
|
+
format: "pdf",
|
|
7841
|
+
bytes
|
|
7842
|
+
},
|
|
7843
|
+
diagnostics
|
|
7844
|
+
});
|
|
7845
|
+
}
|
|
7772
7846
|
if (source.format === "pdf" && targetFormat === "docx") {
|
|
7773
7847
|
const bytes = pdfToDocx(source.bytes, {
|
|
7774
7848
|
signal: options.signal,
|
|
@@ -7942,6 +8016,10 @@ Object.defineProperty(exports, "LAYOUT_FORMAT_VERSION", {
|
|
|
7942
8016
|
}
|
|
7943
8017
|
});
|
|
7944
8018
|
exports.NOOP_DIAGNOSTIC_SINK = NOOP_DIAGNOSTIC_SINK;
|
|
8019
|
+
exports.OdgBytesSchema = OdgBytesSchema;
|
|
8020
|
+
exports.OdpBytesSchema = OdpBytesSchema;
|
|
8021
|
+
exports.OdsBytesSchema = OdsBytesSchema;
|
|
8022
|
+
exports.OdtBytesSchema = OdtBytesSchema;
|
|
7945
8023
|
Object.defineProperty(exports, "PAGE_SIZE_A4", {
|
|
7946
8024
|
enumerable: true,
|
|
7947
8025
|
get: function() {
|
|
@@ -8146,6 +8224,7 @@ Object.defineProperty(exports, "isXmlNode", {
|
|
|
8146
8224
|
return ooxml_js.isXmlNode;
|
|
8147
8225
|
}
|
|
8148
8226
|
});
|
|
8227
|
+
exports.odtToPdf = odtToPdf;
|
|
8149
8228
|
exports.openDocx = openDocx;
|
|
8150
8229
|
exports.openPptx = openPptx;
|
|
8151
8230
|
Object.defineProperty(exports, "packageCodec", {
|
|
@@ -8172,6 +8251,7 @@ exports.pdfToPptx = pdfToPptx;
|
|
|
8172
8251
|
exports.pptxPdfCodec = pptxPdfCodec;
|
|
8173
8252
|
exports.pptxToPdf = pptxToPdf;
|
|
8174
8253
|
exports.readDocxContent = readDocxContent;
|
|
8254
|
+
exports.readOdtContent = readOdtContent;
|
|
8175
8255
|
exports.readPdf = readPdf;
|
|
8176
8256
|
exports.readPptxContent = readPptxContent;
|
|
8177
8257
|
exports.reconstructPresentation = reconstructPresentation;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Attribute, AttributeSchema, BinaryPart, BinaryPartSchema, Comment, CommentSchema, CompactAttrPairs, CompactPackage, CompactPackageSchema, CompactPart, CompactPartSchema, CompactXmlNode, CompactXmlNodeSchema, DefinedName, DefinedNameSchema, Package, Package as Package$1, PackageSchema, Part, PartSchema, Relationship, XmlCdata, XmlCdataSchema, XmlComment, XmlCommentSchema, XmlDeclaration, XmlDeclarationSchema, XmlElement, XmlElement as XmlElement$1, XmlElementSchema, XmlNode, XmlNode as XmlNode$1, XmlNodeSchema, XmlPart, XmlPartSchema, XmlPi, XmlPiSchema, XmlText, XmlTextSchema, attr, base64ToBytes, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, elementsWithTag, encodeCompactPackage, encodePackage, fromCompact, isCompactXmlNode, isXmlNode, packageCodec, parsePackage, parseXml, resolveRelationships, rootElement, serializePackage, textContent, toCompact, unzipPackage, walk, xmlCodec, zipPackage } from "ooxml.js";
|
|
2
2
|
import { Alignment, Box, Box as Box$1, COLOR_BLACK, Color as LayoutColor, ContentBlock, ContentBlockSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembership as ContentListMembership$1, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSlide, ContentSlideSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, DEFAULT_LAYOUT_FONT, LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocument as LayoutDocument$1, LayoutEllipse, LayoutFont, LayoutImage, LayoutImageAsset, LayoutItem, LayoutLine, LayoutLink, LayoutMetadata, LayoutPage, LayoutRect, LayoutText, Margins, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, isContentBlock, rgbHexToColor } from "document-content-model";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { Package as Package$2 } from "odf.js";
|
|
4
5
|
//#region src/model/content.d.ts
|
|
5
6
|
declare const CONTENT_FORMAT_VERSION = 1;
|
|
6
7
|
declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -77,6 +78,10 @@ declare function flipY(box: Box$1, containerHeightPt: number): Box$1;
|
|
|
77
78
|
declare const DocxBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
78
79
|
declare const PptxBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
79
80
|
declare const PdfBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
81
|
+
declare const OdtBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
82
|
+
declare const OdsBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
83
|
+
declare const OdpBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
84
|
+
declare const OdgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
80
85
|
//#endregion
|
|
81
86
|
//#region src/edit/docx/image.d.ts
|
|
82
87
|
interface ImageInit$1 {
|
|
@@ -467,6 +472,9 @@ declare function readDocxContent(pkg: Package$1): ContentDocument;
|
|
|
467
472
|
//#region src/ooxml/pptx/read.d.ts
|
|
468
473
|
declare function readPptxContent(pkg: Package$1): ContentDocument;
|
|
469
474
|
//#endregion
|
|
475
|
+
//#region src/odf/odt/read.d.ts
|
|
476
|
+
declare function readOdtContent(pkg: Package$2): ContentDocument;
|
|
477
|
+
//#endregion
|
|
470
478
|
//#region src/pdf/measure.d.ts
|
|
471
479
|
interface UnderlineMetrics {
|
|
472
480
|
readonly offsetPt: number;
|
|
@@ -514,6 +522,7 @@ interface DocumentToPdfOptions {
|
|
|
514
522
|
}) => void;
|
|
515
523
|
}
|
|
516
524
|
declare function docxToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
525
|
+
declare function odtToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
517
526
|
declare function pptxToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
518
527
|
interface PdfToDocumentOptions {
|
|
519
528
|
readonly signal?: AbortSignal;
|
|
@@ -527,7 +536,7 @@ declare const docxPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint
|
|
|
527
536
|
declare const pptxPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
528
537
|
//#endregion
|
|
529
538
|
//#region src/convert/port.d.ts
|
|
530
|
-
type DocumentFormat = 'docx' | 'pptx' | 'pdf';
|
|
539
|
+
type DocumentFormat = 'docx' | 'pptx' | 'odt' | 'pdf';
|
|
531
540
|
interface DocumentPayload {
|
|
532
541
|
readonly format: DocumentFormat;
|
|
533
542
|
readonly bytes: Uint8Array<ArrayBuffer>;
|
|
@@ -570,4 +579,4 @@ declare function fixedClock(date: Date): ClockPort;
|
|
|
570
579
|
//#region src/ports/abort.d.ts
|
|
571
580
|
declare function throwIfAborted(signal: AbortSignal | undefined): void;
|
|
572
581
|
//#endregion
|
|
573
|
-
export { type Alignment, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, COLOR_BLACK, CONTENT_FORMAT_VERSION, type ClockPort, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ContentBlock, ContentBlockSchema, type ContentDocument, ContentDocumentSchema, type ContentImageBlock, ContentImageBlockSchema, type ContentListMembership, type ContentPageBreak, ContentPageBreakSchema, type ContentParagraph, ContentParagraphSchema, type ContentRun, ContentRunSchema, type ContentSection, ContentSectionSchema, type ContentShape, ContentShapeSchema, type ContentSlide, ContentSlideSchema, type ContentTable, type ContentTableCell, ContentTableCellSchema, type ContentTableRow, ContentTableRowSchema, ContentTableSchema, type ConversionRequest, type ConversionResult, DEFAULT_LAYOUT_FONT, type DefinedName, DefinedNameSchema, type Diagnostic, type DocumentConverter, type DocumentFormat, type DocumentPayload, type DocumentToPdfOptions, type DocxBody, DocxBytesSchema, DocxEditor, DocxParagraph, DocxRun, DocxTable, DocxTableCell, DocxTableRow, type DrawingParagraphInit, type DrawingRunInit, type EngineLayoutOptions, LAYOUT_FORMAT_VERSION, type LayoutColor, type LayoutDocument, type LayoutEllipse, type LayoutFont, type LayoutImage, type LayoutImageAsset, type LayoutItem, type LayoutLine, type LayoutLink, type LayoutMetadata, type LayoutPage, type LayoutRect, type LayoutText, type Margins, NOOP_DIAGNOSTIC_SINK, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, PackageSchema, type PageSize, type Part, PartSchema, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, type PdfToDocumentOptions, PptxBytesSchema, PptxEditor, PptxShape, PptxSlide, type ReadPdfOptions, type ReconstructOptions, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type SlideImageInit, type SlidesLayoutOptions, type TextBoxInit, type WinAnsiSubstitution, type WritePdfOptions, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, attr, base64ToBytes, buildDocxPackage, buildPptxPackage, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, convertPresentationToLayout, convertWordprocessingToLayout, createDocx, createLocalDocumentConverter, createPptx, decodeCompactPackage, decodeEntities, decodePackage, docxPdfCodec, docxToPdf, elementsWithTag, encodeCompactPackage, encodePackage, fixedClock, flipY, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, openDocx, openPptx, packageCodec, parsePackage, parseXml, pdfCodec, pdfToDocx, pdfToPptx, pptxPdfCodec, pptxToPdf, readDocxContent, readPdf, readPptxContent, reconstructPresentation, reconstructWordprocessing, resolveRelationships, rgbHexToColor, rootElement, serializePackage, systemClock, textContent, throwIfAborted, toCompact, unzipPackage, walk, writePdf, xmlCodec, zipPackage };
|
|
582
|
+
export { type Alignment, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, COLOR_BLACK, CONTENT_FORMAT_VERSION, type ClockPort, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ContentBlock, ContentBlockSchema, type ContentDocument, ContentDocumentSchema, type ContentImageBlock, ContentImageBlockSchema, type ContentListMembership, type ContentPageBreak, ContentPageBreakSchema, type ContentParagraph, ContentParagraphSchema, type ContentRun, ContentRunSchema, type ContentSection, ContentSectionSchema, type ContentShape, ContentShapeSchema, type ContentSlide, ContentSlideSchema, type ContentTable, type ContentTableCell, ContentTableCellSchema, type ContentTableRow, ContentTableRowSchema, ContentTableSchema, type ConversionRequest, type ConversionResult, DEFAULT_LAYOUT_FONT, type DefinedName, DefinedNameSchema, type Diagnostic, type DocumentConverter, type DocumentFormat, type DocumentPayload, type DocumentToPdfOptions, type DocxBody, DocxBytesSchema, DocxEditor, DocxParagraph, DocxRun, DocxTable, DocxTableCell, DocxTableRow, type DrawingParagraphInit, type DrawingRunInit, type EngineLayoutOptions, LAYOUT_FORMAT_VERSION, type LayoutColor, type LayoutDocument, type LayoutEllipse, type LayoutFont, type LayoutImage, type LayoutImageAsset, type LayoutItem, type LayoutLine, type LayoutLink, type LayoutMetadata, type LayoutPage, type LayoutRect, type LayoutText, type Margins, NOOP_DIAGNOSTIC_SINK, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, PackageSchema, type PageSize, type Part, PartSchema, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, type PdfToDocumentOptions, PptxBytesSchema, PptxEditor, PptxShape, PptxSlide, type ReadPdfOptions, type ReconstructOptions, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type SlideImageInit, type SlidesLayoutOptions, type TextBoxInit, type WinAnsiSubstitution, type WritePdfOptions, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, attr, base64ToBytes, buildDocxPackage, buildPptxPackage, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, convertPresentationToLayout, convertWordprocessingToLayout, createDocx, createLocalDocumentConverter, createPptx, decodeCompactPackage, decodeEntities, decodePackage, docxPdfCodec, docxToPdf, elementsWithTag, encodeCompactPackage, encodePackage, fixedClock, flipY, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, odtToPdf, openDocx, openPptx, packageCodec, parsePackage, parseXml, pdfCodec, pdfToDocx, pdfToPptx, pptxPdfCodec, pptxToPdf, readDocxContent, readOdtContent, readPdf, readPptxContent, reconstructPresentation, reconstructWordprocessing, resolveRelationships, rgbHexToColor, rootElement, serializePackage, systemClock, textContent, throwIfAborted, toCompact, unzipPackage, walk, writePdf, xmlCodec, zipPackage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Attribute, AttributeSchema, BinaryPart, BinaryPartSchema, Comment, CommentSchema, CompactAttrPairs, CompactPackage, CompactPackageSchema, CompactPart, CompactPartSchema, CompactXmlNode, CompactXmlNodeSchema, DefinedName, DefinedNameSchema, Package, Package as Package$1, PackageSchema, Part, PartSchema, Relationship, XmlCdata, XmlCdataSchema, XmlComment, XmlCommentSchema, XmlDeclaration, XmlDeclarationSchema, XmlElement, XmlElement as XmlElement$1, XmlElementSchema, XmlNode, XmlNode as XmlNode$1, XmlNodeSchema, XmlPart, XmlPartSchema, XmlPi, XmlPiSchema, XmlText, XmlTextSchema, attr, base64ToBytes, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, elementsWithTag, encodeCompactPackage, encodePackage, fromCompact, isCompactXmlNode, isXmlNode, packageCodec, parsePackage, parseXml, resolveRelationships, rootElement, serializePackage, textContent, toCompact, unzipPackage, walk, xmlCodec, zipPackage } from "ooxml.js";
|
|
2
2
|
import { Alignment, Box, Box as Box$1, COLOR_BLACK, Color as LayoutColor, ContentBlock, ContentBlockSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembership as ContentListMembership$1, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSlide, ContentSlideSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, DEFAULT_LAYOUT_FONT, LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocument as LayoutDocument$1, LayoutEllipse, LayoutFont, LayoutImage, LayoutImageAsset, LayoutItem, LayoutLine, LayoutLink, LayoutMetadata, LayoutPage, LayoutRect, LayoutText, Margins, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, isContentBlock, rgbHexToColor } from "document-content-model";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { Package as Package$2 } from "odf.js";
|
|
4
5
|
//#region src/model/content.d.ts
|
|
5
6
|
declare const CONTENT_FORMAT_VERSION = 1;
|
|
6
7
|
declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -77,6 +78,10 @@ declare function flipY(box: Box$1, containerHeightPt: number): Box$1;
|
|
|
77
78
|
declare const DocxBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
78
79
|
declare const PptxBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
79
80
|
declare const PdfBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
81
|
+
declare const OdtBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
82
|
+
declare const OdsBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
83
|
+
declare const OdpBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
84
|
+
declare const OdgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
80
85
|
//#endregion
|
|
81
86
|
//#region src/edit/docx/image.d.ts
|
|
82
87
|
interface ImageInit$1 {
|
|
@@ -467,6 +472,9 @@ declare function readDocxContent(pkg: Package$1): ContentDocument;
|
|
|
467
472
|
//#region src/ooxml/pptx/read.d.ts
|
|
468
473
|
declare function readPptxContent(pkg: Package$1): ContentDocument;
|
|
469
474
|
//#endregion
|
|
475
|
+
//#region src/odf/odt/read.d.ts
|
|
476
|
+
declare function readOdtContent(pkg: Package$2): ContentDocument;
|
|
477
|
+
//#endregion
|
|
470
478
|
//#region src/pdf/measure.d.ts
|
|
471
479
|
interface UnderlineMetrics {
|
|
472
480
|
readonly offsetPt: number;
|
|
@@ -514,6 +522,7 @@ interface DocumentToPdfOptions {
|
|
|
514
522
|
}) => void;
|
|
515
523
|
}
|
|
516
524
|
declare function docxToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
525
|
+
declare function odtToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
517
526
|
declare function pptxToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
518
527
|
interface PdfToDocumentOptions {
|
|
519
528
|
readonly signal?: AbortSignal;
|
|
@@ -527,7 +536,7 @@ declare const docxPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint
|
|
|
527
536
|
declare const pptxPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
528
537
|
//#endregion
|
|
529
538
|
//#region src/convert/port.d.ts
|
|
530
|
-
type DocumentFormat = 'docx' | 'pptx' | 'pdf';
|
|
539
|
+
type DocumentFormat = 'docx' | 'pptx' | 'odt' | 'pdf';
|
|
531
540
|
interface DocumentPayload {
|
|
532
541
|
readonly format: DocumentFormat;
|
|
533
542
|
readonly bytes: Uint8Array<ArrayBuffer>;
|
|
@@ -570,4 +579,4 @@ declare function fixedClock(date: Date): ClockPort;
|
|
|
570
579
|
//#region src/ports/abort.d.ts
|
|
571
580
|
declare function throwIfAborted(signal: AbortSignal | undefined): void;
|
|
572
581
|
//#endregion
|
|
573
|
-
export { type Alignment, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, COLOR_BLACK, CONTENT_FORMAT_VERSION, type ClockPort, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ContentBlock, ContentBlockSchema, type ContentDocument, ContentDocumentSchema, type ContentImageBlock, ContentImageBlockSchema, type ContentListMembership, type ContentPageBreak, ContentPageBreakSchema, type ContentParagraph, ContentParagraphSchema, type ContentRun, ContentRunSchema, type ContentSection, ContentSectionSchema, type ContentShape, ContentShapeSchema, type ContentSlide, ContentSlideSchema, type ContentTable, type ContentTableCell, ContentTableCellSchema, type ContentTableRow, ContentTableRowSchema, ContentTableSchema, type ConversionRequest, type ConversionResult, DEFAULT_LAYOUT_FONT, type DefinedName, DefinedNameSchema, type Diagnostic, type DocumentConverter, type DocumentFormat, type DocumentPayload, type DocumentToPdfOptions, type DocxBody, DocxBytesSchema, DocxEditor, DocxParagraph, DocxRun, DocxTable, DocxTableCell, DocxTableRow, type DrawingParagraphInit, type DrawingRunInit, type EngineLayoutOptions, LAYOUT_FORMAT_VERSION, type LayoutColor, type LayoutDocument, type LayoutEllipse, type LayoutFont, type LayoutImage, type LayoutImageAsset, type LayoutItem, type LayoutLine, type LayoutLink, type LayoutMetadata, type LayoutPage, type LayoutRect, type LayoutText, type Margins, NOOP_DIAGNOSTIC_SINK, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, PackageSchema, type PageSize, type Part, PartSchema, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, type PdfToDocumentOptions, PptxBytesSchema, PptxEditor, PptxShape, PptxSlide, type ReadPdfOptions, type ReconstructOptions, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type SlideImageInit, type SlidesLayoutOptions, type TextBoxInit, type WinAnsiSubstitution, type WritePdfOptions, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, attr, base64ToBytes, buildDocxPackage, buildPptxPackage, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, convertPresentationToLayout, convertWordprocessingToLayout, createDocx, createLocalDocumentConverter, createPptx, decodeCompactPackage, decodeEntities, decodePackage, docxPdfCodec, docxToPdf, elementsWithTag, encodeCompactPackage, encodePackage, fixedClock, flipY, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, openDocx, openPptx, packageCodec, parsePackage, parseXml, pdfCodec, pdfToDocx, pdfToPptx, pptxPdfCodec, pptxToPdf, readDocxContent, readPdf, readPptxContent, reconstructPresentation, reconstructWordprocessing, resolveRelationships, rgbHexToColor, rootElement, serializePackage, systemClock, textContent, throwIfAborted, toCompact, unzipPackage, walk, writePdf, xmlCodec, zipPackage };
|
|
582
|
+
export { type Alignment, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, COLOR_BLACK, CONTENT_FORMAT_VERSION, type ClockPort, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ContentBlock, ContentBlockSchema, type ContentDocument, ContentDocumentSchema, type ContentImageBlock, ContentImageBlockSchema, type ContentListMembership, type ContentPageBreak, ContentPageBreakSchema, type ContentParagraph, ContentParagraphSchema, type ContentRun, ContentRunSchema, type ContentSection, ContentSectionSchema, type ContentShape, ContentShapeSchema, type ContentSlide, ContentSlideSchema, type ContentTable, type ContentTableCell, ContentTableCellSchema, type ContentTableRow, ContentTableRowSchema, ContentTableSchema, type ConversionRequest, type ConversionResult, DEFAULT_LAYOUT_FONT, type DefinedName, DefinedNameSchema, type Diagnostic, type DocumentConverter, type DocumentFormat, type DocumentPayload, type DocumentToPdfOptions, type DocxBody, DocxBytesSchema, DocxEditor, DocxParagraph, DocxRun, DocxTable, DocxTableCell, DocxTableRow, type DrawingParagraphInit, type DrawingRunInit, type EngineLayoutOptions, LAYOUT_FORMAT_VERSION, type LayoutColor, type LayoutDocument, type LayoutEllipse, type LayoutFont, type LayoutImage, type LayoutImageAsset, type LayoutItem, type LayoutLine, type LayoutLink, type LayoutMetadata, type LayoutPage, type LayoutRect, type LayoutText, type Margins, NOOP_DIAGNOSTIC_SINK, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, PackageSchema, type PageSize, type Part, PartSchema, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, type PdfToDocumentOptions, PptxBytesSchema, PptxEditor, PptxShape, PptxSlide, type ReadPdfOptions, type ReconstructOptions, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type SlideImageInit, type SlidesLayoutOptions, type TextBoxInit, type WinAnsiSubstitution, type WritePdfOptions, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, attr, base64ToBytes, buildDocxPackage, buildPptxPackage, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, convertPresentationToLayout, convertWordprocessingToLayout, createDocx, createLocalDocumentConverter, createPptx, decodeCompactPackage, decodeEntities, decodePackage, docxPdfCodec, docxToPdf, elementsWithTag, encodeCompactPackage, encodePackage, fixedClock, flipY, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, odtToPdf, openDocx, openPptx, packageCodec, parsePackage, parseXml, pdfCodec, pdfToDocx, pdfToPptx, pptxPdfCodec, pptxToPdf, readDocxContent, readOdtContent, readPdf, readPptxContent, reconstructPresentation, reconstructWordprocessing, resolveRelationships, rgbHexToColor, rootElement, serializePackage, systemClock, textContent, throwIfAborted, toCompact, unzipPackage, walk, writePdf, xmlCodec, zipPackage };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AttributeSchema, BinaryPartSchema, CommentSchema, CompactPackageSchema, CompactPartSchema, CompactXmlNodeSchema, DefinedNameSchema, PackageSchema, PartSchema, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, attr, attr as attr$1, base64ToBytes, base64ToBytes as base64ToBytes$1, buildXml, bytesToBase64, bytesToBase64 as bytesToBase64$1, childrenWithTag, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, decodePackage as decodePackage$1, elementsWithTag, encodeCompactPackage, encodePackage, encodePackage as encodePackage$1, fromCompact, isCompactXmlNode, isXmlNode, packageCodec, parsePackage, parseXml, readDocx, readPptx, resolveRelationships, resolveRelationships as resolveRelationships$1, rootElement, rootElement as rootElement$1, serializePackage, textContent, textContent as textContent$1, toCompact, unzipPackage, walk, xmlCodec, zipPackage } from "ooxml.js";
|
|
2
2
|
import { COLOR_BLACK, ContentBlockSchema, ContentImageBlockSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentRunSchema, ContentSectionSchema, ContentSectionSchema as ContentSectionSchema$1, ContentShapeSchema, ContentSlideSchema, ContentSlideSchema as ContentSlideSchema$1, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, DEFAULT_LAYOUT_FONT, LAYOUT_FORMAT_VERSION, LAYOUT_FORMAT_VERSION as LAYOUT_FORMAT_VERSION$1, LayoutDocumentSchema, LayoutMetadataSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, colorToRgbHex, isContentBlock, rgbHexToColor } from "document-content-model";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { ODF_MEDIA_TYPES, decodePackage as decodePackage$2, readOdt } from "odf.js";
|
|
4
5
|
import { Unzlib, inflateSync, unzlibSync, zlibSync } from "fflate";
|
|
5
6
|
//#region src/model/content.ts
|
|
6
7
|
const CONTENT_FORMAT_VERSION = 1;
|
|
@@ -64,6 +65,43 @@ function zipBytesSchema(label) {
|
|
|
64
65
|
const DocxBytesSchema = zipBytesSchema("docx");
|
|
65
66
|
const PptxBytesSchema = zipBytesSchema("pptx");
|
|
66
67
|
const PdfBytesSchema = z.instanceof(Uint8Array).refine((bytes) => containsBytesWithin(bytes, PDF_HEADER, PDF_HEADER_SEARCH_WINDOW), { message: "not a valid PDF file: missing the %PDF- header" });
|
|
68
|
+
const MIMETYPE_ENTRY_FILENAME = "mimetype";
|
|
69
|
+
const MIMETYPE_FILENAME_OFFSET = 30;
|
|
70
|
+
const MIMETYPE_CONTENT_OFFSET = 38;
|
|
71
|
+
const COMPRESSION_METHOD_OFFSET = 8;
|
|
72
|
+
const COMPRESSED_SIZE_OFFSET = 18;
|
|
73
|
+
function readUint16LE(bytes, offset) {
|
|
74
|
+
const b0 = bytes[offset];
|
|
75
|
+
const b1 = bytes[offset + 1];
|
|
76
|
+
if (b0 === void 0 || b1 === void 0) return;
|
|
77
|
+
return b0 | b1 << 8;
|
|
78
|
+
}
|
|
79
|
+
function readUint32LE(bytes, offset) {
|
|
80
|
+
const b0 = bytes[offset];
|
|
81
|
+
const b1 = bytes[offset + 1];
|
|
82
|
+
const b2 = bytes[offset + 2];
|
|
83
|
+
const b3 = bytes[offset + 3];
|
|
84
|
+
if (b0 === void 0 || b1 === void 0 || b2 === void 0 || b3 === void 0) return;
|
|
85
|
+
return (b0 | b1 << 8 | b2 << 16 | b3 << 24) >>> 0;
|
|
86
|
+
}
|
|
87
|
+
function readAsciiSlice(bytes, offset, length) {
|
|
88
|
+
if (bytes.length < offset + length) return;
|
|
89
|
+
return new TextDecoder().decode(bytes.subarray(offset, offset + length));
|
|
90
|
+
}
|
|
91
|
+
function hasOdfMimetypeEntry(bytes, mediaType) {
|
|
92
|
+
if (!startsWithBytes(bytes, ZIP_LOCAL_FILE_HEADER)) return false;
|
|
93
|
+
if (readUint16LE(bytes, COMPRESSION_METHOD_OFFSET) !== 0) return false;
|
|
94
|
+
if (readAsciiSlice(bytes, MIMETYPE_FILENAME_OFFSET, 8) !== MIMETYPE_ENTRY_FILENAME) return false;
|
|
95
|
+
if (readUint32LE(bytes, COMPRESSED_SIZE_OFFSET) !== mediaType.length) return false;
|
|
96
|
+
return readAsciiSlice(bytes, MIMETYPE_CONTENT_OFFSET, mediaType.length) === mediaType;
|
|
97
|
+
}
|
|
98
|
+
function odfBytesSchema(label, mediaType) {
|
|
99
|
+
return z.instanceof(Uint8Array).refine((bytes) => hasOdfMimetypeEntry(bytes, mediaType), { message: `not a valid ${label} file: the first zip entry is not a stored "mimetype" part declaring "${mediaType}"` });
|
|
100
|
+
}
|
|
101
|
+
const OdtBytesSchema = odfBytesSchema("odt", ODF_MEDIA_TYPES.odt);
|
|
102
|
+
const OdsBytesSchema = odfBytesSchema("ods", ODF_MEDIA_TYPES.ods);
|
|
103
|
+
const OdpBytesSchema = odfBytesSchema("odp", ODF_MEDIA_TYPES.odp);
|
|
104
|
+
const OdgBytesSchema = odfBytesSchema("odg", ODF_MEDIA_TYPES.odg);
|
|
67
105
|
//#endregion
|
|
68
106
|
//#region src/xml/fragment.ts
|
|
69
107
|
function el(tag, attrs = {}, children = []) {
|
|
@@ -1090,7 +1128,7 @@ function appendBlock(body, block) {
|
|
|
1090
1128
|
altText: block.altText
|
|
1091
1129
|
});
|
|
1092
1130
|
else if (block.kind === "pageBreak") body.appendPageBreak();
|
|
1093
|
-
else appendTable(body, block);
|
|
1131
|
+
else if (block.kind === "table") appendTable(body, block);
|
|
1094
1132
|
}
|
|
1095
1133
|
//#endregion
|
|
1096
1134
|
//#region src/edit/pptx/scaffold.ts
|
|
@@ -6696,6 +6734,17 @@ function readPptxContent(pkg) {
|
|
|
6696
6734
|
};
|
|
6697
6735
|
}
|
|
6698
6736
|
//#endregion
|
|
6737
|
+
//#region src/odf/odt/read.ts
|
|
6738
|
+
function readOdtContent(pkg) {
|
|
6739
|
+
const odtDoc = readOdt(pkg);
|
|
6740
|
+
return {
|
|
6741
|
+
kind: "wordprocessing",
|
|
6742
|
+
formatVersion: 1,
|
|
6743
|
+
metadata: { ...odtDoc.metadata },
|
|
6744
|
+
sections: odtDoc.sections
|
|
6745
|
+
};
|
|
6746
|
+
}
|
|
6747
|
+
//#endregion
|
|
6699
6748
|
//#region src/pdf/text-layout.ts
|
|
6700
6749
|
const WORD_OR_WHITESPACE_PATTERN = /\n|\s+|\S+/g;
|
|
6701
6750
|
function atomizeRuns(runs, measurer) {
|
|
@@ -7667,6 +7716,14 @@ function docxToPdf(bytes, options) {
|
|
|
7667
7716
|
onSubstitution: options?.onSubstitution
|
|
7668
7717
|
});
|
|
7669
7718
|
}
|
|
7719
|
+
function odtToPdf(bytes, options) {
|
|
7720
|
+
const content = readOdtContent(decodePackage$2(bytes));
|
|
7721
|
+
if (content.kind !== "wordprocessing") throw new Error("readOdtContent returned a non-wordprocessing ContentDocument");
|
|
7722
|
+
return writePdf(convertWordprocessingToLayout(content, { measurer: createStandardFontMeasurer() }), {
|
|
7723
|
+
signal: options?.signal,
|
|
7724
|
+
onSubstitution: options?.onSubstitution
|
|
7725
|
+
});
|
|
7726
|
+
}
|
|
7670
7727
|
function pptxToPdf(bytes, options) {
|
|
7671
7728
|
const content = readPptxContent(openPptx(bytes).toPackage());
|
|
7672
7729
|
if (content.kind !== "presentation") throw new Error("readPptxContent returned a non-presentation ContentDocument");
|
|
@@ -7710,6 +7767,10 @@ const SUPPORTED_CONVERSIONS = [
|
|
|
7710
7767
|
source: "pptx",
|
|
7711
7768
|
target: "pdf"
|
|
7712
7769
|
},
|
|
7770
|
+
{
|
|
7771
|
+
source: "odt",
|
|
7772
|
+
target: "pdf"
|
|
7773
|
+
},
|
|
7713
7774
|
{
|
|
7714
7775
|
source: "pdf",
|
|
7715
7776
|
target: "docx"
|
|
@@ -7768,6 +7829,19 @@ function createLocalDocumentConverter() {
|
|
|
7768
7829
|
diagnostics
|
|
7769
7830
|
});
|
|
7770
7831
|
}
|
|
7832
|
+
if (source.format === "odt" && targetFormat === "pdf") {
|
|
7833
|
+
const bytes = odtToPdf(source.bytes, {
|
|
7834
|
+
signal: options.signal,
|
|
7835
|
+
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c))
|
|
7836
|
+
});
|
|
7837
|
+
return Promise.resolve({
|
|
7838
|
+
document: {
|
|
7839
|
+
format: "pdf",
|
|
7840
|
+
bytes
|
|
7841
|
+
},
|
|
7842
|
+
diagnostics
|
|
7843
|
+
});
|
|
7844
|
+
}
|
|
7771
7845
|
if (source.format === "pdf" && targetFormat === "docx") {
|
|
7772
7846
|
const bytes = pdfToDocx(source.bytes, {
|
|
7773
7847
|
signal: options.signal,
|
|
@@ -7805,4 +7879,4 @@ function fixedClock(date) {
|
|
|
7805
7879
|
return { now: () => date };
|
|
7806
7880
|
}
|
|
7807
7881
|
//#endregion
|
|
7808
|
-
export { AttributeSchema, BinaryPartSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, CommentSchema, CompactPackageSchema, CompactPartSchema, CompactXmlNodeSchema, ContentBlockSchema, ContentDocumentSchema, ContentImageBlockSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSlideSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, DEFAULT_LAYOUT_FONT, DefinedNameSchema, DocxBytesSchema, DocxEditor, DocxParagraph, DocxRun, DocxTable, DocxTableCell, DocxTableRow, LAYOUT_FORMAT_VERSION, NOOP_DIAGNOSTIC_SINK, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PackageSchema, PartSchema, PdfBytesSchema, PdfEncryptedError, PdfParseError, PptxBytesSchema, PptxEditor, PptxShape, PptxSlide, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, attr, base64ToBytes, buildDocxPackage, buildPptxPackage, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, convertPresentationToLayout, convertWordprocessingToLayout, createDocx, createLocalDocumentConverter, createPptx, decodeCompactPackage, decodeEntities, decodePackage, docxPdfCodec, docxToPdf, elementsWithTag, encodeCompactPackage, encodePackage, fixedClock, flipY, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, openDocx, openPptx, packageCodec, parsePackage, parseXml, pdfCodec, pdfToDocx, pdfToPptx, pptxPdfCodec, pptxToPdf, readDocxContent, readPdf, readPptxContent, reconstructPresentation, reconstructWordprocessing, resolveRelationships, rgbHexToColor, rootElement, serializePackage, systemClock, textContent, throwIfAborted, toCompact, unzipPackage, walk, writePdf, xmlCodec, zipPackage };
|
|
7882
|
+
export { AttributeSchema, BinaryPartSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, CommentSchema, CompactPackageSchema, CompactPartSchema, CompactXmlNodeSchema, ContentBlockSchema, ContentDocumentSchema, ContentImageBlockSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSlideSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, DEFAULT_LAYOUT_FONT, DefinedNameSchema, DocxBytesSchema, DocxEditor, DocxParagraph, DocxRun, DocxTable, DocxTableCell, DocxTableRow, LAYOUT_FORMAT_VERSION, NOOP_DIAGNOSTIC_SINK, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PackageSchema, PartSchema, PdfBytesSchema, PdfEncryptedError, PdfParseError, PptxBytesSchema, PptxEditor, PptxShape, PptxSlide, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, attr, base64ToBytes, buildDocxPackage, buildPptxPackage, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, convertPresentationToLayout, convertWordprocessingToLayout, createDocx, createLocalDocumentConverter, createPptx, decodeCompactPackage, decodeEntities, decodePackage, docxPdfCodec, docxToPdf, elementsWithTag, encodeCompactPackage, encodePackage, fixedClock, flipY, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, odtToPdf, openDocx, openPptx, packageCodec, parsePackage, parseXml, pdfCodec, pdfToDocx, pdfToPptx, pptxPdfCodec, pptxToPdf, readDocxContent, readOdtContent, readPdf, readPptxContent, reconstructPresentation, reconstructWordprocessing, resolveRelationships, rgbHexToColor, rootElement, serializePackage, systemClock, textContent, throwIfAborted, toCompact, unzipPackage, walk, writePdf, xmlCodec, zipPackage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "documents.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -64,8 +64,9 @@
|
|
|
64
64
|
"license": "MIT",
|
|
65
65
|
"packageManager": "pnpm@11.6.0",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"document-content-model": "^1.
|
|
67
|
+
"document-content-model": "^1.2.0",
|
|
68
68
|
"fflate": "^0.8.3",
|
|
69
|
+
"odf.js": "^1.8.0",
|
|
69
70
|
"ooxml.js": "^2.1.0",
|
|
70
71
|
"zod": "^4.4.3"
|
|
71
72
|
},
|