@gilav21/shadcn-angular-rte 0.2.2 → 0.2.3
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/fesm2022/{gilav21-shadcn-angular-rte-docx-parser-CAPT-WC9.mjs → gilav21-shadcn-angular-rte-docx-parser-D_wFX3FP.mjs} +2 -2
- package/fesm2022/{gilav21-shadcn-angular-rte-docx-parser-CAPT-WC9.mjs.map → gilav21-shadcn-angular-rte-docx-parser-D_wFX3FP.mjs.map} +1 -1
- package/fesm2022/{gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-CjHrbpSa.mjs → gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-CHDlfOxW.mjs} +75 -32
- package/fesm2022/gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-CHDlfOxW.mjs.map +1 -0
- package/fesm2022/{gilav21-shadcn-angular-rte-pdf-readable-JvCpuNQH.mjs → gilav21-shadcn-angular-rte-pdf-readable-BKYRkHec.mjs} +142 -192
- package/fesm2022/gilav21-shadcn-angular-rte-pdf-readable-BKYRkHec.mjs.map +1 -0
- package/fesm2022/gilav21-shadcn-angular-rte.mjs +1 -1
- package/package.json +1 -1
- package/types/gilav21-shadcn-angular-rte.d.ts +0 -2
- package/types/gilav21-shadcn-angular-rte.d.ts.map +1 -1
- package/fesm2022/gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-CjHrbpSa.mjs.map +0 -1
- package/fesm2022/gilav21-shadcn-angular-rte-pdf-readable-JvCpuNQH.mjs.map +0 -1
|
@@ -85,23 +85,37 @@ class DecodeBudget {
|
|
|
85
85
|
* `number[]` let a bomb take over a gigabyte before it tripped.
|
|
86
86
|
*/
|
|
87
87
|
const MAX_DECODED_STREAM_BYTES = 64 * 1024 * 1024;
|
|
88
|
+
// ── Hex decoding ────────────────────────────────────────────────────────
|
|
89
|
+
/**
|
|
90
|
+
* The bytes a run of hex digits spells (PDF 32000-1, 7.3.4.3): digits only, a final lone digit read as
|
|
91
|
+
* if followed by 0. Anything else, white-space and junk alike, is skipped.
|
|
92
|
+
*
|
|
93
|
+
* It is the one decoder for hex in object syntax, in content streams and in the ASCIIHexDecode
|
|
94
|
+
* filter, and it is total: the input is untrusted, so no character sequence may throw (a
|
|
95
|
+
* `String.fromCodePoint(NaN)` from `<ZZ>` aborted the whole outline, or blanked the whole page) or
|
|
96
|
+
* be read as a digit it is not (`parseInt('4Z', 16)` is 4, a silent wrong byte).
|
|
97
|
+
*/
|
|
98
|
+
function decodeHexDigits(raw) {
|
|
99
|
+
const digits = raw.replaceAll(/[^\da-f]/gi, '');
|
|
100
|
+
const padded = digits.length % 2 === 0 ? digits : `${digits}0`;
|
|
101
|
+
const bytes = new Uint8Array(padded.length / 2);
|
|
102
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
103
|
+
bytes[i] = Number.parseInt(padded.slice(i * 2, i * 2 + 2), 16);
|
|
104
|
+
}
|
|
105
|
+
return bytes;
|
|
106
|
+
}
|
|
107
|
+
/** A hex string's bytes as the one-byte-per-character string the parser keeps PDF strings in. */
|
|
108
|
+
function hexToByteString(raw) {
|
|
109
|
+
let str = '';
|
|
110
|
+
for (const byte of decodeHexDigits(raw))
|
|
111
|
+
str += String.fromCodePoint(byte);
|
|
112
|
+
return str;
|
|
113
|
+
}
|
|
88
114
|
// ── Stream filter decoders ──────────────────────────────────────────────
|
|
89
115
|
function decodeASCIIHex(data) {
|
|
90
116
|
const text = new TextDecoder('latin1').decode(data);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (ch === '>')
|
|
94
|
-
break;
|
|
95
|
-
if (!' \t\r\n\0\f'.includes(ch))
|
|
96
|
-
hex += ch;
|
|
97
|
-
}
|
|
98
|
-
if (hex.length % 2 !== 0)
|
|
99
|
-
hex += '0';
|
|
100
|
-
const result = new Uint8Array(hex.length / 2);
|
|
101
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
102
|
-
result[i / 2] = Number.parseInt(hex.substring(i, i + 2), 16);
|
|
103
|
-
}
|
|
104
|
-
return result;
|
|
117
|
+
const end = text.indexOf('>');
|
|
118
|
+
return decodeHexDigits(end < 0 ? text : text.slice(0, end));
|
|
105
119
|
}
|
|
106
120
|
function ascii85IsEndMarker(text, i) {
|
|
107
121
|
return text[i] === '~' && i + 1 < text.length && text[i + 1] === '>';
|
|
@@ -1128,8 +1142,10 @@ class PdfReader {
|
|
|
1128
1142
|
const c = this.text[pos];
|
|
1129
1143
|
if (' \t\r\n\0\f/<>[](){}%'.includes(c))
|
|
1130
1144
|
break;
|
|
1131
|
-
|
|
1132
|
-
|
|
1145
|
+
// `#` introduces two hex digits (7.3.5); anything else after it leaves the `#` as written.
|
|
1146
|
+
const escape = c === '#' ? /^[\da-f]{2}/i.exec(this.text.slice(pos + 1, pos + 3)) : null;
|
|
1147
|
+
if (escape) {
|
|
1148
|
+
name += String.fromCodePoint(Number.parseInt(escape[0], 16));
|
|
1133
1149
|
pos += 3;
|
|
1134
1150
|
}
|
|
1135
1151
|
else {
|
|
@@ -1199,23 +1215,10 @@ class PdfReader {
|
|
|
1199
1215
|
return { obj: { type: 'string', value: str }, endPos: pos };
|
|
1200
1216
|
}
|
|
1201
1217
|
parseHexString(pos) {
|
|
1202
|
-
pos
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
if (!' \t\r\n\0\f'.includes(c))
|
|
1207
|
-
hex += c;
|
|
1208
|
-
pos++;
|
|
1209
|
-
}
|
|
1210
|
-
if (this.text[pos] === '>')
|
|
1211
|
-
pos++;
|
|
1212
|
-
if (hex.length % 2 !== 0)
|
|
1213
|
-
hex += '0';
|
|
1214
|
-
let str = '';
|
|
1215
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
1216
|
-
str += String.fromCodePoint(Number.parseInt(hex.substring(i, i + 2), 16));
|
|
1217
|
-
}
|
|
1218
|
-
return { obj: { type: 'string', value: str }, endPos: pos };
|
|
1218
|
+
const start = pos + 1;
|
|
1219
|
+
const close = this.text.indexOf('>', start);
|
|
1220
|
+
const end = close < 0 ? this.text.length : close;
|
|
1221
|
+
return { obj: { type: 'string', value: hexToByteString(this.text.slice(start, end)) }, endPos: close < 0 ? end : end + 1 };
|
|
1219
1222
|
}
|
|
1220
1223
|
parseObjectStream(streamObjNum) {
|
|
1221
1224
|
const streamKey = `${streamObjNum} 0`;
|
|
@@ -1799,8 +1802,8 @@ function fixVisualOrderRTL(text) {
|
|
|
1799
1802
|
}
|
|
1800
1803
|
function joinSplitHebrewFragments(text) {
|
|
1801
1804
|
return text
|
|
1802
|
-
.replaceAll(/"([\u0590-\u05FF]+)\s+([\u0590-\u05FF])(?=\s|[^"\u0590-\u05FF]|$)/g, (
|
|
1803
|
-
.replaceAll(/(?<![\u0590-\u05FF])([\u0590-\u05FF])\s+([\u0590-\u05FF]+)"(?=\s|[^"\u0590-\u05FF]|$)/g, (
|
|
1805
|
+
.replaceAll(/"([\u0590-\u05FF]+)\s+([\u0590-\u05FF])(?=\s|[^"\u0590-\u05FF]|$)/g, (...[, p1, p2]) => p1 + '"' + p2)
|
|
1806
|
+
.replaceAll(/(?<![\u0590-\u05FF])([\u0590-\u05FF])\s+([\u0590-\u05FF]+)"(?=\s|[^"\u0590-\u05FF]|$)/g, (...[, p1, p2]) => p1 + p2 + '"');
|
|
1804
1807
|
}
|
|
1805
1808
|
function fixBracketsAroundLtrWords(text) {
|
|
1806
1809
|
// fixRTLWordChars inverts brackets around LTR words (e.g. "(Default)-ה" → "ה-)Default(").
|
|
@@ -2075,22 +2078,10 @@ function tokenizeLiteralString$1(text, startPos) {
|
|
|
2075
2078
|
return { token: '(' + str + ')', endPos: pos };
|
|
2076
2079
|
}
|
|
2077
2080
|
function tokenizeHexString$1(text, startPos) {
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
hex += text[pos];
|
|
2083
|
-
pos++;
|
|
2084
|
-
}
|
|
2085
|
-
if (pos < text.length)
|
|
2086
|
-
pos++;
|
|
2087
|
-
if (hex.length % 2 !== 0)
|
|
2088
|
-
hex += '0';
|
|
2089
|
-
let str = '';
|
|
2090
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
2091
|
-
str += String.fromCodePoint(Number.parseInt(hex.substring(i, i + 2), 16));
|
|
2092
|
-
}
|
|
2093
|
-
return { token: '(' + str + ')', endPos: pos };
|
|
2081
|
+
const start = startPos + 1;
|
|
2082
|
+
const close = text.indexOf('>', start);
|
|
2083
|
+
const end = close < 0 ? text.length : close;
|
|
2084
|
+
return { token: '(' + hexToByteString(text.slice(start, end)) + ')', endPos: close < 0 ? end : end + 1 };
|
|
2094
2085
|
}
|
|
2095
2086
|
function skipComment$1(text, pos) {
|
|
2096
2087
|
while (pos < text.length && text[pos] !== '\n' && text[pos] !== '\r')
|
|
@@ -2964,7 +2955,7 @@ const IGNORED_OPERATORS = new Set([
|
|
|
2964
2955
|
'EI',
|
|
2965
2956
|
'MP', 'DP',
|
|
2966
2957
|
]);
|
|
2967
|
-
function processStrokeColorOperator(token,
|
|
2958
|
+
function processStrokeColorOperator(token, gs, popNum) {
|
|
2968
2959
|
switch (token) {
|
|
2969
2960
|
case 'RG': {
|
|
2970
2961
|
const b = popNum();
|
|
@@ -3808,7 +3799,7 @@ function dispatchContentOperator(token, ctx) {
|
|
|
3808
3799
|
return true;
|
|
3809
3800
|
if (processColorOperator(token, ctx, () => popNumber(ctx)))
|
|
3810
3801
|
return true;
|
|
3811
|
-
if (processStrokeColorOperator(token, ctx.
|
|
3802
|
+
if (processStrokeColorOperator(token, ctx.gs, () => popNumber(ctx)))
|
|
3812
3803
|
return true;
|
|
3813
3804
|
if (processStrokeColorSpaceOperator(token, ctx))
|
|
3814
3805
|
return true;
|
|
@@ -5139,7 +5130,7 @@ function insertImagesBeforeY(state, sortedImages, page, y) {
|
|
|
5139
5130
|
state.imageIdx++;
|
|
5140
5131
|
}
|
|
5141
5132
|
}
|
|
5142
|
-
function renderLineAsHeading(state, line, headingLevel, bodyFont, bodySize
|
|
5133
|
+
function renderLineAsHeading(state, line, headingLevel, bodyFont, bodySize) {
|
|
5143
5134
|
flushParagraph(state);
|
|
5144
5135
|
closeList(state);
|
|
5145
5136
|
const content = lineToHtmlContent(line, bodyFont, bodySize, state.annotations);
|
|
@@ -5161,7 +5152,7 @@ function renderLineAsHeading(state, line, headingLevel, bodyFont, bodySize, _lin
|
|
|
5161
5152
|
state.html.push(`<h${headingLevel}${dirAttr}${styleAttr}>${content}</h${headingLevel}>`);
|
|
5162
5153
|
state.lastLineSpacing = 0;
|
|
5163
5154
|
}
|
|
5164
|
-
function renderLineAsBullet(state, line,
|
|
5155
|
+
function renderLineAsBullet(state, line, bodyFont, bodySize) {
|
|
5165
5156
|
flushParagraph(state);
|
|
5166
5157
|
if (state.inNumberedList) {
|
|
5167
5158
|
state.html.push('</ol>');
|
|
@@ -5178,7 +5169,7 @@ function renderLineAsBullet(state, line, lineText, bodyFont, bodySize) {
|
|
|
5178
5169
|
const dirAttr = rtl ? ' dir="rtl"' : '';
|
|
5179
5170
|
state.html.push(`<li${dirAttr}>${content}</li>`);
|
|
5180
5171
|
}
|
|
5181
|
-
function renderLineAsNumbered(state, line,
|
|
5172
|
+
function renderLineAsNumbered(state, line, bodyFont, bodySize) {
|
|
5182
5173
|
flushParagraph(state);
|
|
5183
5174
|
const rtl = isLineRTL(line);
|
|
5184
5175
|
if (state.inBulletList) {
|
|
@@ -5230,16 +5221,16 @@ function processHtmlLine(line, lineText, bodySize, bodyFont, state, options) {
|
|
|
5230
5221
|
const primaryFontSize = line.items.reduce((max, item) => Math.max(max, item.fontSize), 0);
|
|
5231
5222
|
const headingLevel = structHeading > 0 ? structHeading : getHeadingLevel(primaryFontSize, bodySize);
|
|
5232
5223
|
if (headingLevel > 0) {
|
|
5233
|
-
renderLineAsHeading(state, line, headingLevel, bodyFont, bodySize
|
|
5224
|
+
renderLineAsHeading(state, line, headingLevel, bodyFont, bodySize);
|
|
5234
5225
|
return;
|
|
5235
5226
|
}
|
|
5236
5227
|
const isStructList = structType !== null && isStructureListItem(structType);
|
|
5237
5228
|
if (isStructList || BULLET_PATTERN.test(lineText)) {
|
|
5238
|
-
renderLineAsBullet(state, line,
|
|
5229
|
+
renderLineAsBullet(state, line, bodyFont, bodySize);
|
|
5239
5230
|
return;
|
|
5240
5231
|
}
|
|
5241
5232
|
if (isNumberedLine(lineText, rtl)) {
|
|
5242
|
-
renderLineAsNumbered(state, line,
|
|
5233
|
+
renderLineAsNumbered(state, line, bodyFont, bodySize);
|
|
5243
5234
|
return;
|
|
5244
5235
|
}
|
|
5245
5236
|
appendToParagraph(line, bodySize, bodyFont, state, options, rtl);
|
|
@@ -5781,7 +5772,7 @@ function applyParagraphSpacing(state, lineSpacing, bodySize) {
|
|
|
5781
5772
|
state.currentParagraphSpacingPx = Math.max(state.currentParagraphSpacingPx, px);
|
|
5782
5773
|
}
|
|
5783
5774
|
}
|
|
5784
|
-
function handleBorderBoxLine(
|
|
5775
|
+
function handleBorderBoxLine(ctx, state, renderedBorderBoxes, borderBox) {
|
|
5785
5776
|
if (!renderedBorderBoxes.has(borderBox)) {
|
|
5786
5777
|
flushParagraph(state);
|
|
5787
5778
|
closeList(state);
|
|
@@ -5809,7 +5800,7 @@ function processRegularLine(line, lineText, ctx, state, renderedBorderBoxes) {
|
|
|
5809
5800
|
const { underlinedItems, structureMap, allBorderBoxes, bodySize, bodyFont, pageWidth, leftMargin, rightMargin } = ctx;
|
|
5810
5801
|
const borderBox = isLineInsideBorderBox(line, allBorderBoxes);
|
|
5811
5802
|
if (borderBox) {
|
|
5812
|
-
handleBorderBoxLine(
|
|
5803
|
+
handleBorderBoxLine(ctx, state, renderedBorderBoxes, borderBox);
|
|
5813
5804
|
return;
|
|
5814
5805
|
}
|
|
5815
5806
|
const lineSpacing = state.lastY !== null && line.items[0].page === state.lastPage
|
|
@@ -6326,63 +6317,60 @@ function parseOutline(reader, pdfPages) {
|
|
|
6326
6317
|
const firstRef = outlinesDict['First'];
|
|
6327
6318
|
if (!firstRef)
|
|
6328
6319
|
return [];
|
|
6329
|
-
const
|
|
6330
|
-
return parseOutlineItems(reader, firstRef,
|
|
6320
|
+
const pageIndexes = buildPageIndexMap(pdfPages);
|
|
6321
|
+
return parseOutlineItems(reader, firstRef, pageIndexes, 0, new Set());
|
|
6331
6322
|
}
|
|
6332
6323
|
catch {
|
|
6333
6324
|
return [];
|
|
6334
6325
|
}
|
|
6335
6326
|
}
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
return map;
|
|
6327
|
+
/**
|
|
6328
|
+
* Page index by page object. `getPages()` returns the resolved page dictionaries, not references, and
|
|
6329
|
+
* the reader caches every object it resolves, so a destination's reference to a page resolves to the
|
|
6330
|
+
* very object this list holds: identity is the key. (Keying on a reference string matched nothing,
|
|
6331
|
+
* because the list never holds references, and every outline item reported page -1.)
|
|
6332
|
+
*/
|
|
6333
|
+
function buildPageIndexMap(pdfPages) {
|
|
6334
|
+
return new Map(pdfPages.map((page, index) => [page, index]));
|
|
6345
6335
|
}
|
|
6346
|
-
|
|
6336
|
+
/** The page an explicit destination array `[page /Fit ...]` names, or undefined when its first entry is not a page of the document. */
|
|
6337
|
+
function resolveRefArrayPageIndex(reader, destObj, pageIndexes) {
|
|
6347
6338
|
const resolved = reader.resolveDeep(destObj);
|
|
6348
|
-
if (resolved.type
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
}
|
|
6354
|
-
return -1;
|
|
6339
|
+
if (resolved.type !== 'array')
|
|
6340
|
+
return undefined;
|
|
6341
|
+
const target = resolved.value[0];
|
|
6342
|
+
// A page number (a remote destination's form) is not a reference and names no page here.
|
|
6343
|
+
return target?.type === 'ref' ? pageIndexes.get(reader.resolveDeep(target)) : undefined;
|
|
6355
6344
|
}
|
|
6356
|
-
function resolveOutlinePageIndex(reader, item,
|
|
6345
|
+
function resolveOutlinePageIndex(reader, item, pageIndexes) {
|
|
6357
6346
|
const dest = item['Dest'];
|
|
6358
6347
|
if (dest) {
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
return idx;
|
|
6348
|
+
if (reader.resolveDeep(dest).type === 'string')
|
|
6349
|
+
return undefined;
|
|
6350
|
+
const index = resolveRefArrayPageIndex(reader, dest, pageIndexes);
|
|
6351
|
+
if (index !== undefined)
|
|
6352
|
+
return index;
|
|
6365
6353
|
}
|
|
6366
6354
|
const aObj = item['A'];
|
|
6367
6355
|
if (!aObj)
|
|
6368
|
-
return
|
|
6356
|
+
return undefined;
|
|
6369
6357
|
try {
|
|
6370
6358
|
const action = reader.getDict(aObj);
|
|
6371
6359
|
const s = reader.getString(action['S'] ?? { type: 'null', value: null });
|
|
6372
6360
|
if (s !== 'GoTo')
|
|
6373
|
-
return
|
|
6361
|
+
return undefined;
|
|
6374
6362
|
const d = action['D'];
|
|
6375
|
-
return d ? resolveRefArrayPageIndex(reader, d,
|
|
6363
|
+
return d ? resolveRefArrayPageIndex(reader, d, pageIndexes) : undefined;
|
|
6376
6364
|
}
|
|
6377
6365
|
catch {
|
|
6378
|
-
return
|
|
6366
|
+
return undefined;
|
|
6379
6367
|
}
|
|
6380
6368
|
}
|
|
6381
6369
|
/**
|
|
6382
6370
|
* `visited` spans the whole outline tree, not one sibling list: two items
|
|
6383
6371
|
* pointing at the same child list would otherwise each expand it in full.
|
|
6384
6372
|
*/
|
|
6385
|
-
function parseOutlineItems(reader, firstRef,
|
|
6373
|
+
function parseOutlineItems(reader, firstRef, pageIndexes, depth, visited) {
|
|
6386
6374
|
if (depth > 10)
|
|
6387
6375
|
return [];
|
|
6388
6376
|
const items = [];
|
|
@@ -6396,11 +6384,11 @@ function parseOutlineItems(reader, firstRef, pageMap, depth, visited) {
|
|
|
6396
6384
|
try {
|
|
6397
6385
|
const itemDict = reader.getDict(currentRef);
|
|
6398
6386
|
const title = reader.getString(itemDict['Title'] ?? { type: 'string', value: '' });
|
|
6399
|
-
const pageIndex = resolveOutlinePageIndex(reader, itemDict,
|
|
6387
|
+
const pageIndex = resolveOutlinePageIndex(reader, itemDict, pageIndexes);
|
|
6400
6388
|
let children = [];
|
|
6401
6389
|
const childFirst = itemDict['First'];
|
|
6402
6390
|
if (childFirst) {
|
|
6403
|
-
children = parseOutlineItems(reader, childFirst,
|
|
6391
|
+
children = parseOutlineItems(reader, childFirst, pageIndexes, depth + 1, visited);
|
|
6404
6392
|
}
|
|
6405
6393
|
items.push({ title, pageIndex, children });
|
|
6406
6394
|
const nextRef = itemDict['Next'];
|
|
@@ -6631,7 +6619,7 @@ function scaleSimpleGlyph(srcData, scaleX, scaleY) {
|
|
|
6631
6619
|
});
|
|
6632
6620
|
}
|
|
6633
6621
|
else {
|
|
6634
|
-
afterX = skipCoordinates(
|
|
6622
|
+
afterX = skipCoordinates(xDataOff, flags, numPoints, X_SHORT_VECTOR, X_IS_SAME_OR_POSITIVE);
|
|
6635
6623
|
}
|
|
6636
6624
|
// Scale y-coordinates
|
|
6637
6625
|
if (Math.abs(scaleY - 1) > 1e-6) {
|
|
@@ -6643,7 +6631,7 @@ function scaleSimpleGlyph(srcData, scaleX, scaleY) {
|
|
|
6643
6631
|
return result;
|
|
6644
6632
|
}
|
|
6645
6633
|
// ── Skip coordinates without modifying (to find offset of next axis) ────
|
|
6646
|
-
function skipCoordinates(
|
|
6634
|
+
function skipCoordinates(offset, flags, numPoints, shortBit, sameBit) {
|
|
6647
6635
|
let pos = offset;
|
|
6648
6636
|
for (let i = 0; i < numPoints; i++) {
|
|
6649
6637
|
const flag = flags[i];
|
|
@@ -6747,7 +6735,6 @@ class TtfFont {
|
|
|
6747
6735
|
const locaRec = this.getTableData('loca');
|
|
6748
6736
|
const glyfRec = this.getTableData('glyf');
|
|
6749
6737
|
this.glyfOffset = glyfRec?.offset ?? 0;
|
|
6750
|
-
this.glyfLength = glyfRec?.length ?? 0;
|
|
6751
6738
|
this.glyphOffsets = locaRec && glyfRec
|
|
6752
6739
|
? this.parseLoca(locaRec, indexToLocFormat)
|
|
6753
6740
|
: [];
|
|
@@ -7518,21 +7505,6 @@ function cssQuotedFontName(name) {
|
|
|
7518
7505
|
}
|
|
7519
7506
|
return `'${quoted}'`;
|
|
7520
7507
|
}
|
|
7521
|
-
const SAFE_LINK_PROTOCOLS = new Set(['http:', 'https:', 'mailto:']);
|
|
7522
|
-
/**
|
|
7523
|
-
* The link annotation's URI as the browser will parse it when it is an absolute
|
|
7524
|
-
* http, https or mailto URL; `undefined` for any other scheme or a relative URI.
|
|
7525
|
-
*/
|
|
7526
|
-
function safeLinkUri(uri) {
|
|
7527
|
-
try {
|
|
7528
|
-
const url = new URL(uri);
|
|
7529
|
-
return SAFE_LINK_PROTOCOLS.has(url.protocol) ? url.href : undefined;
|
|
7530
|
-
}
|
|
7531
|
-
catch {
|
|
7532
|
-
// Not an absolute URL; a relative URI has no page to resolve against here.
|
|
7533
|
-
return undefined;
|
|
7534
|
-
}
|
|
7535
|
-
}
|
|
7536
7508
|
function resolveFontDescriptor(reader, fontObjDict) {
|
|
7537
7509
|
const direct = fontObjDict['FontDescriptor'];
|
|
7538
7510
|
if (direct)
|
|
@@ -8698,7 +8670,7 @@ class TextLine {
|
|
|
8698
8670
|
// F5: optimize_normal (HTMLTextLine.cc:363-540) — 1:1 C++ translation
|
|
8699
8671
|
// Adjusts letter-space and word-space to reduce HTML element count.
|
|
8700
8672
|
// Builds new_offsets list and swaps at end (C++ line 537).
|
|
8701
|
-
optimizeNormal(mgr,
|
|
8673
|
+
optimizeNormal(mgr, spaceThreshold, z) {
|
|
8702
8674
|
// C++ line 366-367: remove useless states at end
|
|
8703
8675
|
let lastSt = this.states.at(-1);
|
|
8704
8676
|
while (lastSt && (lastSt.installed?.startIdx ?? 0) >= this.text.length) {
|
|
@@ -8807,7 +8779,7 @@ class TextLine {
|
|
|
8807
8779
|
* <span class="[diff classes]">styled text</span>
|
|
8808
8780
|
* </div>
|
|
8809
8781
|
*/
|
|
8810
|
-
dumpText(mgr,
|
|
8782
|
+
dumpText(mgr, hEps, spaceThreshold, z) {
|
|
8811
8783
|
if (this.text.length === 0 && this.states.length === 0)
|
|
8812
8784
|
return '';
|
|
8813
8785
|
const mId = mgr.transformMatrix.install(this.transformMatrix);
|
|
@@ -8817,7 +8789,7 @@ class TextLine {
|
|
|
8817
8789
|
const parts = [];
|
|
8818
8790
|
const divClasses = this.buildDivClasses(mId, xId, yId, hId);
|
|
8819
8791
|
parts.push(`<div class="${divClasses}">`);
|
|
8820
|
-
this.emitLineContent(parts, mgr,
|
|
8792
|
+
this.emitLineContent(parts, mgr, hEps, spaceThreshold, z);
|
|
8821
8793
|
parts.push('</div>');
|
|
8822
8794
|
return parts.join('');
|
|
8823
8795
|
}
|
|
@@ -8835,7 +8807,7 @@ class TextLine {
|
|
|
8835
8807
|
// F6: emitLineContent — 1:1 translation of C++ dump_text inner loop
|
|
8836
8808
|
// (HTMLTextLine.cc:226-293). Interleaves offset and text output with
|
|
8837
8809
|
// accumulated dx and single_space_offset matching.
|
|
8838
|
-
emitLineContent(parts, mgr,
|
|
8810
|
+
emitLineContent(parts, mgr, hEps, spaceThreshold, z) {
|
|
8839
8811
|
const stateStack = [];
|
|
8840
8812
|
if (this.states.length > 0 && this.states[0].installed) {
|
|
8841
8813
|
stateStack.push(this.states[0].installed);
|
|
@@ -8904,16 +8876,6 @@ class TextLine {
|
|
|
8904
8876
|
}
|
|
8905
8877
|
}
|
|
8906
8878
|
}
|
|
8907
|
-
findStateForIndex(charIdx, currentIdx) {
|
|
8908
|
-
for (let si = currentIdx + 1; si < this.states.length; si++) {
|
|
8909
|
-
const stateStart = this.states[si].installed?.startIdx ?? 0;
|
|
8910
|
-
if (stateStart > charIdx)
|
|
8911
|
-
return currentIdx;
|
|
8912
|
-
if (stateStart === charIdx)
|
|
8913
|
-
return si;
|
|
8914
|
-
}
|
|
8915
|
-
return currentIdx;
|
|
8916
|
-
}
|
|
8917
8879
|
emitOffset(parts, opts) {
|
|
8918
8880
|
const { mgr, ts, installed, target, hEps, spaceThreshold, z } = opts;
|
|
8919
8881
|
if (Math.abs(target) <= hEps)
|
|
@@ -9004,12 +8966,6 @@ class TextLine {
|
|
|
9004
8966
|
d++;
|
|
9005
8967
|
return d;
|
|
9006
8968
|
}
|
|
9007
|
-
getEmSizeForState(stateIdx, z) {
|
|
9008
|
-
if (stateIdx < this.states.length) {
|
|
9009
|
-
return this.states[stateIdx].textState.fontSize * z;
|
|
9010
|
-
}
|
|
9011
|
-
return 12 * z;
|
|
9012
|
-
}
|
|
9013
8969
|
}
|
|
9014
8970
|
const PP_EPS = 1e-6;
|
|
9015
8971
|
const FILL_BY_RENDER_MODE = [true, false, true, false, true, false, true, false];
|
|
@@ -9020,7 +8976,6 @@ function setLineState(current, target) {
|
|
|
9020
8976
|
const FONT_SIZE_MULTIPLIER = 4; // pdf2htmlEX default (pdf2htmlEX.cc:185)
|
|
9021
8977
|
class PixelPerfectProcessor {
|
|
9022
8978
|
constructor(reader, fontRegistry, zoom) {
|
|
9023
|
-
this.pageHeight = 792;
|
|
9024
8979
|
// PDF graphics state
|
|
9025
8980
|
this.ctm = [1, 0, 0, 1, 0, 0];
|
|
9026
8981
|
this.textMatrix = [1, 0, 0, 1, 0, 0];
|
|
@@ -9047,8 +9002,6 @@ class PixelPerfectProcessor {
|
|
|
9047
9002
|
this.curFontSize = 0;
|
|
9048
9003
|
this.curTextTm = [1, 0, 0, 1, 0, 0];
|
|
9049
9004
|
// State from before current checkStateChange
|
|
9050
|
-
this.prevDrawTextScale = 1;
|
|
9051
|
-
this.prevTextTm = [1, 0, 0, 1, 0, 0];
|
|
9052
9005
|
// HTML state (mirrors C++ cur_text_state / cur_line_state)
|
|
9053
9006
|
this.curTransformMatrix = [1, 0, 0, 1];
|
|
9054
9007
|
this.prevTransformMatrix = [1, 0, 0, 1];
|
|
@@ -9094,7 +9047,7 @@ class PixelPerfectProcessor {
|
|
|
9094
9047
|
const { maxNestingDepth, maxFormDrawsPerPage } = this.reader.limits;
|
|
9095
9048
|
return new DrawPath(maxNestingDepth, maxFormDrawsPerPage);
|
|
9096
9049
|
}
|
|
9097
|
-
processPage(pageObj
|
|
9050
|
+
processPage(pageObj) {
|
|
9098
9051
|
this.resetState();
|
|
9099
9052
|
this.formDraws = this.newFormDraws();
|
|
9100
9053
|
this.lines.length = 0;
|
|
@@ -9104,7 +9057,6 @@ class PixelPerfectProcessor {
|
|
|
9104
9057
|
const mediaBox = getPageMediaBox(this.reader, pageDict);
|
|
9105
9058
|
let pageWidth = Math.abs(mediaBox[2] - mediaBox[0]);
|
|
9106
9059
|
let pageHeight = Math.abs(mediaBox[3] - mediaBox[1]);
|
|
9107
|
-
this.pageHeight = pageHeight;
|
|
9108
9060
|
this.initialYScale = 0;
|
|
9109
9061
|
const rotation = pageDict['Rotate'] ? this.reader.getNumber(pageDict['Rotate']) : 0;
|
|
9110
9062
|
if (rotation === 90 || rotation === 270) {
|
|
@@ -9128,7 +9080,7 @@ class PixelPerfectProcessor {
|
|
|
9128
9080
|
this.lines.push(this.currentLine);
|
|
9129
9081
|
}
|
|
9130
9082
|
// Extract annotations
|
|
9131
|
-
const annotations = this.extractAnnotations(pageDict
|
|
9083
|
+
const annotations = this.extractAnnotations(pageDict);
|
|
9132
9084
|
return {
|
|
9133
9085
|
lines: [...this.lines],
|
|
9134
9086
|
pathRects: [...this.pathRects],
|
|
@@ -9161,8 +9113,6 @@ class PixelPerfectProcessor {
|
|
|
9161
9113
|
this.curTy = 0;
|
|
9162
9114
|
this.curFontSize = 0;
|
|
9163
9115
|
this.curTextTm = [1, 0, 0, 1, 0, 0];
|
|
9164
|
-
this.prevTextTm = [1, 0, 0, 1, 0, 0];
|
|
9165
|
-
this.prevDrawTextScale = 1;
|
|
9166
9116
|
this.curTransformMatrix = [1, 0, 0, 1];
|
|
9167
9117
|
this.prevTransformMatrix = [1, 0, 0, 1];
|
|
9168
9118
|
this.curLetterSpace = 0;
|
|
@@ -9196,8 +9146,6 @@ class PixelPerfectProcessor {
|
|
|
9196
9146
|
const oldTm = [...this.curTextTm];
|
|
9197
9147
|
const oldDrawTextScale = this.drawTextScale;
|
|
9198
9148
|
this.prevTransformMatrix = this.curTransformMatrix;
|
|
9199
|
-
this.prevTextTm = oldTm;
|
|
9200
|
-
this.prevDrawTextScale = oldDrawTextScale;
|
|
9201
9149
|
// Font change (state.cc:208-239)
|
|
9202
9150
|
if (this.allChanged || this.fontChanged) {
|
|
9203
9151
|
const newFontInfo = this.fontInfoMap.get(this.fontName);
|
|
@@ -9466,52 +9414,52 @@ class PixelPerfectProcessor {
|
|
|
9466
9414
|
registerGraphicsStateOps(m, noop) {
|
|
9467
9415
|
m.set('q', () => this.saveState());
|
|
9468
9416
|
m.set('Q', () => this.restoreState());
|
|
9469
|
-
m.set('cm', (
|
|
9470
|
-
m.set('w', (
|
|
9417
|
+
m.set('cm', (ops) => this.opCm(ops));
|
|
9418
|
+
m.set('w', (ops) => { if (ops.length >= 1)
|
|
9471
9419
|
this.lineWidth = Number.parseFloat(ops[0]); });
|
|
9472
|
-
m.set('g', (
|
|
9473
|
-
m.set('G', (
|
|
9474
|
-
m.set('rg', (
|
|
9475
|
-
m.set('RG', (
|
|
9476
|
-
m.set('k', (
|
|
9477
|
-
m.set('K', (
|
|
9478
|
-
m.set('cs', (
|
|
9479
|
-
m.set('CS', (
|
|
9480
|
-
m.set('sc', (
|
|
9481
|
-
m.set('SC', (
|
|
9482
|
-
m.set('scn', (
|
|
9483
|
-
m.set('SCN', (
|
|
9484
|
-
m.set('Do', (
|
|
9485
|
-
m.set('gs', (
|
|
9420
|
+
m.set('g', (ops) => { this.fillColor = grayToHex(Number.parseFloat(ops[0] ?? '0')); this.fillColorChanged = true; });
|
|
9421
|
+
m.set('G', (ops) => { this.strokeColor = grayToHex(Number.parseFloat(ops[0] ?? '0')); this.strokeColorChanged = true; });
|
|
9422
|
+
m.set('rg', (ops) => this.opRg(ops, true));
|
|
9423
|
+
m.set('RG', (ops) => this.opRg(ops, false));
|
|
9424
|
+
m.set('k', (ops) => this.opK(ops, true));
|
|
9425
|
+
m.set('K', (ops) => this.opK(ops, false));
|
|
9426
|
+
m.set('cs', (ops) => this.opCs(ops));
|
|
9427
|
+
m.set('CS', (ops) => this.opCs(ops));
|
|
9428
|
+
m.set('sc', (ops, res) => this.opSc(ops, true, res));
|
|
9429
|
+
m.set('SC', (ops, res) => this.opSc(ops, false, res));
|
|
9430
|
+
m.set('scn', (ops, res) => this.opSc(ops, true, res));
|
|
9431
|
+
m.set('SCN', (ops, res) => this.opSc(ops, false, res));
|
|
9432
|
+
m.set('Do', (ops, res, pw, ph) => this.opDo(ops, res, pw, ph));
|
|
9433
|
+
m.set('gs', (ops, res) => this.opGs(ops, res));
|
|
9486
9434
|
for (const name of ['BMC', 'BDC', 'EMC', 'MP', 'DP', 'BI'])
|
|
9487
9435
|
m.set(name, noop);
|
|
9488
9436
|
}
|
|
9489
9437
|
registerTextOps(m, noop) {
|
|
9490
|
-
m.set('Tf', (
|
|
9491
|
-
m.set('Tc', (
|
|
9492
|
-
m.set('Tw', (
|
|
9493
|
-
m.set('Tz', (
|
|
9494
|
-
m.set('TL', (
|
|
9495
|
-
m.set('Tr', (
|
|
9496
|
-
m.set('Ts', (
|
|
9438
|
+
m.set('Tf', (ops) => this.opTf(ops));
|
|
9439
|
+
m.set('Tc', (ops) => { this.charSpace = Number.parseFloat(ops[0] ?? '0'); this.letterSpaceChanged = true; });
|
|
9440
|
+
m.set('Tw', (ops) => { this.wordSpace = Number.parseFloat(ops[0] ?? '0'); this.wordSpaceChanged = true; });
|
|
9441
|
+
m.set('Tz', (ops) => { this.horizScaling = Number.parseFloat(ops[0] ?? '100') / 100; this.horizScaleChanged = true; });
|
|
9442
|
+
m.set('TL', (ops) => { this.leading = Number.parseFloat(ops[0] ?? '0'); });
|
|
9443
|
+
m.set('Tr', (ops) => { this.renderMode = Number.parseInt(ops[0] ?? '0', 10); this.fillColorChanged = true; this.strokeColorChanged = true; });
|
|
9444
|
+
m.set('Ts', (ops) => { this.rise = Number.parseFloat(ops[0] ?? '0'); this.riseChanged = true; });
|
|
9497
9445
|
m.set('BT', () => this.opBT());
|
|
9498
9446
|
m.set('ET', noop);
|
|
9499
|
-
m.set('Td', (
|
|
9500
|
-
m.set('TD', (
|
|
9501
|
-
m.set('Tm', (
|
|
9447
|
+
m.set('Td', (ops) => this.opTd(ops));
|
|
9448
|
+
m.set('TD', (ops) => this.opTD(ops));
|
|
9449
|
+
m.set('Tm', (ops) => this.opTm(ops));
|
|
9502
9450
|
m.set('T*', () => this.opTStar());
|
|
9503
|
-
m.set('Tj', (
|
|
9504
|
-
m.set('TJ', (
|
|
9505
|
-
m.set('\'', (
|
|
9506
|
-
m.set('"', (
|
|
9451
|
+
m.set('Tj', (ops) => this.opTj(ops));
|
|
9452
|
+
m.set('TJ', (ops) => this.opTJ(ops));
|
|
9453
|
+
m.set('\'', (ops) => { this.opTStar(); this.opTj(ops); });
|
|
9454
|
+
m.set('"', (ops) => this.opQuoteDbl(ops));
|
|
9507
9455
|
}
|
|
9508
9456
|
registerPathOps(m, noop) {
|
|
9509
|
-
m.set('re', (
|
|
9510
|
-
m.set('m', (
|
|
9511
|
-
m.set('l', (
|
|
9512
|
-
m.set('c', (
|
|
9513
|
-
m.set('v', (
|
|
9514
|
-
m.set('y', (
|
|
9457
|
+
m.set('re', (ops) => this.opRe(ops));
|
|
9458
|
+
m.set('m', (ops) => this.opPathMove(ops));
|
|
9459
|
+
m.set('l', (ops) => this.opPathLine(ops));
|
|
9460
|
+
m.set('c', (ops) => this.opPathCurve(ops));
|
|
9461
|
+
m.set('v', (ops) => this.opPathCurve2Points(ops));
|
|
9462
|
+
m.set('y', (ops) => this.opPathCurve2Points(ops));
|
|
9515
9463
|
m.set('h', noop);
|
|
9516
9464
|
m.set('S', () => this.paintPath(true, false));
|
|
9517
9465
|
m.set('s', () => this.paintPath(true, false));
|
|
@@ -9538,7 +9486,7 @@ class PixelPerfectProcessor {
|
|
|
9538
9486
|
executeOperator(op, operands, resources, pageWidth, pageHeight) {
|
|
9539
9487
|
const handler = this.getOperatorMap().get(op);
|
|
9540
9488
|
if (handler)
|
|
9541
|
-
handler(
|
|
9489
|
+
handler(operands, resources, pageWidth, pageHeight);
|
|
9542
9490
|
}
|
|
9543
9491
|
// ── Operator implementations ─────────────────────────────────────
|
|
9544
9492
|
saveState() {
|
|
@@ -9617,7 +9565,7 @@ class PixelPerfectProcessor {
|
|
|
9617
9565
|
this.strokeColorChanged = true;
|
|
9618
9566
|
}
|
|
9619
9567
|
}
|
|
9620
|
-
opCs(operands
|
|
9568
|
+
opCs(operands) {
|
|
9621
9569
|
const name = operands[0]?.startsWith('/') ? operands[0].substring(1) : operands[0] ?? '';
|
|
9622
9570
|
this.fillColorSpaceIsPattern = name === 'Pattern';
|
|
9623
9571
|
if (!this.fillColorSpaceIsPattern)
|
|
@@ -10068,7 +10016,7 @@ class PixelPerfectProcessor {
|
|
|
10068
10016
|
return new Uint8Array(0);
|
|
10069
10017
|
}
|
|
10070
10018
|
}
|
|
10071
|
-
extractAnnotations(pageDict
|
|
10019
|
+
extractAnnotations(pageDict) {
|
|
10072
10020
|
const annotsRef = pageDict['Annots'];
|
|
10073
10021
|
if (!annotsRef)
|
|
10074
10022
|
return [];
|
|
@@ -10173,7 +10121,9 @@ function renderImage(img, z) {
|
|
|
10173
10121
|
`width:${w}px;height:${h}px;" src="${escapeHtml$1(img.dataUrl)}"/>`;
|
|
10174
10122
|
}
|
|
10175
10123
|
function renderAnnotation(ann, z) {
|
|
10176
|
-
|
|
10124
|
+
// The shared helper also lets a same-page `#fragment` through; a PDF link annotation never did here
|
|
10125
|
+
// (it would scroll or navigate the host page), so a fragment is dropped before the shared check.
|
|
10126
|
+
const href = ann.uri.startsWith('#') ? undefined : safeLinkHref(ann.uri);
|
|
10177
10127
|
if (!href)
|
|
10178
10128
|
return '';
|
|
10179
10129
|
const left = round$1(ann.x * z);
|
|
@@ -10225,7 +10175,7 @@ function fixYFlippedCoordinates(result) {
|
|
|
10225
10175
|
img.y = Math.abs(img.y) * initialYScale;
|
|
10226
10176
|
}
|
|
10227
10177
|
}
|
|
10228
|
-
function buildPageContentHtml(result, pageIndex, mgr,
|
|
10178
|
+
function buildPageContentHtml(result, pageIndex, mgr, z, scaledWidth, scaledHeight) {
|
|
10229
10179
|
const htmlParts = [];
|
|
10230
10180
|
htmlParts.push(`<div id="pf${pageIndex + 1}" class="pf" style="width:${round$1(scaledWidth)}px;height:${round$1(scaledHeight)}px;" data-page-no="${pageIndex + 1}">`, `<div class="pc pc${pageIndex + 1}">`);
|
|
10231
10181
|
for (const rect of result.pathRects) {
|
|
@@ -10237,7 +10187,7 @@ function buildPageContentHtml(result, pageIndex, mgr, fontRegistry, z, scaledWid
|
|
|
10237
10187
|
for (const img of result.imageItems)
|
|
10238
10188
|
htmlParts.push(renderImage(img, z));
|
|
10239
10189
|
for (const line of result.lines) {
|
|
10240
|
-
const lineHtml = line.dumpText(mgr,
|
|
10190
|
+
const lineHtml = line.dumpText(mgr, H_EPS, SPACE_THRESHOLD, z);
|
|
10241
10191
|
if (lineHtml)
|
|
10242
10192
|
htmlParts.push(lineHtml);
|
|
10243
10193
|
}
|
|
@@ -10255,10 +10205,10 @@ function assemblePageHtml(result, pageIndex, mgr, fontRegistry, z) {
|
|
|
10255
10205
|
const text = extractTextFromLines(result.lines, z);
|
|
10256
10206
|
for (const line of result.lines) {
|
|
10257
10207
|
line.prepare(mgr, fontRegistry, z);
|
|
10258
|
-
line.optimizeNormal(mgr,
|
|
10208
|
+
line.optimizeNormal(mgr, SPACE_THRESHOLD, z);
|
|
10259
10209
|
}
|
|
10260
10210
|
return {
|
|
10261
|
-
html: buildPageContentHtml(result, pageIndex, mgr,
|
|
10211
|
+
html: buildPageContentHtml(result, pageIndex, mgr, z, scaledWidth, scaledHeight),
|
|
10262
10212
|
text,
|
|
10263
10213
|
pageIndex,
|
|
10264
10214
|
pageWidth: scaledWidth,
|
|
@@ -10298,7 +10248,7 @@ async function renderPixelPerfectPaged(buffer, options, limits = DEFAULT_PARSER_
|
|
|
10298
10248
|
const processor = new PixelPerfectProcessor(reader, fontRegistry, zoom);
|
|
10299
10249
|
for (let i = 0; i < pdfPages.length; i++) {
|
|
10300
10250
|
try {
|
|
10301
|
-
const result = processor.processPage(pdfPages[i]
|
|
10251
|
+
const result = processor.processPage(pdfPages[i]);
|
|
10302
10252
|
const page = assemblePageHtml(result, i, mgr, fontRegistry, zoom);
|
|
10303
10253
|
pages.push(page);
|
|
10304
10254
|
}
|
|
@@ -11216,7 +11166,7 @@ const SEPARATOR_THICKNESS = 3;
|
|
|
11216
11166
|
const ROW_TOLERANCE_EM = 0.35;
|
|
11217
11167
|
function findTableInBand(band, rects, pageIndex, ctx, modes = {}) {
|
|
11218
11168
|
const rows = groupByBaseline$1(band);
|
|
11219
|
-
const ruled = (modes.ruled ?? true) ? findRuledTable(band,
|
|
11169
|
+
const ruled = (modes.ruled ?? true) ? findRuledTable(band, rects, pageIndex) : null;
|
|
11220
11170
|
if (ruled)
|
|
11221
11171
|
return applyTableSpan(ruled, ctx);
|
|
11222
11172
|
const unruled = modes.unruled ?? true;
|
|
@@ -11284,7 +11234,7 @@ function groupByBaseline$1(band) {
|
|
|
11284
11234
|
}
|
|
11285
11235
|
return rows;
|
|
11286
11236
|
}
|
|
11287
|
-
function findRuledTable(band,
|
|
11237
|
+
function findRuledTable(band, rects, pageIndex) {
|
|
11288
11238
|
const separators = bandScopedRects(band, rects).filter(isSeparatorRect);
|
|
11289
11239
|
const components = connectedComponents(separators)
|
|
11290
11240
|
.sort((a, b) => componentTop(b) - componentTop(a));
|
|
@@ -11356,7 +11306,7 @@ const COMPONENT_GAP = 4;
|
|
|
11356
11306
|
* tables and must not share a grid.
|
|
11357
11307
|
*/
|
|
11358
11308
|
function connectedComponents(rects) {
|
|
11359
|
-
const parent = rects.map((
|
|
11309
|
+
const parent = rects.map((...[, i]) => i);
|
|
11360
11310
|
const find = (i) => {
|
|
11361
11311
|
let root = i;
|
|
11362
11312
|
while (parent[root] !== root)
|
|
@@ -13084,7 +13034,7 @@ function columnZoneRatios(columns) {
|
|
|
13084
13034
|
const overallX0 = Math.min(...spans.map(s => s.x0));
|
|
13085
13035
|
const overallX1 = Math.max(...spans.map(s => s.x1));
|
|
13086
13036
|
const totalWidth = Math.max(1, overallX1 - overallX0);
|
|
13087
|
-
const order = spans.map((
|
|
13037
|
+
const order = spans.map((...[, i]) => i).sort((a, b) => spans[a].x0 - spans[b].x0);
|
|
13088
13038
|
const ratios = new Array(columns.length).fill(0);
|
|
13089
13039
|
for (let k = 0; k < order.length; k++) {
|
|
13090
13040
|
const i = order[k];
|
|
@@ -15326,4 +15276,4 @@ function emitImageOnly(extracted, opts) {
|
|
|
15326
15276
|
}
|
|
15327
15277
|
|
|
15328
15278
|
export { parsePdfReadable };
|
|
15329
|
-
//# sourceMappingURL=gilav21-shadcn-angular-rte-pdf-readable-
|
|
15279
|
+
//# sourceMappingURL=gilav21-shadcn-angular-rte-pdf-readable-BKYRkHec.mjs.map
|