reamkit 1.0.0 → 1.0.2
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 +4 -3
- package/dist/esm/core/bidi/index.d.ts +2 -0
- package/dist/esm/core/bidi/index.js +1 -0
- package/dist/esm/core/bidi/segments.d.ts +6 -0
- package/dist/esm/core/bidi/segments.js +41 -0
- package/dist/esm/core/converter/facade.js +1 -1
- package/dist/esm/core/converter/project.js +3 -2
- package/dist/esm/core/converter/ream.js +2 -1
- package/dist/esm/core/font/index.d.ts +2 -0
- package/dist/esm/core/font/measure.d.ts +7 -0
- package/dist/esm/core/font/measure.js +30 -0
- package/dist/esm/core/images.d.ts +17 -0
- package/dist/esm/core/images.js +308 -0
- package/dist/esm/core/line-breaker/index.d.ts +1 -1
- package/dist/esm/core/line-breaker/knuth-plass.d.ts +1 -0
- package/dist/esm/core/line-breaker/knuth-plass.js +2 -2
- package/dist/esm/core/numbering/apply.d.ts +3 -0
- package/dist/esm/core/numbering/apply.js +62 -0
- package/dist/esm/core/numbering/index.d.ts +1 -0
- package/dist/esm/core/opc/package.d.ts +2 -1
- package/dist/esm/core/opc/package.js +6 -2
- package/dist/esm/core/style-cascade/index.d.ts +1 -1
- package/dist/esm/core/style-cascade/resolver.d.ts +3 -1
- package/dist/esm/core/style-cascade/resolver.js +75 -2
- package/dist/esm/core/style-cascade/types.d.ts +2 -1
- package/dist/esm/core/vector.d.ts +45 -0
- package/dist/esm/core/vector.js +48 -0
- package/dist/esm/excel/print-model.js +21 -3
- package/dist/esm/excel/xlsx-reader.js +2 -2
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +2 -1
- package/dist/esm/{pdf → layout}/arc-to-bezier.d.ts +1 -1
- package/dist/esm/{pdf → layout}/arc-to-bezier.js +2 -2
- package/dist/esm/{pdf → layout}/math-layout.d.ts +1 -1
- package/dist/esm/{pdf → layout}/math-layout.js +1 -1
- package/dist/esm/layout/page-doc.d.ts +133 -0
- package/dist/esm/layout/page-doc.js +38 -0
- package/dist/esm/{pdf → layout}/preset-geometry.d.ts +1 -1
- package/dist/esm/{pdf → layout}/preset-geometry.js +2 -2
- package/dist/esm/layout/styled-layout.d.ts +84 -0
- package/dist/esm/layout/styled-layout.js +1729 -0
- package/dist/esm/pdf/cid-font.d.ts +0 -6
- package/dist/esm/pdf/cid-font.js +2 -28
- package/dist/esm/pdf/image-xobject.d.ts +3 -17
- package/dist/esm/pdf/image-xobject.js +2 -306
- package/dist/esm/pdf/index.js +1 -0
- package/dist/esm/pdf/styled-page-emitter.d.ts +8 -2
- package/dist/esm/pdf/styled-page-emitter.js +29 -14
- package/dist/esm/pdf/styled-page-renderer.d.ts +4 -217
- package/dist/esm/pdf/styled-page-renderer.js +3 -1824
- package/dist/esm/pdf/vector-graphics.d.ts +3 -45
- package/dist/esm/pdf/vector-graphics.js +2 -46
- package/dist/esm/svg/svg-writer.d.ts +1 -1
- package/dist/esm/svg/svg-writer.js +14 -15
- package/dist/esm/word/docx-reader.js +4 -3
- package/package.json +2 -2
- /package/dist/esm/{pdf → layout}/chart-geometry.d.ts +0 -0
- /package/dist/esm/{pdf → layout}/chart-geometry.js +0 -0
|
@@ -1,46 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readonly y: number;
|
|
5
|
-
} | {
|
|
6
|
-
readonly op: 'line';
|
|
7
|
-
readonly x: number;
|
|
8
|
-
readonly y: number;
|
|
9
|
-
} | {
|
|
10
|
-
readonly op: 'cubic';
|
|
11
|
-
readonly x1: number;
|
|
12
|
-
readonly y1: number;
|
|
13
|
-
readonly x2: number;
|
|
14
|
-
readonly y2: number;
|
|
15
|
-
readonly x: number;
|
|
16
|
-
readonly y: number;
|
|
17
|
-
} | {
|
|
18
|
-
readonly op: 'close';
|
|
19
|
-
};
|
|
20
|
-
export interface VectorPath {
|
|
21
|
-
readonly segments: ReadonlyArray<PathSegment>;
|
|
22
|
-
readonly fillRule?: 'nonzero' | 'evenodd';
|
|
23
|
-
}
|
|
24
|
-
export interface StrokeStyle {
|
|
25
|
-
readonly colorHex: string;
|
|
26
|
-
readonly widthPt: number;
|
|
27
|
-
readonly cap?: 'butt' | 'round' | 'square';
|
|
28
|
-
readonly join?: 'miter' | 'round' | 'bevel';
|
|
29
|
-
readonly dash?: ReadonlyArray<number>;
|
|
30
|
-
}
|
|
31
|
-
export interface VectorShape {
|
|
32
|
-
readonly paths: ReadonlyArray<VectorPath>;
|
|
33
|
-
readonly fillColorHex?: string;
|
|
34
|
-
readonly stroke?: StrokeStyle;
|
|
35
|
-
readonly transform: readonly [number, number, number, number, number, number];
|
|
36
|
-
}
|
|
37
|
-
export declare class PathBuilder {
|
|
38
|
-
private readonly segments;
|
|
39
|
-
moveTo(x: number, y: number): this;
|
|
40
|
-
lineTo(x: number, y: number): this;
|
|
41
|
-
cubicTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): this;
|
|
42
|
-
append(segments: ReadonlyArray<PathSegment>): this;
|
|
43
|
-
close(): this;
|
|
44
|
-
build(fillRule?: 'nonzero' | 'evenodd'): VectorPath;
|
|
45
|
-
}
|
|
1
|
+
import { VectorShape } from '../core/vector.js';
|
|
2
|
+
export type { PathSegment, StrokeStyle, VectorPath, VectorShape } from '../core/vector.js';
|
|
3
|
+
export { PathBuilder } from '../core/vector.js';
|
|
46
4
|
export declare function emitVectorShape(shape: VectorShape): Array<string>;
|
|
@@ -1,49 +1,5 @@
|
|
|
1
|
+
import "../core/vector.js";
|
|
1
2
|
//#region src/pdf/vector-graphics.ts
|
|
2
|
-
var PathBuilder = class {
|
|
3
|
-
segments = [];
|
|
4
|
-
moveTo(x, y) {
|
|
5
|
-
this.segments.push({
|
|
6
|
-
op: "move",
|
|
7
|
-
x,
|
|
8
|
-
y
|
|
9
|
-
});
|
|
10
|
-
return this;
|
|
11
|
-
}
|
|
12
|
-
lineTo(x, y) {
|
|
13
|
-
this.segments.push({
|
|
14
|
-
op: "line",
|
|
15
|
-
x,
|
|
16
|
-
y
|
|
17
|
-
});
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
cubicTo(x1, y1, x2, y2, x, y) {
|
|
21
|
-
this.segments.push({
|
|
22
|
-
op: "cubic",
|
|
23
|
-
x1,
|
|
24
|
-
y1,
|
|
25
|
-
x2,
|
|
26
|
-
y2,
|
|
27
|
-
x,
|
|
28
|
-
y
|
|
29
|
-
});
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
append(segments) {
|
|
33
|
-
for (const s of segments) this.segments.push(s);
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
close() {
|
|
37
|
-
this.segments.push({ op: "close" });
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
build(fillRule) {
|
|
41
|
-
return {
|
|
42
|
-
segments: this.segments.slice(),
|
|
43
|
-
...fillRule ? { fillRule } : {}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
3
|
function emitVectorShape(shape) {
|
|
48
4
|
const out = [];
|
|
49
5
|
out.push("q");
|
|
@@ -100,4 +56,4 @@ function hexToRgb01(hex) {
|
|
|
100
56
|
];
|
|
101
57
|
}
|
|
102
58
|
//#endregion
|
|
103
|
-
export {
|
|
59
|
+
export { emitVectorShape };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DocumentWriter, WriteResult } from '../core/ir/adapters.js';
|
|
2
|
-
import { LaidOutDocument } from '../
|
|
2
|
+
import { LaidOutDocument } from '../layout/page-doc.js';
|
|
3
3
|
export interface SvgWriteOptions {
|
|
4
4
|
/** Gap between stacked pages, in px/pt (default 12). */
|
|
5
5
|
readonly pageGap?: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FEATURES } from "../core/ir/features.js";
|
|
2
|
-
import { paintPlan } from "../
|
|
2
|
+
import { paintPlan } from "../layout/page-doc.js";
|
|
3
3
|
//#region src/svg/svg-writer.ts
|
|
4
4
|
var PAGE_GAP = 12;
|
|
5
5
|
function writeSvg(laid, opts = {}) {
|
|
@@ -35,18 +35,17 @@ var svgWriter = {
|
|
|
35
35
|
write: (doc, opts) => writeSvg(doc, opts ?? {})
|
|
36
36
|
};
|
|
37
37
|
function emitPage(out, page, laid, losses) {
|
|
38
|
-
const H = page.height;
|
|
39
38
|
const plan = paintPlan(page.commands);
|
|
40
|
-
for (const f of plan.fills) out.push(`<rect x="${fmt(f.x)}" y="${fmt(
|
|
39
|
+
for (const f of plan.fills) out.push(`<rect x="${fmt(f.x)}" y="${fmt(f.y)}" width="${fmt(f.width)}" height="${fmt(f.height)}" fill="#${f.fillColorHex}"/>`);
|
|
41
40
|
for (const img of plan.images) {
|
|
42
41
|
const href = imageHref(img.imageResourceName, laid);
|
|
43
42
|
if (!href) continue;
|
|
44
|
-
out.push(`<image x="${fmt(img.x)}" y="${fmt(
|
|
43
|
+
out.push(`<image x="${fmt(img.x)}" y="${fmt(img.y)}" width="${fmt(img.width)}" height="${fmt(img.height)}" href="${href}" preserveAspectRatio="none"/>`);
|
|
45
44
|
}
|
|
46
45
|
for (const b of plan.borders) {
|
|
47
46
|
const x2 = b.x + b.width;
|
|
48
|
-
const yTop =
|
|
49
|
-
const yBottom =
|
|
47
|
+
const yTop = b.y;
|
|
48
|
+
const yBottom = b.y + b.height;
|
|
50
49
|
const [ax, ay, bx, by] = b.side === "top" ? [
|
|
51
50
|
b.x,
|
|
52
51
|
yTop,
|
|
@@ -70,11 +69,11 @@ function emitPage(out, page, laid, losses) {
|
|
|
70
69
|
];
|
|
71
70
|
out.push(`<line x1="${fmt(ax)}" y1="${fmt(ay)}" x2="${fmt(bx)}" y2="${fmt(by)}" stroke="#${b.borderColorHex}" stroke-width="${fmt(b.borderSizePt)}"/>`);
|
|
72
71
|
}
|
|
73
|
-
for (const sh of plan.shapes) emitShape(out, sh.shape
|
|
74
|
-
for (const t of plan.lines) emitTextLine(out, t,
|
|
72
|
+
for (const sh of plan.shapes) emitShape(out, sh.shape);
|
|
73
|
+
for (const t of plan.lines) emitTextLine(out, t, losses);
|
|
75
74
|
}
|
|
76
|
-
function emitTextLine(out, item,
|
|
77
|
-
const y =
|
|
75
|
+
function emitTextLine(out, item, losses) {
|
|
76
|
+
const y = item.baselineY;
|
|
78
77
|
let x = item.originX;
|
|
79
78
|
for (const tok of item.line.tokens) {
|
|
80
79
|
if (tok.kind === "image") {
|
|
@@ -94,9 +93,9 @@ function emitTextLine(out, item, pageHeight, losses) {
|
|
|
94
93
|
x += tok.widthPt;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
|
-
function emitShape(out, shape
|
|
96
|
+
function emitShape(out, shape) {
|
|
98
97
|
const [a, b, c, d, e, f] = shape.transform;
|
|
99
|
-
const transform = `matrix(${fmt(a)} ${fmt(
|
|
98
|
+
const transform = `matrix(${fmt(a)} ${fmt(b)} ${fmt(c)} ${fmt(d)} ${fmt(e)} ${fmt(f)})`;
|
|
100
99
|
const fill = shape.fillColorHex ? `#${shape.fillColorHex}` : "none";
|
|
101
100
|
const stroke = shape.stroke ? ` stroke="#${shape.stroke.colorHex}" stroke-width="${fmt(shape.stroke.widthPt)}"` : "";
|
|
102
101
|
for (const path of shape.paths) {
|
|
@@ -107,9 +106,9 @@ function emitShape(out, shape, pageHeight) {
|
|
|
107
106
|
}
|
|
108
107
|
function pathData(segments) {
|
|
109
108
|
const parts = [];
|
|
110
|
-
for (const s of segments) if (s.op === "move") parts.push(`M ${fmt(s.x)} ${fmt(
|
|
111
|
-
else if (s.op === "line") parts.push(`L ${fmt(s.x)} ${fmt(
|
|
112
|
-
else if (s.op === "cubic") parts.push(`C ${fmt(s.x1)} ${fmt(
|
|
109
|
+
for (const s of segments) if (s.op === "move") parts.push(`M ${fmt(s.x)} ${fmt(s.y)}`);
|
|
110
|
+
else if (s.op === "line") parts.push(`L ${fmt(s.x)} ${fmt(s.y)}`);
|
|
111
|
+
else if (s.op === "cubic") parts.push(`C ${fmt(s.x1)} ${fmt(s.y1)} ${fmt(s.x2)} ${fmt(s.y2)} ${fmt(s.x)} ${fmt(s.y)}`);
|
|
113
112
|
else parts.push("Z");
|
|
114
113
|
return parts.join(" ");
|
|
115
114
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ResourceStore } from "../core/ir/resources.js";
|
|
2
2
|
import { FEATURES } from "../core/ir/features.js";
|
|
3
|
-
import {
|
|
3
|
+
import { applyNumbering, applyNumberingToHeadersFooters } from "../core/numbering/apply.js";
|
|
4
|
+
import { EMPTY_STYLE_SHEET, resolveBodyStyles, resolveHeadersFootersStyles } from "../core/style-cascade/resolver.js";
|
|
4
5
|
import "../core/style-cascade/index.js";
|
|
5
6
|
import { bytesInclude } from "../core/bytes.js";
|
|
6
7
|
import { DEFAULT_THEME_PALETTE, makeColorResolver } from "../core/drawingml/colors.js";
|
|
@@ -66,11 +67,11 @@ function readDocx(docx) {
|
|
|
66
67
|
return {
|
|
67
68
|
doc: {
|
|
68
69
|
kind: "flow",
|
|
69
|
-
body,
|
|
70
|
+
body: resolveBodyStyles(applyNumbering(body, numbering), styles),
|
|
70
71
|
sections,
|
|
71
72
|
styles,
|
|
72
73
|
numbering,
|
|
73
|
-
headersFooters,
|
|
74
|
+
headersFooters: resolveHeadersFootersStyles(applyNumberingToHeadersFooters(headersFooters, numbering), styles),
|
|
74
75
|
charts,
|
|
75
76
|
resources,
|
|
76
77
|
...embeddedFonts.size > 0 ? { embeddedFonts } : {},
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reamkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Ream — DOCX/XLSX to PDF (and SVG), built from scratch on the ECMA-376 and ISO 32000 specifications. Parse once, convert anywhere.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author": "Alex Krassavin",
|
|
6
|
+
"author": "Alex Krassavin <info@reamkit.dev>",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/alex-krassavin/reamkit.git"
|
|
File without changes
|
|
File without changes
|