reamkit 1.23.0 → 1.25.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 +22 -11
- package/dist/esm/core/bmp.d.ts +33 -0
- package/dist/esm/core/bmp.js +276 -0
- package/dist/esm/core/converter/facade.d.ts +3 -3
- package/dist/esm/core/converter/facade.js +12 -0
- package/dist/esm/core/converter/ream.d.ts +48 -4
- package/dist/esm/core/converter/ream.js +25 -4
- package/dist/esm/core/document-model/index.d.ts +1 -1
- package/dist/esm/core/document-model/types.d.ts +54 -0
- package/dist/esm/core/drawingml/chart-geometry.js +3 -2
- package/dist/esm/core/drawingml/diagram/colors.d.ts +52 -0
- package/dist/esm/core/drawingml/diagram/colors.js +125 -0
- package/dist/esm/core/drawingml/diagram/data-model.d.ts +47 -0
- package/dist/esm/core/drawingml/diagram/data-model.js +119 -0
- package/dist/esm/core/drawingml/diagram/layout-engine.d.ts +46 -0
- package/dist/esm/core/drawingml/diagram/layout-engine.js +948 -0
- package/dist/esm/core/drawingml/diagram/run.d.ts +37 -0
- package/dist/esm/core/drawingml/diagram/run.js +50 -0
- package/dist/esm/core/drawingml/diagram/to-drawing.d.ts +16 -0
- package/dist/esm/core/drawingml/diagram/to-drawing.js +86 -0
- package/dist/esm/core/drawingml/preset-geometry.js +116 -6
- package/dist/esm/core/drawingml/text-warp.d.ts +58 -0
- package/dist/esm/core/drawingml/text-warp.js +355 -0
- package/dist/esm/core/drawingml/theme-parser.js +9 -3
- package/dist/esm/core/font/measure.d.ts +12 -0
- package/dist/esm/core/font/measure.js +36 -0
- package/dist/esm/core/images.d.ts +30 -2
- package/dist/esm/core/images.js +121 -5
- package/dist/esm/core/metafile/emf.js +144 -16
- package/dist/esm/core/metafile/picture.d.ts +49 -0
- package/dist/esm/core/metafile/picture.js +70 -1
- package/dist/esm/core/metafile/wmf.js +53 -4
- package/dist/esm/core/ole/escher-blip.js +11 -1
- package/dist/esm/core/outline.d.ts +17 -0
- package/dist/esm/core/outline.js +30 -0
- package/dist/esm/core/style-cascade/resolver.js +1 -0
- package/dist/esm/core/style-cascade/types.d.ts +3 -1
- package/dist/esm/excel/print-model.js +2 -2
- package/dist/esm/excel/sheet-drawing.js +1 -1
- package/dist/esm/excel/sheet-to-flow.d.ts +10 -0
- package/dist/esm/excel/sheet-to-flow.js +30 -3
- package/dist/esm/html/html-writer.js +5 -3
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/layout/page-doc.d.ts +35 -0
- package/dist/esm/layout/page-doc.js +14 -1
- package/dist/esm/layout/styled-layout.js +217 -30
- package/dist/esm/markdown/markdown-writer.d.ts +41 -0
- package/dist/esm/markdown/markdown-writer.js +733 -0
- package/dist/esm/pdf/shading.js +8 -6
- package/dist/esm/pdf/styled-page-emitter.js +62 -4
- package/dist/esm/pdf/vector-graphics.js +1 -1
- package/dist/esm/pdf-reader/annots.d.ts +24 -0
- package/dist/esm/pdf-reader/annots.js +126 -0
- package/dist/esm/pdf-reader/content.d.ts +131 -5
- package/dist/esm/pdf-reader/content.js +169 -12
- package/dist/esm/pdf-reader/display.d.ts +56 -0
- package/dist/esm/pdf-reader/display.js +162 -0
- package/dist/esm/pdf-reader/document.d.ts +36 -1
- package/dist/esm/pdf-reader/document.js +92 -25
- package/dist/esm/pdf-reader/embedded-fonts.d.ts +31 -0
- package/dist/esm/pdf-reader/embedded-fonts.js +94 -0
- package/dist/esm/pdf-reader/flow-build.d.ts +61 -6
- package/dist/esm/pdf-reader/flow-build.js +128 -22
- package/dist/esm/pdf-reader/font.js +185 -4
- package/dist/esm/pdf-reader/image-decode.js +56 -5
- package/dist/esm/pdf-reader/images.d.ts +6 -0
- package/dist/esm/pdf-reader/images.js +25 -5
- package/dist/esm/pdf-reader/jpeg.d.ts +18 -0
- package/dist/esm/pdf-reader/jpeg.js +419 -0
- package/dist/esm/pdf-reader/layout.d.ts +1 -1
- package/dist/esm/pdf-reader/layout.js +221 -32
- package/dist/esm/pdf-reader/pattern-tint.d.ts +17 -0
- package/dist/esm/pdf-reader/pattern-tint.js +181 -0
- package/dist/esm/pdf-reader/reader.d.ts +9 -1
- package/dist/esm/pdf-reader/reader.js +22 -6
- package/dist/esm/pdf-reader/shading.d.ts +14 -0
- package/dist/esm/pdf-reader/shading.js +27 -1
- package/dist/esm/pdf-reader/tagged.js +156 -17
- package/dist/esm/pdf-reader/text.d.ts +13 -1
- package/dist/esm/pdf-reader/text.js +70 -3
- package/dist/esm/pdf-reader/vector.d.ts +25 -1
- package/dist/esm/pdf-reader/vector.js +168 -12
- package/dist/esm/pptx/ppt/ppt-reader.js +95 -27
- package/dist/esm/pptx/ppt/ppt-text.d.ts +41 -0
- package/dist/esm/pptx/ppt/ppt-text.js +327 -37
- package/dist/esm/pptx/pptx-reader.js +90 -10
- package/dist/esm/pptx/slide-parser.d.ts +4 -1
- package/dist/esm/pptx/slide-parser.js +104 -13
- package/dist/esm/pptx/sp-helpers.d.ts +7 -3
- package/dist/esm/pptx/sp-helpers.js +45 -7
- package/dist/esm/pptx/table-style.d.ts +7 -0
- package/dist/esm/pptx/table-style.js +59 -7
- package/dist/esm/svg/svg-writer.js +1 -0
- package/dist/esm/word/document-parser.d.ts +4 -1
- package/dist/esm/word/document-parser.js +4 -1
- package/dist/esm/word/docx-reader.js +26 -13
- package/dist/esm/word/docx-writer.js +15 -1
- package/dist/esm/word/drawing-parser.d.ts +20 -0
- package/dist/esm/word/drawing-parser.js +44 -5
- package/dist/esm/word/table-parser.js +3 -0
- package/package.json +1 -1
|
@@ -50,6 +50,10 @@ var RASTER_MEDIA = {
|
|
|
50
50
|
gif: {
|
|
51
51
|
ext: "gif",
|
|
52
52
|
contentType: "image/gif"
|
|
53
|
+
},
|
|
54
|
+
bmp: {
|
|
55
|
+
ext: "bmp",
|
|
56
|
+
contentType: "image/bmp"
|
|
53
57
|
}
|
|
54
58
|
};
|
|
55
59
|
function mediaInfo(bytes) {
|
|
@@ -523,6 +527,16 @@ function tableXml(table, losses, state, scope) {
|
|
|
523
527
|
const rows = table.rows.map((row) => rowXml(row, losses, state, scope)).join("");
|
|
524
528
|
return `<w:tbl>${tblPrXml(table.properties)}<w:tblGrid>${grid}</w:tblGrid>${rows}</w:tbl>`;
|
|
525
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* §17.4.60 — `w:tblPr`. CT_Tbl declares it `minOccurs="1"`: a table states its
|
|
532
|
+
* properties even when it has none to state, and Word refuses to open a file
|
|
533
|
+
* whose `w:tbl` opens straight into its grid. Nothing else in the wild writes
|
|
534
|
+
* one without it — 5432 tables across the LibreOffice, Word and POI corpora,
|
|
535
|
+
* every one of them with a `w:tblPr` — and it went unnoticed here because a
|
|
536
|
+
* table read from a real document always carries SOMETHING (a width, a border,
|
|
537
|
+
* an alignment). One reconstructed from a PDF's glyph positions carries none of
|
|
538
|
+
* it, so `Ream.parse(pdf).convert('docx')` wrote a document Word turned away.
|
|
539
|
+
*/
|
|
526
540
|
function tblPrXml(p) {
|
|
527
541
|
const out = [];
|
|
528
542
|
if (p.widthType !== void 0) {
|
|
@@ -534,7 +548,7 @@ function tblPrXml(p) {
|
|
|
534
548
|
if (borders) out.push(borders);
|
|
535
549
|
const margins = cellMarginsXml("w:tblCellMar", p.defaultCellMargins);
|
|
536
550
|
if (margins) out.push(margins);
|
|
537
|
-
return
|
|
551
|
+
return `<w:tblPr>${out.join("")}</w:tblPr>`;
|
|
538
552
|
}
|
|
539
553
|
function rowXml(row, losses, state, scope) {
|
|
540
554
|
const trPr = [];
|
|
@@ -157,6 +157,26 @@ export declare function parseVmlPicture(node: PoNode, parseBody?: ParseBody): Dr
|
|
|
157
157
|
* @returns The fill.
|
|
158
158
|
*/
|
|
159
159
|
export declare function vmlFill(shape: PoNode, shapeType?: PoNode, resolveImage?: (id: string) => ResourceId | undefined): ShapeFill;
|
|
160
|
+
/**
|
|
161
|
+
* §20.1.8.55 `a:srcRect` — the picture's own edges, cut away before it is
|
|
162
|
+
* fitted to its frame. Each is a percentage in thousandths (ST_Percentage), so
|
|
163
|
+
* `l="14711"` drops the left 14.711%.
|
|
164
|
+
*
|
|
165
|
+
* @param node The `a:srcRect` element, or `undefined` when the fill declares none.
|
|
166
|
+
* @returns The crop, or `undefined` when nothing is cut away.
|
|
167
|
+
*/
|
|
168
|
+
export declare function parseSrcRect(node: PoNode | undefined): ImageCrop | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* The fill with the direction the SHAPE states, where it states one and no
|
|
171
|
+
* colours: §20.1.8.33's `a:gradFill` holding only an `a:lin` says "sweep the
|
|
172
|
+
* gallery style's run of colours this way". 63200.pptx's ellipse asks for the
|
|
173
|
+
* diagonal where the theme's slot sweeps straight down.
|
|
174
|
+
*
|
|
175
|
+
* @param fill The fill resolved from the style (or anywhere else).
|
|
176
|
+
* @param spPr The shape's own properties.
|
|
177
|
+
* @returns The fill, turned; unchanged when the shape states no bare direction.
|
|
178
|
+
*/
|
|
179
|
+
export declare function withStatedDirection(fill: ShapeFill, spPr: PoNode | undefined): ShapeFill;
|
|
160
180
|
/**
|
|
161
181
|
* Whether an `spPr` states a fill AT ALL — including `a:noFill`, which is a
|
|
162
182
|
* shape saying it has none rather than saying nothing. A placeholder that says
|
|
@@ -1042,7 +1042,11 @@ function vmlTextBox(shape, parseBody) {
|
|
|
1042
1042
|
const content = box ? poFindDescendant(box, "w:txbxContent") : void 0;
|
|
1043
1043
|
if (!content) return void 0;
|
|
1044
1044
|
const blocks = parseBody(poChildren(content));
|
|
1045
|
-
|
|
1045
|
+
if (blocks.length === 0) return void 0;
|
|
1046
|
+
return {
|
|
1047
|
+
content: blocks,
|
|
1048
|
+
upright: true
|
|
1049
|
+
};
|
|
1046
1050
|
}
|
|
1047
1051
|
/**
|
|
1048
1052
|
* The `@style` of a positioned VML shape as a float anchor: `position:absolute`
|
|
@@ -1532,6 +1536,34 @@ var FILL_TAGS = new Set([
|
|
|
1532
1536
|
"a:pattFill",
|
|
1533
1537
|
"a:grpFill"
|
|
1534
1538
|
]);
|
|
1539
|
+
function emptyGradient(node) {
|
|
1540
|
+
return poIs(node, "a:gradFill") && !poChildren(node).some((c) => poIs(c, "a:gsLst"));
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* The fill with the direction the SHAPE states, where it states one and no
|
|
1544
|
+
* colours: §20.1.8.33's `a:gradFill` holding only an `a:lin` says "sweep the
|
|
1545
|
+
* gallery style's run of colours this way". 63200.pptx's ellipse asks for the
|
|
1546
|
+
* diagonal where the theme's slot sweeps straight down.
|
|
1547
|
+
*
|
|
1548
|
+
* @param fill The fill resolved from the style (or anywhere else).
|
|
1549
|
+
* @param spPr The shape's own properties.
|
|
1550
|
+
* @returns The fill, turned; unchanged when the shape states no bare direction.
|
|
1551
|
+
*/
|
|
1552
|
+
function withStatedDirection(fill, spPr) {
|
|
1553
|
+
const gradient = fill.kind === "gradient" ? fill.gradient : void 0;
|
|
1554
|
+
if (gradient === void 0 || gradient.kind !== "linear" || spPr === void 0) return fill;
|
|
1555
|
+
const grad = poChildren(spPr).find((c) => emptyGradient(c));
|
|
1556
|
+
const lin = grad ? poChildren(grad).find((c) => poIs(c, "a:lin")) : void 0;
|
|
1557
|
+
const ang = lin ? poIntAttr(lin, "ang") : void 0;
|
|
1558
|
+
if (ang === void 0) return fill;
|
|
1559
|
+
return {
|
|
1560
|
+
...fill,
|
|
1561
|
+
gradient: {
|
|
1562
|
+
...gradient,
|
|
1563
|
+
angle: ang / 6e4 % 360
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1535
1567
|
/**
|
|
1536
1568
|
* Whether an `spPr` states a fill AT ALL — including `a:noFill`, which is a
|
|
1537
1569
|
* shape saying it has none rather than saying nothing. A placeholder that says
|
|
@@ -1541,7 +1573,7 @@ var FILL_TAGS = new Set([
|
|
|
1541
1573
|
* @returns Whether a fill element is present.
|
|
1542
1574
|
*/
|
|
1543
1575
|
function statesFill(spPr) {
|
|
1544
|
-
return spPr !== void 0 && poChildren(spPr).some((c) => FILL_TAGS.has(poTag(c) ?? ""));
|
|
1576
|
+
return spPr !== void 0 && poChildren(spPr).some((c) => FILL_TAGS.has(poTag(c) ?? "") && !emptyGradient(c));
|
|
1545
1577
|
}
|
|
1546
1578
|
function styleRefFill(style, resolveColor, themeStyles) {
|
|
1547
1579
|
const ref = poChildren(style).find((c) => poIs(c, "a:fillRef"));
|
|
@@ -1625,11 +1657,13 @@ function parseTextBox(wsp, parseBody) {
|
|
|
1625
1657
|
const anchor = a === "ctr" ? "ctr" : a === "b" ? "b" : a === "t" ? "t" : void 0;
|
|
1626
1658
|
const v = bodyPr ? poAttr(bodyPr, "vert") : void 0;
|
|
1627
1659
|
const vertical = v === "vert270" ? "vert270" : v !== void 0 && v !== "horz" ? "vert" : void 0;
|
|
1660
|
+
const upright = bodyPr !== void 0 && poAttr(bodyPr, "upright") === "1";
|
|
1628
1661
|
const autoFit = bodyPr !== void 0 && poChildren(bodyPr).some((c) => poIs(c, "a:spAutoFit"));
|
|
1629
1662
|
return {
|
|
1630
1663
|
content,
|
|
1631
1664
|
...chain ? { chain } : {},
|
|
1632
1665
|
...vertical ? { vertical } : {},
|
|
1666
|
+
...upright ? { upright } : {},
|
|
1633
1667
|
...autoFit ? { autoFit: true } : {},
|
|
1634
1668
|
...lIns !== void 0 ? { insetLeft: emuToPt(lIns) } : {},
|
|
1635
1669
|
...tIns !== void 0 ? { insetTop: emuToPt(tIns) } : {},
|
|
@@ -1819,7 +1853,8 @@ function fillFromNode(child, resolveColor, resolveImage) {
|
|
|
1819
1853
|
const rect = fillRectBox(child);
|
|
1820
1854
|
const duotone = blip ? duotoneOf(blip, resolveColor) : void 0;
|
|
1821
1855
|
const tile = poChildren(child).find((c) => poIs(c, "a:tile"));
|
|
1822
|
-
const
|
|
1856
|
+
const stretched = poChildren(child).some((c) => poIs(c, "a:stretch"));
|
|
1857
|
+
const tiled = tile !== void 0 || !stretched;
|
|
1823
1858
|
const tileScale = tile ? tileScaleOf(tile) : void 0;
|
|
1824
1859
|
const fixed = blip ? poChildren(blip).find((c) => poIs(c, "a:alphaModFix")) : void 0;
|
|
1825
1860
|
const amt = fixed ? poIntAttr(fixed, "amt") : void 0;
|
|
@@ -1981,6 +2016,10 @@ function nodeAlpha(color) {
|
|
|
1981
2016
|
* @returns The pair, or `undefined` when the blip states no duotone.
|
|
1982
2017
|
*/
|
|
1983
2018
|
function duotoneOf(blip, resolveColor) {
|
|
2019
|
+
if (poChildren(blip).some((c) => poIs(c, "a:grayscl"))) return {
|
|
2020
|
+
shadowHex: "000000",
|
|
2021
|
+
highlightHex: "FFFFFF"
|
|
2022
|
+
};
|
|
1984
2023
|
const duotone = poChildren(blip).find((c) => poIs(c, "a:duotone"));
|
|
1985
2024
|
if (!duotone) return void 0;
|
|
1986
2025
|
const [shadowHex, highlightHex] = poChildren(duotone).map((c) => resolveColorNode(c, resolveColor)).filter((hex) => hex !== void 0);
|
|
@@ -2286,7 +2325,7 @@ function parseGradient(grad, resolveColor) {
|
|
|
2286
2325
|
return {
|
|
2287
2326
|
kind: "radial",
|
|
2288
2327
|
stops,
|
|
2289
|
-
...poAttr(path, "path") === "rect" ? { sweep: "rect" } : {},
|
|
2328
|
+
...poAttr(path, "path") === "rect" || poAttr(path, "path") === "shape" ? { sweep: "rect" } : {},
|
|
2290
2329
|
...center ? { center } : {}
|
|
2291
2330
|
};
|
|
2292
2331
|
}
|
|
@@ -2302,4 +2341,4 @@ function clampUnit(x) {
|
|
|
2302
2341
|
return x < 0 ? 0 : x > 1 ? 1 : x;
|
|
2303
2342
|
}
|
|
2304
2343
|
//#endregion
|
|
2305
|
-
export { colorChangeOf, expandMcChildren, parseCustGeom, parseDrawing, parseFill, parseLine, parsePrstGeom, parseShadow, parseVmlPicture, parseXfrm, shadowFromOuterShdw, statesFill, styleRefFill, styleRefFontColor, styleRefLine, vmlFill };
|
|
2344
|
+
export { colorChangeOf, expandMcChildren, parseCustGeom, parseDrawing, parseFill, parseLine, parsePrstGeom, parseShadow, parseSrcRect, parseVmlPicture, parseXfrm, shadowFromOuterShdw, statesFill, styleRefFill, styleRefFontColor, styleRefLine, vmlFill, withStatedDirection };
|
|
@@ -353,6 +353,9 @@ function parseCellProperties(tcPr) {
|
|
|
353
353
|
}
|
|
354
354
|
const vAlign = poVal(poFirstChild(tcPr, "w:vAlign"));
|
|
355
355
|
if (vAlign === "center" || vAlign === "bottom" || vAlign === "top") out.verticalAlign = vAlign;
|
|
356
|
+
const dir = poVal(poFirstChild(tcPr, "w:textDirection"));
|
|
357
|
+
if (dir === "btLr" || dir === "tbLr") out.textDirection = "vert270";
|
|
358
|
+
else if (dir === "tbRl") out.textDirection = "vert";
|
|
356
359
|
if (poFirstChild(tcPr, "w:hideMark")) out.hideMark = true;
|
|
357
360
|
return {
|
|
358
361
|
properties: out,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reamkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"description": "Ream — convert DOCX, XLSX, PPTX and PDF to PDF, SVG, HTML, DOCX and XLSX, built from scratch on the ECMA-376 and ISO 32000 specifications. Parse once, convert anywhere.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alex Krassavin <info@reamkit.dev>",
|