reamkit 1.26.0 → 1.28.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 +14 -8
- package/dist/esm/core/converter/ream.d.ts +0 -9
- package/dist/esm/core/converter/ream.js +0 -1
- package/dist/esm/core/document-model/types.d.ts +5 -3
- package/dist/esm/core/font/index.d.ts +1 -0
- package/dist/esm/core/font/ligatures.d.ts +17 -0
- package/dist/esm/core/font/ligatures.js +49 -0
- package/dist/esm/core/font/ttf-parser.d.ts +2 -1
- package/dist/esm/core/font/ttf-parser.js +11 -2
- package/dist/esm/core/fonts/remote-fonts.d.ts +1 -1
- package/dist/esm/core/fonts/remote-fonts.js +47 -2
- package/dist/esm/core/fonts/scripts.js +10 -5
- package/dist/esm/excel/header-footer.js +53 -8
- package/dist/esm/layout/styled-layout.js +53 -3
- package/dist/esm/pdf/cid-font.js +35 -8
- package/dist/esm/pdf-reader/annot-draw.d.ts +65 -0
- package/dist/esm/pdf-reader/annot-draw.js +487 -0
- package/dist/esm/pdf-reader/annots.d.ts +0 -12
- package/dist/esm/pdf-reader/annots.js +30 -4
- package/dist/esm/pdf-reader/ccitt.d.ts +20 -3
- package/dist/esm/pdf-reader/ccitt.js +102 -6
- package/dist/esm/pdf-reader/cff-outline.d.ts +36 -0
- package/dist/esm/pdf-reader/cff-outline.js +1122 -0
- package/dist/esm/pdf-reader/cie-color.d.ts +33 -0
- package/dist/esm/pdf-reader/cie-color.js +112 -0
- package/dist/esm/pdf-reader/cmap.js +5 -2
- package/dist/esm/pdf-reader/content.d.ts +123 -3
- package/dist/esm/pdf-reader/content.js +232 -54
- package/dist/esm/pdf-reader/dingbats.d.ts +11 -0
- package/dist/esm/pdf-reader/dingbats.js +1033 -0
- package/dist/esm/pdf-reader/display.d.ts +1 -1
- package/dist/esm/pdf-reader/display.js +61 -6
- package/dist/esm/pdf-reader/document.d.ts +6 -0
- package/dist/esm/pdf-reader/document.js +55 -10
- package/dist/esm/pdf-reader/embedded-fonts.d.ts +23 -3
- package/dist/esm/pdf-reader/embedded-fonts.js +36 -4
- package/dist/esm/pdf-reader/encodings.d.ts +25 -0
- package/dist/esm/pdf-reader/encodings.js +110 -0
- package/dist/esm/pdf-reader/flow-build.d.ts +19 -5
- package/dist/esm/pdf-reader/flow-build.js +111 -11
- package/dist/esm/pdf-reader/font.js +403 -21
- package/dist/esm/pdf-reader/function.d.ts +16 -0
- package/dist/esm/pdf-reader/function.js +414 -0
- package/dist/esm/pdf-reader/glyf-outline.d.ts +43 -0
- package/dist/esm/pdf-reader/glyf-outline.js +351 -0
- package/dist/esm/pdf-reader/glyph-names.js +20 -0
- package/dist/esm/pdf-reader/icc.d.ts +10 -0
- package/dist/esm/pdf-reader/icc.js +210 -0
- package/dist/esm/pdf-reader/image-decode.d.ts +9 -4
- package/dist/esm/pdf-reader/image-decode.js +274 -72
- package/dist/esm/pdf-reader/images.d.ts +18 -0
- package/dist/esm/pdf-reader/images.js +154 -11
- package/dist/esm/pdf-reader/jbig2.d.ts +23 -0
- package/dist/esm/pdf-reader/jbig2.js +126 -32
- package/dist/esm/pdf-reader/layout.d.ts +32 -0
- package/dist/esm/pdf-reader/layout.js +1316 -64
- package/dist/esm/pdf-reader/lexer.d.ts +2 -0
- package/dist/esm/pdf-reader/lexer.js +4 -0
- package/dist/esm/pdf-reader/math-rows.d.ts +23 -0
- package/dist/esm/pdf-reader/math-rows.js +198 -0
- package/dist/esm/pdf-reader/optional-content.d.ts +36 -0
- package/dist/esm/pdf-reader/optional-content.js +93 -0
- package/dist/esm/pdf-reader/predefined-cmap.d.ts +21 -0
- package/dist/esm/pdf-reader/predefined-cmap.js +102 -0
- package/dist/esm/pdf-reader/reader.d.ts +6 -6
- package/dist/esm/pdf-reader/reader.js +102 -16
- package/dist/esm/pdf-reader/shading.d.ts +139 -8
- package/dist/esm/pdf-reader/shading.js +309 -39
- package/dist/esm/pdf-reader/standard-metrics.d.ts +8 -0
- package/dist/esm/pdf-reader/standard-metrics.js +18 -0
- package/dist/esm/pdf-reader/standard-widths.d.ts +20 -0
- package/dist/esm/pdf-reader/standard-widths.js +62 -0
- package/dist/esm/pdf-reader/stream-filters.d.ts +6 -0
- package/dist/esm/pdf-reader/stream-filters.js +67 -0
- package/dist/esm/pdf-reader/tagged.js +204 -32
- package/dist/esm/pdf-reader/text-rules.d.ts +16 -0
- package/dist/esm/pdf-reader/text-rules.js +185 -0
- package/dist/esm/pdf-reader/text.js +157 -4
- package/dist/esm/pdf-reader/type1-outline.d.ts +21 -0
- package/dist/esm/pdf-reader/type1-outline.js +576 -0
- package/dist/esm/pdf-reader/vector.d.ts +5 -0
- package/dist/esm/pdf-reader/vector.js +79 -27
- package/dist/esm/word/document-parser.js +4 -1
- package/dist/esm/word/docx-writer.js +74 -11
- package/package.json +1 -1
|
@@ -71,6 +71,29 @@ export declare function decodeGenericRegion(mq: MQDecoder, cx: Cx, width: number
|
|
|
71
71
|
* @param dy Likewise, vertically.
|
|
72
72
|
*/
|
|
73
73
|
export declare function decodeRefinement(mq: MQDecoder, cx: Cx, width: number, height: number, template: number, reference: Jbig2Bitmap, dx: number, dy: number, at: ReadonlyArray<At>, tpgron: boolean): Jbig2Bitmap;
|
|
74
|
+
/**
|
|
75
|
+
* §6.4.5 — draw a text region: a run of strips, each holding instances of the
|
|
76
|
+
* symbols in `symbols`, placed by running coordinates rather than absolute ones.
|
|
77
|
+
*
|
|
78
|
+
* This is what JBIG2 is for. A scanned page is not stored as pixels but as "the
|
|
79
|
+
* shape called 37, here; the shape called 12, four pixels on" — so the letter
|
|
80
|
+
* "e" costs its bitmap once and a few bits per occurrence after that.
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* §6.4.5 Table 34 — SBSYMCODELEN, how many bits a text region spends naming
|
|
84
|
+
* one of its symbols.
|
|
85
|
+
*
|
|
86
|
+
* `ceil(log2(SBNUMSYMS))`, and for ONE symbol that is ZERO: there is nothing to
|
|
87
|
+
* choose, so no bits are read and the id is always that symbol.
|
|
88
|
+
* Rounded up to one — which the HUFFMAN side of the same table does need — the
|
|
89
|
+
* decoder takes a bit belonging to the next field and reads the id as 1, which
|
|
90
|
+
* is no symbol at all: bitmap-symbol-big-segmentid.pdf places one instance of
|
|
91
|
+
* one symbol in each of two regions, and both came back empty.
|
|
92
|
+
*
|
|
93
|
+
* @param symbols How many symbols the region has to choose between.
|
|
94
|
+
* @returns The number of bits an id takes.
|
|
95
|
+
*/
|
|
96
|
+
export declare function symbolCodeLength(symbols: number): number;
|
|
74
97
|
/**
|
|
75
98
|
* Decode an embedded JBIG2 image.
|
|
76
99
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodeCcitt } from "./ccitt.js";
|
|
1
|
+
import { decodeCcitt, decodeCcittPlanes } from "./ccitt.js";
|
|
2
2
|
//#region src/pdf-reader/jbig2.ts
|
|
3
3
|
function makeBitmap(width, height, fill = 0) {
|
|
4
4
|
const data = new Uint8Array(width * height);
|
|
@@ -1792,21 +1792,38 @@ var Corner = /* @__PURE__ */ function(Corner) {
|
|
|
1792
1792
|
* shape called 37, here; the shape called 12, four pixels on" — so the letter
|
|
1793
1793
|
* "e" costs its bitmap once and a few bits per occurrence after that.
|
|
1794
1794
|
*/
|
|
1795
|
-
|
|
1795
|
+
/**
|
|
1796
|
+
* §6.4.5 Table 34 — SBSYMCODELEN, how many bits a text region spends naming
|
|
1797
|
+
* one of its symbols.
|
|
1798
|
+
*
|
|
1799
|
+
* `ceil(log2(SBNUMSYMS))`, and for ONE symbol that is ZERO: there is nothing to
|
|
1800
|
+
* choose, so no bits are read and the id is always that symbol.
|
|
1801
|
+
* Rounded up to one — which the HUFFMAN side of the same table does need — the
|
|
1802
|
+
* decoder takes a bit belonging to the next field and reads the id as 1, which
|
|
1803
|
+
* is no symbol at all: bitmap-symbol-big-segmentid.pdf places one instance of
|
|
1804
|
+
* one symbol in each of two regions, and both came back empty.
|
|
1805
|
+
*
|
|
1806
|
+
* @param symbols How many symbols the region has to choose between.
|
|
1807
|
+
* @returns The number of bits an id takes.
|
|
1808
|
+
*/
|
|
1809
|
+
function symbolCodeLength(symbols) {
|
|
1810
|
+
return Math.ceil(Math.log2(Math.max(symbols, 1)));
|
|
1811
|
+
}
|
|
1812
|
+
function decodeTextRegion(mq, symbols, p, stripsLog, lent) {
|
|
1796
1813
|
const bmp = makeBitmap(p.width, p.height, p.defPixel);
|
|
1797
1814
|
const strips = 1 << stripsLog;
|
|
1798
|
-
const codeLen =
|
|
1799
|
-
const iadt = new IntDecoder(mq);
|
|
1800
|
-
const iafs = new IntDecoder(mq);
|
|
1801
|
-
const iads = new IntDecoder(mq);
|
|
1802
|
-
const iait = new IntDecoder(mq);
|
|
1803
|
-
const iari = new IntDecoder(mq);
|
|
1804
|
-
const iardw = new IntDecoder(mq);
|
|
1805
|
-
const iardh = new IntDecoder(mq);
|
|
1806
|
-
const iardx = new IntDecoder(mq);
|
|
1807
|
-
const iardy = new IntDecoder(mq);
|
|
1808
|
-
const iaid = new IdDecoder(mq, codeLen);
|
|
1809
|
-
const refineCx = newContexts(8192);
|
|
1815
|
+
const codeLen = lent?.codeLen ?? symbolCodeLength(symbols.length);
|
|
1816
|
+
const iadt = lent?.iadt ?? new IntDecoder(mq);
|
|
1817
|
+
const iafs = lent?.iafs ?? new IntDecoder(mq);
|
|
1818
|
+
const iads = lent?.iads ?? new IntDecoder(mq);
|
|
1819
|
+
const iait = lent?.iait ?? new IntDecoder(mq);
|
|
1820
|
+
const iari = lent?.iari ?? new IntDecoder(mq);
|
|
1821
|
+
const iardw = lent?.iardw ?? new IntDecoder(mq);
|
|
1822
|
+
const iardh = lent?.iardh ?? new IntDecoder(mq);
|
|
1823
|
+
const iardx = lent?.iardx ?? new IntDecoder(mq);
|
|
1824
|
+
const iardy = lent?.iardy ?? new IntDecoder(mq);
|
|
1825
|
+
const iaid = lent?.iaid ?? new IdDecoder(mq, codeLen);
|
|
1826
|
+
const refineCx = lent?.refineCx ?? newContexts(8192);
|
|
1810
1827
|
const num = (v) => v === OOB ? 0 : v;
|
|
1811
1828
|
let stripT = -num(iadt.decode()) * strips;
|
|
1812
1829
|
let firstS = 0;
|
|
@@ -1845,10 +1862,10 @@ function decodeTextRegion(mq, symbols, p, stripsLog) {
|
|
|
1845
1862
|
compose(bmp, sym, x, y, p.combOp);
|
|
1846
1863
|
curS += (p.transposed ? sh : sw) - 1;
|
|
1847
1864
|
placed++;
|
|
1848
|
-
if (placed >= p.instances) break;
|
|
1849
1865
|
const ids = iads.decode();
|
|
1850
1866
|
if (ids === OOB) break;
|
|
1851
1867
|
curS += ids + p.dsOffset;
|
|
1868
|
+
if (placed > p.instances * 2 + 16) break;
|
|
1852
1869
|
}
|
|
1853
1870
|
}
|
|
1854
1871
|
return bmp;
|
|
@@ -1873,6 +1890,22 @@ function decodeSymbolDictionary(mq, input, newCount, exportCount, template, at,
|
|
|
1873
1890
|
const refineCx = newContexts(8192);
|
|
1874
1891
|
const newSymbols = [];
|
|
1875
1892
|
const num = (v) => v === OOB ? 0 : v;
|
|
1893
|
+
const codeLen = symbolCodeLength(input.length + newCount);
|
|
1894
|
+
const iaid = new IdDecoder(mq, codeLen);
|
|
1895
|
+
const lent = {
|
|
1896
|
+
codeLen,
|
|
1897
|
+
iadt: new IntDecoder(mq),
|
|
1898
|
+
iafs: new IntDecoder(mq),
|
|
1899
|
+
iads: new IntDecoder(mq),
|
|
1900
|
+
iait: new IntDecoder(mq),
|
|
1901
|
+
iari: new IntDecoder(mq),
|
|
1902
|
+
iardw: new IntDecoder(mq),
|
|
1903
|
+
iardh: new IntDecoder(mq),
|
|
1904
|
+
iardx,
|
|
1905
|
+
iardy,
|
|
1906
|
+
iaid,
|
|
1907
|
+
refineCx
|
|
1908
|
+
};
|
|
1876
1909
|
let height = 0;
|
|
1877
1910
|
let guard = 0;
|
|
1878
1911
|
while (newSymbols.length < newCount && guard++ < 1e4) {
|
|
@@ -1892,7 +1925,7 @@ function decodeSymbolDictionary(mq, input, newCount, exportCount, template, at,
|
|
|
1892
1925
|
const instances = num(iaai.decode());
|
|
1893
1926
|
if (instances === 1) {
|
|
1894
1927
|
const all = [...input, ...newSymbols];
|
|
1895
|
-
const id =
|
|
1928
|
+
const id = iaid.decode();
|
|
1896
1929
|
const rdx = num(iardx.decode());
|
|
1897
1930
|
const rdy = num(iardy.decode());
|
|
1898
1931
|
newSymbols.push(decodeRefinement(mq, refineCx, width, height, rTemplate, all[id] ?? makeBitmap(1, 1), rdx, rdy, rAt, false));
|
|
@@ -1911,7 +1944,7 @@ function decodeSymbolDictionary(mq, input, newCount, exportCount, template, at,
|
|
|
1911
1944
|
refine: true,
|
|
1912
1945
|
rTemplate,
|
|
1913
1946
|
rAt
|
|
1914
|
-
}, 0));
|
|
1947
|
+
}, 0, lent));
|
|
1915
1948
|
}
|
|
1916
1949
|
}
|
|
1917
1950
|
}
|
|
@@ -2022,15 +2055,73 @@ function decodeTextRegionHuff(bits, data, symbols, p, stripsLog, t) {
|
|
|
2022
2055
|
compose(bmp, sym, x, y, p.combOp);
|
|
2023
2056
|
curS += (p.transposed ? sh : sw) - 1;
|
|
2024
2057
|
placed++;
|
|
2025
|
-
if (placed >= p.instances) break;
|
|
2026
2058
|
const ids = huffDecode(bits, t.ds);
|
|
2027
2059
|
if (ids === OOB) break;
|
|
2028
2060
|
curS += ids + p.dsOffset;
|
|
2061
|
+
if (placed > p.instances * 2 + 16) break;
|
|
2029
2062
|
}
|
|
2030
2063
|
}
|
|
2031
2064
|
return bmp;
|
|
2032
2065
|
}
|
|
2033
2066
|
/**
|
|
2067
|
+
* §6.5.8.2 — one shape of a REFINING Huffman dictionary.
|
|
2068
|
+
*
|
|
2069
|
+
* The dictionary states how many instances the shape is made of. One is a
|
|
2070
|
+
* refinement of a symbol it already holds — the id in as many bits as the
|
|
2071
|
+
* dictionary will end with, the offsets through table B.15, and the
|
|
2072
|
+
* refinement's own length through B.1, so the reader steps over exactly that.
|
|
2073
|
+
* Several is a text region of its own, read with the standard tables §6.5.8.2.1
|
|
2074
|
+
* names and with the symbol ids in plain fixed-width codes.
|
|
2075
|
+
*
|
|
2076
|
+
* @returns The shape, which is `width` by `height` whatever it took to make.
|
|
2077
|
+
*/
|
|
2078
|
+
function aggregateSymbolHuff(bits, data, symbols, width, height, codeLen, refineCx, agg) {
|
|
2079
|
+
const num = (v) => v === OOB ? 0 : v;
|
|
2080
|
+
const instances = num(huffDecode(bits, agg.inst));
|
|
2081
|
+
const b15 = standardTable(15);
|
|
2082
|
+
const b1 = standardTable(1);
|
|
2083
|
+
if (instances !== 1) {
|
|
2084
|
+
const ids = buildHuffTable(Array.from({ length: 1 << codeLen }, (_, i) => ({
|
|
2085
|
+
prefLen: codeLen,
|
|
2086
|
+
rangeLen: 0,
|
|
2087
|
+
rangeLow: i
|
|
2088
|
+
})));
|
|
2089
|
+
return decodeTextRegionHuff(bits, data, symbols, {
|
|
2090
|
+
width,
|
|
2091
|
+
height,
|
|
2092
|
+
instances: Math.max(1, instances),
|
|
2093
|
+
stripT: 0,
|
|
2094
|
+
refCorner: Corner.TopLeft,
|
|
2095
|
+
transposed: false,
|
|
2096
|
+
combOp: 0,
|
|
2097
|
+
defPixel: 0,
|
|
2098
|
+
dsOffset: 0,
|
|
2099
|
+
refine: true,
|
|
2100
|
+
rTemplate: agg.rTemplate,
|
|
2101
|
+
rAt: agg.rAt
|
|
2102
|
+
}, 0, {
|
|
2103
|
+
fs: standardTable(6),
|
|
2104
|
+
ds: standardTable(8),
|
|
2105
|
+
dt: standardTable(11),
|
|
2106
|
+
rdw: b15,
|
|
2107
|
+
rdh: b15,
|
|
2108
|
+
rdx: b15,
|
|
2109
|
+
rdy: b15,
|
|
2110
|
+
rsize: b1,
|
|
2111
|
+
symbolIds: ids
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
const id = bits.readBits(codeLen);
|
|
2115
|
+
const rdx = num(huffDecode(bits, b15));
|
|
2116
|
+
const rdy = num(huffDecode(bits, b15));
|
|
2117
|
+
const size = num(huffDecode(bits, b1));
|
|
2118
|
+
bits.align();
|
|
2119
|
+
const start = bits.bytePos;
|
|
2120
|
+
const bmp = decodeRefinement(new MQDecoder(data.subarray(start)), refineCx, width, height, agg.rTemplate, symbols[id] ?? makeBitmap(1, 1), rdx, rdy, agg.rAt, false);
|
|
2121
|
+
bits.skipTo(start + size);
|
|
2122
|
+
return bmp;
|
|
2123
|
+
}
|
|
2124
|
+
/**
|
|
2034
2125
|
* §6.5.9 — a Huffman-coded symbol dictionary.
|
|
2035
2126
|
*
|
|
2036
2127
|
* The shapes of a height class are not coded one by one: their widths are read
|
|
@@ -2038,9 +2129,11 @@ function decodeTextRegionHuff(bits, data, symbols, p, stripsLog, t) {
|
|
|
2038
2129
|
* apart by those widths. That is why a Huffman dictionary needs a size field
|
|
2039
2130
|
* the arithmetic one does not.
|
|
2040
2131
|
*/
|
|
2041
|
-
function decodeSymbolDictionaryHuff(bits, data, input, newCount, exportCount, dh, dw, bmSize) {
|
|
2132
|
+
function decodeSymbolDictionaryHuff(bits, data, input, newCount, exportCount, dh, dw, bmSize, agg) {
|
|
2042
2133
|
const newSymbols = [];
|
|
2043
2134
|
const num = (v) => v === OOB ? 0 : v;
|
|
2135
|
+
const codeLen = symbolCodeLength(input.length + newCount);
|
|
2136
|
+
const refineCx = newContexts(8192);
|
|
2044
2137
|
let height = 0;
|
|
2045
2138
|
let guard = 0;
|
|
2046
2139
|
while (newSymbols.length < newCount && guard++ < 1e4) {
|
|
@@ -2054,9 +2147,14 @@ function decodeSymbolDictionaryHuff(bits, data, input, newCount, exportCount, dh
|
|
|
2054
2147
|
if (d === OOB) break;
|
|
2055
2148
|
width += d;
|
|
2056
2149
|
if (width <= 0 || width > 16384 || newSymbols.length + widths.length >= newCount + 1) break;
|
|
2150
|
+
if (agg) {
|
|
2151
|
+
newSymbols.push(aggregateSymbolHuff(bits, data, [...input, ...newSymbols], width, height, codeLen, refineCx, agg));
|
|
2152
|
+
continue;
|
|
2153
|
+
}
|
|
2057
2154
|
widths.push(width);
|
|
2058
2155
|
totalWidth += width;
|
|
2059
2156
|
}
|
|
2157
|
+
if (agg) continue;
|
|
2060
2158
|
if (widths.length === 0) continue;
|
|
2061
2159
|
const size = num(huffDecode(bits, bmSize));
|
|
2062
2160
|
bits.align();
|
|
@@ -2164,21 +2262,13 @@ function decodePatternDictionary(data, mmr, template, pw, ph, grayMax) {
|
|
|
2164
2262
|
function decodeGrayScale(mq, data, mmr, template, at, width, height, bits, skip) {
|
|
2165
2263
|
const cx = newContexts(65536);
|
|
2166
2264
|
const planes = new Array(bits);
|
|
2167
|
-
|
|
2265
|
+
const packed = mmr ? decodeCcittPlanes(data, width, height, bits) : void 0;
|
|
2266
|
+
const rowBytes = width + 7 >> 3;
|
|
2168
2267
|
const decoder = mq ?? new MQDecoder(data);
|
|
2169
2268
|
for (let j = bits - 1; j >= 0; j--) if (mmr) {
|
|
2170
|
-
const
|
|
2171
|
-
k: -1,
|
|
2172
|
-
columns: width,
|
|
2173
|
-
rows: height,
|
|
2174
|
-
byteAlign: false
|
|
2175
|
-
});
|
|
2269
|
+
const bytes = packed?.[bits - 1 - j];
|
|
2176
2270
|
const plane = makeBitmap(width, height);
|
|
2177
|
-
if (
|
|
2178
|
-
const rowBytes = width + 7 >> 3;
|
|
2179
|
-
for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) plane.data[y * width + x] = packed[y * rowBytes + (x >> 3)] >> 7 - (x & 7) & 1;
|
|
2180
|
-
mmrOffset += packed.length;
|
|
2181
|
-
}
|
|
2271
|
+
if (bytes) for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) plane.data[y * width + x] = bytes[y * rowBytes + (x >> 3)] >> 7 - (x & 7) & 1;
|
|
2182
2272
|
planes[j] = plane;
|
|
2183
2273
|
} else planes[j] = decodeGenericRegion(decoder, cx, width, height, template, at, false, skip);
|
|
2184
2274
|
const values = new Array(width * height).fill(0);
|
|
@@ -2432,7 +2522,11 @@ function decodeJbig2(data, globals, width, height) {
|
|
|
2432
2522
|
const dwSel = flags >> 4 & 3;
|
|
2433
2523
|
const bmSel = flags >> 6 & 1;
|
|
2434
2524
|
const bits = new BitReader(bytes.subarray(seg.start + r.pos, seg.end));
|
|
2435
|
-
symbolsBySegment.set(seg.number, decodeSymbolDictionaryHuff(bits, bytes.subarray(seg.start + r.pos, seg.end), inherited, newCount, exportCount, pick(dhSel, [4, 5]), pick(dwSel, [2, 3]), bmSel === 1 ? custom[ci++] ?? standardTable(1) : standardTable(1)
|
|
2525
|
+
symbolsBySegment.set(seg.number, decodeSymbolDictionaryHuff(bits, bytes.subarray(seg.start + r.pos, seg.end), inherited, newCount, exportCount, pick(dhSel, [4, 5]), pick(dwSel, [2, 3]), bmSel === 1 ? custom[ci++] ?? standardTable(1) : standardTable(1), refAgg ? {
|
|
2526
|
+
inst: (flags >> 7 & 1) === 1 ? custom[ci++] ?? standardTable(1) : standardTable(1),
|
|
2527
|
+
rTemplate,
|
|
2528
|
+
rAt: rAt.length > 0 ? rAt : NOMINAL_AT_REFINE
|
|
2529
|
+
} : void 0));
|
|
2436
2530
|
continue;
|
|
2437
2531
|
}
|
|
2438
2532
|
symbolsBySegment.set(seg.number, decodeSymbolDictionary(new MQDecoder(bytes.subarray(seg.start + r.pos, seg.end)), inherited, newCount, exportCount, template, at.length > 0 ? at : NOMINAL_AT[template] ?? [], refAgg, rTemplate, rAt.length > 0 ? rAt : NOMINAL_AT_REFINE));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PdfFile } from './document.js';
|
|
2
2
|
import { Reconstruction } from './flow-build.js';
|
|
3
|
+
/** §9.10.2 — a glyph the face maps to no character (see `./font`). */
|
|
4
|
+
export declare const UNMAPPED = "\uFFFD";
|
|
3
5
|
/**
|
|
4
6
|
* Heuristically reconstruct an untagged PDF into a {@link Reconstruction}
|
|
5
7
|
* (E-PDF EP4). With no structure tree there is only positioned content, so
|
|
@@ -16,3 +18,33 @@ import { Reconstruction } from './flow-build.js';
|
|
|
16
18
|
* @returns The reconstructed {@link FlowDoc} plus any read-time losses.
|
|
17
19
|
*/
|
|
18
20
|
export declare function reconstructByLayout(file: PdfFile, mode?: 'flow' | 'positional'): Reconstruction;
|
|
21
|
+
/**
|
|
22
|
+
* Whether a line ENDED a paragraph, rather than wrapping into the next.
|
|
23
|
+
*
|
|
24
|
+
* Leading alone cannot tell the two apart: five labels stacked at 15pt with a
|
|
25
|
+
* 12pt face look exactly like five wrapped lines, and alphatrans.pdf's five are
|
|
26
|
+
* read as one paragraph and re-wrapped into two. But a wrapping engine pulls
|
|
27
|
+
* the next word UP — so a line that stops well short of the measure stopped
|
|
28
|
+
* because its author stopped it, and the line after it begins something new.
|
|
29
|
+
* The same rule separates two paragraphs set with no extra space between them,
|
|
30
|
+
* which used to run together for the same reason.
|
|
31
|
+
*
|
|
32
|
+
* Only where both lines start at the same edge. Where they do not, the block is
|
|
33
|
+
* placed rather than set — a centred title's every line is short of the measure
|
|
34
|
+
* and none of them ends anything.
|
|
35
|
+
*
|
|
36
|
+
* @param prev The line before: where it starts, how wide it is, its face.
|
|
37
|
+
* @param next The line after — only where it starts matters.
|
|
38
|
+
* @param column The measure both were set in, when it is known.
|
|
39
|
+
* @returns Whether the first line ended a paragraph.
|
|
40
|
+
*/
|
|
41
|
+
export declare function endedParagraph(prev: {
|
|
42
|
+
x: number;
|
|
43
|
+
width: number;
|
|
44
|
+
fontSize: number;
|
|
45
|
+
}, next: {
|
|
46
|
+
x: number;
|
|
47
|
+
}, column: {
|
|
48
|
+
left: number;
|
|
49
|
+
right: number;
|
|
50
|
+
} | undefined): boolean;
|