reamkit 1.32.1 → 1.33.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 +5 -4
- package/dist/esm/core/bidi/algorithm.js +2 -2
- package/dist/esm/core/bidi/char-types.js +1 -1
- package/dist/esm/core/bidi/index.js +3 -3
- package/dist/esm/core/bytes.js +1 -1
- package/dist/esm/core/converter/facade.js +3 -2
- package/dist/esm/core/converter/ream.js +12 -5
- package/dist/esm/core/crypto/asn1.js +2 -2
- package/dist/esm/core/crypto/cms.js +5 -3
- package/dist/esm/core/crypto/index.js +2 -1
- package/dist/esm/core/crypto/offcrypto.js +8 -7
- package/dist/esm/core/crypto/primitives.js +16 -16
- package/dist/esm/core/document-model/index.d.ts +1 -1
- package/dist/esm/core/document-model/types.d.ts +174 -2
- package/dist/esm/core/drawingml/chart-geometry.d.ts +24 -6
- package/dist/esm/core/drawingml/chart-geometry.js +905 -208
- package/dist/esm/core/drawingml/chart-parser.d.ts +5 -1
- package/dist/esm/core/drawingml/chart-parser.js +275 -19
- package/dist/esm/core/drawingml/chart-text.d.ts +41 -0
- package/dist/esm/core/drawingml/chart-text.js +93 -0
- package/dist/esm/core/drawingml/colors.js +5 -5
- package/dist/esm/core/drawingml/diagram/layout-engine.js +1 -4
- package/dist/esm/core/drawingml/diagram/run.js +2 -1
- package/dist/esm/core/drawingml/preset-geometry.js +4 -6
- package/dist/esm/core/drawingml/shape-render.js +1 -1
- package/dist/esm/core/drawingml/text-warp.js +4 -16
- package/dist/esm/core/drawingml/theme-parser.js +14 -8
- package/dist/esm/core/font/arabic-joining.js +2 -2
- package/dist/esm/core/font/binary-reader.js +2 -0
- package/dist/esm/core/font/font-registry.js +1 -0
- package/dist/esm/core/font/ligatures.js +1 -1
- package/dist/esm/core/font/opentype-layout.js +11 -5
- package/dist/esm/core/font/ttf-build.js +6 -10
- package/dist/esm/core/font/ttf-parser.js +2 -1
- package/dist/esm/core/font/ttf-subset.js +8 -8
- package/dist/esm/core/fonts/families.js +1 -1
- package/dist/esm/core/fonts/remote-fonts.js +4 -4
- package/dist/esm/core/hyphenation/index.js +1 -1
- package/dist/esm/core/images.js +8 -8
- package/dist/esm/core/ir/loss.js +1 -0
- package/dist/esm/core/line-breaker/cjk.js +1 -1
- package/dist/esm/core/line-breaker/index.js +4 -3
- package/dist/esm/core/links.js +1 -1
- package/dist/esm/core/lzw.js +1 -1
- package/dist/esm/core/metafile/blit.js +1 -1
- package/dist/esm/core/metafile/emf.js +5 -7
- package/dist/esm/core/metafile/picture.js +1 -1
- package/dist/esm/core/metafile/symbol-fonts.js +7 -7
- package/dist/esm/core/metafile/wmf.js +5 -7
- package/dist/esm/core/number-format.js +4 -6
- package/dist/esm/core/numbering/index.js +3 -2
- package/dist/esm/core/ole/cfb.js +4 -4
- package/dist/esm/core/ole/escher-blip.js +1 -1
- package/dist/esm/core/opc/index.js +5 -4
- package/dist/esm/core/opc/package.js +3 -1
- package/dist/esm/core/opc/xml-entities.js +1 -1
- package/dist/esm/core/outline.js +1 -1
- package/dist/esm/core/png-encode.js +3 -3
- package/dist/esm/core/po-helpers.js +1 -1
- package/dist/esm/core/spreadsheet-model/types.d.ts +6 -0
- package/dist/esm/core/style-cascade/index.js +4 -3
- package/dist/esm/core/tiff.js +3 -1
- package/dist/esm/excel/activex-parser.js +1 -1
- package/dist/esm/excel/conditional-format.js +7 -7
- package/dist/esm/excel/formula/functions.js +8 -4
- package/dist/esm/excel/formula/index.js +3 -3
- package/dist/esm/excel/formula/lexer.js +2 -2
- package/dist/esm/excel/formula/parser.js +4 -3
- package/dist/esm/excel/formula/value.js +1 -1
- package/dist/esm/excel/index.js +7 -6
- package/dist/esm/excel/print-model.js +4 -4
- package/dist/esm/excel/printer-settings.js +6 -7
- package/dist/esm/excel/rich-value.js +1 -1
- package/dist/esm/excel/sheet-shape-parser.js +4 -2
- package/dist/esm/excel/sheet-to-flow.js +13 -11
- package/dist/esm/excel/styles-parser.js +5 -3
- package/dist/esm/excel/tint.js +5 -5
- package/dist/esm/excel/vml-drawing.js +2 -2
- package/dist/esm/excel/worksheet-parser.js +5 -5
- package/dist/esm/excel/xls/biff-chart.js +1 -3
- package/dist/esm/excel/xls/biff-reader.js +10 -11
- package/dist/esm/excel/xls/xls-reader.js +1 -1
- package/dist/esm/excel/xlsx-reader.js +17 -4
- package/dist/esm/excel/xlsx-to-pdf.js +1 -1
- package/dist/esm/excel/xlsx-writer.js +2 -2
- package/dist/esm/html/html-writer.js +18 -10
- package/dist/esm/layout/line-paint.js +1 -1
- package/dist/esm/layout/math-layout.js +5 -8
- package/dist/esm/layout/styled-layout.js +103 -31
- package/dist/esm/layout/turned-section.js +2 -2
- package/dist/esm/markdown/markdown-writer.js +1 -1
- package/dist/esm/pdf/encryption.js +9 -9
- package/dist/esm/pdf/icc-profile.js +2 -2
- package/dist/esm/pdf/index.js +3 -2
- package/dist/esm/pdf/objects.js +7 -0
- package/dist/esm/pdf/serialize.js +1 -1
- package/dist/esm/pdf/struct-tree.js +3 -1
- package/dist/esm/pdf/styled-page-emitter.js +23 -15
- package/dist/esm/pdf/styled-page-renderer.js +9 -5
- package/dist/esm/pdf-reader/annot-draw.js +3 -3
- package/dist/esm/pdf-reader/ccitt.js +2 -1
- package/dist/esm/pdf-reader/cff-outline.js +1 -4
- package/dist/esm/pdf-reader/content.js +13 -15
- package/dist/esm/pdf-reader/decrypt.js +5 -4
- package/dist/esm/pdf-reader/document.js +6 -2
- package/dist/esm/pdf-reader/encodings.js +1 -1
- package/dist/esm/pdf-reader/flow-build.js +4 -6
- package/dist/esm/pdf-reader/font.js +3 -3
- package/dist/esm/pdf-reader/function.js +8 -7
- package/dist/esm/pdf-reader/icc.js +1 -1
- package/dist/esm/pdf-reader/images.js +1 -1
- package/dist/esm/pdf-reader/jbig2.js +36 -38
- package/dist/esm/pdf-reader/jpeg.js +14 -13
- package/dist/esm/pdf-reader/layout.js +12 -9
- package/dist/esm/pdf-reader/lexer.js +2 -1
- package/dist/esm/pdf-reader/math-rows.js +2 -2
- package/dist/esm/pdf-reader/optional-content.js +1 -1
- package/dist/esm/pdf-reader/page-numbers.js +1 -1
- package/dist/esm/pdf-reader/pattern-tint.js +1 -2
- package/dist/esm/pdf-reader/reader.js +2 -2
- package/dist/esm/pdf-reader/struct-tree.js +1 -1
- package/dist/esm/pdf-reader/tagged.js +3 -2
- package/dist/esm/pdf-reader/text.js +2 -2
- package/dist/esm/pdf-reader/type1-outline.js +1 -3
- package/dist/esm/pptx/embedded-fonts.js +3 -5
- package/dist/esm/pptx/placeholder-cascade.js +1 -1
- package/dist/esm/pptx/ppt/ppt-reader.js +5 -4
- package/dist/esm/pptx/ppt/ppt-text.js +9 -10
- package/dist/esm/pptx/pptx-reader.js +6 -5
- package/dist/esm/pptx/preset-table-styles.js +1 -1
- package/dist/esm/pptx/slide-parser.js +6 -4
- package/dist/esm/pptx/sp-helpers.js +1 -1
- package/dist/esm/pptx/table-style.js +2 -1
- package/dist/esm/svg/svg-writer.js +1 -1
- package/dist/esm/word/doc/doc-reader.js +2 -2
- package/dist/esm/word/doc/doc-text.js +20 -22
- package/dist/esm/word/document-parser.js +26 -21
- package/dist/esm/word/docx-reader.js +2 -2
- package/dist/esm/word/docx-to-pdf.js +3 -3
- package/dist/esm/word/docx-writer.js +10 -6
- package/dist/esm/word/drawing-parser.js +18 -18
- package/dist/esm/word/font-table.js +1 -1
- package/dist/esm/word/index.js +6 -5
- package/dist/esm/word/numbering-parser.js +4 -3
- package/dist/esm/word/omml-parser.js +1 -1
- package/dist/esm/word/paragraph-properties.js +11 -10
- package/dist/esm/word/run-properties.js +4 -4
- package/dist/esm/word/settings-parser.js +2 -1
- package/dist/esm/word/shading.js +1 -1
- package/dist/esm/word/styles-parser.js +5 -4
- package/dist/esm/word/table-parser.js +4 -4
- package/dist/esm/word/theme-fonts.js +1 -1
- package/package.json +8 -2
|
@@ -53,7 +53,7 @@ function buildText(text) {
|
|
|
53
53
|
return buf;
|
|
54
54
|
}
|
|
55
55
|
function buildXYZ(x, y, z) {
|
|
56
|
-
const buf = new Uint8Array(20);
|
|
56
|
+
const buf = /* @__PURE__ */ new Uint8Array(20);
|
|
57
57
|
const view = new DataView(buf.buffer);
|
|
58
58
|
writeU32BE(view, 0, tag("XYZ "));
|
|
59
59
|
writeU32BE(view, 4, 0);
|
|
@@ -159,7 +159,7 @@ function buildSrgbIccProfile() {
|
|
|
159
159
|
view.setInt32(72, s15Fixed16(D50.y), false);
|
|
160
160
|
view.setInt32(76, s15Fixed16(D50.z), false);
|
|
161
161
|
writeU32BE(view, headerSize, tagCount);
|
|
162
|
-
let p =
|
|
162
|
+
let p = 132;
|
|
163
163
|
for (const e of entries) {
|
|
164
164
|
const off = blockOffsets.get(e.data);
|
|
165
165
|
writeU32BE(view, p, tag(e.sig));
|
package/dist/esm/pdf/index.js
CHANGED
|
@@ -2,5 +2,6 @@ import "./cid-font.js";
|
|
|
2
2
|
import "./text-page-renderer.js";
|
|
3
3
|
import "../core/images.js";
|
|
4
4
|
import "./image-xobject.js";
|
|
5
|
-
import "./signature.js";
|
|
6
|
-
import "./styled-page-renderer.js";
|
|
5
|
+
import { signPdf } from "./signature.js";
|
|
6
|
+
import { renderStyledPdf, renderStyledPdfEncrypted } from "./styled-page-renderer.js";
|
|
7
|
+
export { renderStyledPdf, renderStyledPdfEncrypted, signPdf };
|
package/dist/esm/pdf/objects.js
CHANGED
|
@@ -4,6 +4,7 @@ import { zlibSync } from "fflate";
|
|
|
4
4
|
var PDF_NULL = Symbol("PDF_NULL");
|
|
5
5
|
/** A PDF name object (§7.3.5), e.g. `/Type` — the leading slash is added on serialization. */
|
|
6
6
|
var PdfName = class {
|
|
7
|
+
value;
|
|
7
8
|
/** @param value The name's text, without the leading `/`. */
|
|
8
9
|
constructor(value) {
|
|
9
10
|
this.value = value;
|
|
@@ -11,6 +12,8 @@ var PdfName = class {
|
|
|
11
12
|
};
|
|
12
13
|
/** An indirect reference (§7.3.10), written `id gen R`. */
|
|
13
14
|
var PdfRef = class {
|
|
15
|
+
id;
|
|
16
|
+
generation;
|
|
14
17
|
/**
|
|
15
18
|
* @param id The referenced object number.
|
|
16
19
|
* @param generation The generation number (0 for freshly written objects).
|
|
@@ -22,6 +25,8 @@ var PdfRef = class {
|
|
|
22
25
|
};
|
|
23
26
|
/** A PDF stream object (§7.3.8): a dictionary plus its raw byte payload. */
|
|
24
27
|
var PdfStream = class {
|
|
28
|
+
dict;
|
|
29
|
+
data;
|
|
25
30
|
/**
|
|
26
31
|
* @param dict The stream dictionary (`/Length` is filled in on serialization).
|
|
27
32
|
* @param data The raw stream bytes.
|
|
@@ -37,6 +42,7 @@ var PdfStream = class {
|
|
|
37
42
|
* UTF-16BE with a leading BOM, the PDF-standard form for Unicode strings.
|
|
38
43
|
*/
|
|
39
44
|
var PdfHexString = class {
|
|
45
|
+
bytes;
|
|
40
46
|
/** @param bytes The raw bytes to emit as hex. */
|
|
41
47
|
constructor(bytes) {
|
|
42
48
|
this.bytes = bytes;
|
|
@@ -48,6 +54,7 @@ var PdfHexString = class {
|
|
|
48
54
|
* place after the byte offsets are known (ISO 32000 §12.8.1).
|
|
49
55
|
*/
|
|
50
56
|
var PdfRawToken = class {
|
|
57
|
+
token;
|
|
51
58
|
/** @param token The literal text to emit unchanged. */
|
|
52
59
|
constructor(token) {
|
|
53
60
|
this.token = token;
|
|
@@ -2,6 +2,8 @@ import { PDF_NULL, dict, name, unicodeString } from "./objects.js";
|
|
|
2
2
|
//#region src/pdf/struct-tree.ts
|
|
3
3
|
/** One node in the logical structure tree: a {@link StructType} plus its children, marked-content and attributes. */
|
|
4
4
|
var StructNode = class {
|
|
5
|
+
id;
|
|
6
|
+
type;
|
|
5
7
|
children = [];
|
|
6
8
|
mcrefs = [];
|
|
7
9
|
/**
|
|
@@ -182,4 +184,4 @@ var StructTreeBuilder = class {
|
|
|
182
184
|
}
|
|
183
185
|
};
|
|
184
186
|
//#endregion
|
|
185
|
-
export { StructTreeBuilder };
|
|
187
|
+
export { StructNode, StructTreeBuilder };
|
|
@@ -348,7 +348,7 @@ function assembleStyledPdf(laid, options, doc) {
|
|
|
348
348
|
});
|
|
349
349
|
if (pageRefs.length === 0) {
|
|
350
350
|
const fallback = sectionCtxs[0] ?? defaultPageCtx();
|
|
351
|
-
const contentsRef = doc.add(stream({}, new Uint8Array(0)));
|
|
351
|
+
const contentsRef = doc.add(stream({}, /* @__PURE__ */ new Uint8Array(0)));
|
|
352
352
|
const fallbackDict = dict({
|
|
353
353
|
Type: name("Page"),
|
|
354
354
|
Parent: ref(pagesRef.id),
|
|
@@ -372,17 +372,23 @@ function assembleStyledPdf(laid, options, doc) {
|
|
|
372
372
|
Type: name("Catalog"),
|
|
373
373
|
Pages: ref(pagesRef.id)
|
|
374
374
|
};
|
|
375
|
-
if (pdfaProfile)
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
375
|
+
if (pdfaProfile) {
|
|
376
|
+
const outputIntentRef = doc.add(dict({
|
|
377
|
+
Type: name("OutputIntent"),
|
|
378
|
+
S: name("GTS_PDFA1"),
|
|
379
|
+
OutputConditionIdentifier: "sRGB",
|
|
380
|
+
Info: "sRGB IEC61966-2.1",
|
|
381
|
+
DestOutputProfile: ref(pdfaIccRef.id)
|
|
382
|
+
}));
|
|
383
|
+
catalogEntries["OutputIntents"] = [ref(outputIntentRef.id)];
|
|
384
|
+
}
|
|
385
|
+
if (pdfaProfile || options.pdfUA) {
|
|
386
|
+
const xmpRef = doc.add(stream({
|
|
387
|
+
Type: name("Metadata"),
|
|
388
|
+
Subtype: name("XML")
|
|
389
|
+
}, buildXmpPacket(xmpFromInfo(docInfo, pdfaProfile, options.pdfUA === true))));
|
|
390
|
+
catalogEntries["Metadata"] = ref(xmpRef.id);
|
|
391
|
+
}
|
|
386
392
|
if (tagged && structBuilder) {
|
|
387
393
|
const structRootRef = structBuilder.emit(doc, pageRefs);
|
|
388
394
|
catalogEntries["MarkInfo"] = dict({ Marked: true });
|
|
@@ -399,7 +405,8 @@ function assembleStyledPdf(laid, options, doc) {
|
|
|
399
405
|
const sorted = [...embedded].sort((a, b) => a.file.name < b.file.name ? -1 : a.file.name > b.file.name ? 1 : 0);
|
|
400
406
|
const names = [];
|
|
401
407
|
for (const e of sorted) names.push(e.file.name, ref(e.ref.id));
|
|
402
|
-
|
|
408
|
+
const embeddedFilesRef = doc.add(dict({ Names: names }));
|
|
409
|
+
namesTreeEntries["EmbeddedFiles"] = ref(embeddedFilesRef.id);
|
|
403
410
|
}
|
|
404
411
|
const bookmarkDests = laid.pdf.bookmarks;
|
|
405
412
|
const destNames = [...referencedAnchors].filter((n) => bookmarkDests.has(n)).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
@@ -415,7 +422,8 @@ function assembleStyledPdf(laid, options, doc) {
|
|
|
415
422
|
pos.yTopPt
|
|
416
423
|
]);
|
|
417
424
|
}
|
|
418
|
-
|
|
425
|
+
const destsRef = doc.add(dict({ Names: names }));
|
|
426
|
+
namesTreeEntries["Dests"] = ref(destsRef.id);
|
|
419
427
|
}
|
|
420
428
|
if (Object.keys(namesTreeEntries).length > 0) catalogEntries["Names"] = dict(namesTreeEntries);
|
|
421
429
|
if (options.signaturePlaceholder && firstPageDict) {
|
|
@@ -655,7 +663,7 @@ function emitPageContent(page, tagging, gradientNames, alphaStateNames, duotoneS
|
|
|
655
663
|
const commands = page.commands;
|
|
656
664
|
const links = [];
|
|
657
665
|
if (commands.length === 0) return {
|
|
658
|
-
content: new Uint8Array(0),
|
|
666
|
+
content: /* @__PURE__ */ new Uint8Array(0),
|
|
659
667
|
links
|
|
660
668
|
};
|
|
661
669
|
const H = page.height;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PdfDocument } from "./writer.js";
|
|
2
|
-
import "../layout/page-doc.js";
|
|
3
|
-
import { layoutStyledDocument } from "../layout/styled-layout.js";
|
|
2
|
+
import { pageItemBounds, pageLayers, paintPlan } from "../layout/page-doc.js";
|
|
3
|
+
import { GLUE_SHRINK_RATIO, layoutStyledDocument } from "../layout/styled-layout.js";
|
|
4
4
|
import { emitStyledPdf, emitStyledPdfEncrypted } from "./styled-page-emitter.js";
|
|
5
5
|
//#region src/pdf/styled-page-renderer.ts
|
|
6
6
|
/**
|
|
@@ -12,7 +12,9 @@ import { emitStyledPdf, emitStyledPdfEncrypted } from "./styled-page-emitter.js"
|
|
|
12
12
|
*/
|
|
13
13
|
function renderStyledPdf(body, options) {
|
|
14
14
|
if (options.encrypt) throw new Error("PDF encryption requires the async conversion path (WebCrypto)");
|
|
15
|
-
|
|
15
|
+
const laid = layoutStyledDocument(body, options);
|
|
16
|
+
const doc = new PdfDocument();
|
|
17
|
+
return emitStyledPdf(laid, options, doc);
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* The encrypting variant of {@link renderStyledPdf} (ISO 32000 §7.6; async
|
|
@@ -37,7 +39,9 @@ async function renderStyledPdfEncrypted(body, options) {
|
|
|
37
39
|
contentAccessibility: true
|
|
38
40
|
}
|
|
39
41
|
} : encrypt;
|
|
40
|
-
|
|
42
|
+
const laid = layoutStyledDocument(body, options);
|
|
43
|
+
const doc = new PdfDocument();
|
|
44
|
+
return emitStyledPdfEncrypted(laid, options, doc, effective);
|
|
41
45
|
}
|
|
42
46
|
//#endregion
|
|
43
|
-
export { renderStyledPdf, renderStyledPdfEncrypted };
|
|
47
|
+
export { GLUE_SHRINK_RATIO, layoutStyledDocument, pageItemBounds, pageLayers, paintPlan, renderStyledPdf, renderStyledPdfEncrypted };
|
|
@@ -167,7 +167,7 @@ function drawnResources(file, annot) {
|
|
|
167
167
|
const subtype = file.get(annot, "Subtype");
|
|
168
168
|
if (subtype instanceof PdfName && subtype.value === "FreeText") {
|
|
169
169
|
const text = freeTextContents(file, annot);
|
|
170
|
-
return text === void 0 ? void 0 : new Map([["Font", new Map([[FREE_TEXT_FONT, spelledFace(text)]])]]);
|
|
170
|
+
return text === void 0 ? void 0 : /* @__PURE__ */ new Map([["Font", /* @__PURE__ */ new Map([[FREE_TEXT_FONT, spelledFace(text)]])]]);
|
|
171
171
|
}
|
|
172
172
|
if (!(subtype instanceof PdfName) || subtype.value !== "Widget") return void 0;
|
|
173
173
|
const acro = file.get(file.catalog, "AcroForm");
|
|
@@ -296,11 +296,11 @@ function spelledFace(text) {
|
|
|
296
296
|
const cp = ch.codePointAt(0) ?? 32;
|
|
297
297
|
differences.push(new PdfName(`uni${cp.toString(16).toUpperCase().padStart(4, "0")}`));
|
|
298
298
|
}
|
|
299
|
-
return new Map([
|
|
299
|
+
return /* @__PURE__ */ new Map([
|
|
300
300
|
["Type", new PdfName("Font")],
|
|
301
301
|
["Subtype", new PdfName("Type1")],
|
|
302
302
|
["BaseFont", new PdfName("Helvetica")],
|
|
303
|
-
["Encoding", new Map([["Differences", differences]])]
|
|
303
|
+
["Encoding", /* @__PURE__ */ new Map([["Differences", differences]])]
|
|
304
304
|
]);
|
|
305
305
|
}
|
|
306
306
|
/** §12.7.4.3 — the field is a multi-line text box (bit 13 of `/Ff`). */
|
|
@@ -164,6 +164,7 @@ function readCode(reader, table) {
|
|
|
164
164
|
return -1;
|
|
165
165
|
}
|
|
166
166
|
var BitReader = class {
|
|
167
|
+
data;
|
|
167
168
|
bytePos = 0;
|
|
168
169
|
bitPos = 0;
|
|
169
170
|
constructor(data) {
|
|
@@ -502,4 +503,4 @@ var WHITE = buildRunTable(WHITE_CODES, SHARED_MAKEUP);
|
|
|
502
503
|
var BLACK = buildRunTable(BLACK_CODES, SHARED_MAKEUP);
|
|
503
504
|
var MODES = new Map(MODE_CODES.map(([bits, m]) => [bits.length << 8 | parseInt(bits, 2), m]));
|
|
504
505
|
//#endregion
|
|
505
|
-
export { decodeCcitt, decodeCcittPlanes };
|
|
506
|
+
export { BLACK_CODES, MODE_CODES, SHARED_MAKEUP, WHITE_CODES, decodeCcitt, decodeCcittPlanes };
|
|
@@ -1022,9 +1022,7 @@ function runGlyph(font, gid, part = false) {
|
|
|
1022
1022
|
stack.length = 0;
|
|
1023
1023
|
break;
|
|
1024
1024
|
}
|
|
1025
|
-
default:
|
|
1026
|
-
stack.length = 0;
|
|
1027
|
-
break;
|
|
1025
|
+
default: stack.length = 0;
|
|
1028
1026
|
}
|
|
1029
1027
|
}
|
|
1030
1028
|
return true;
|
|
@@ -1118,7 +1116,6 @@ function runEscape(op, stack, trans) {
|
|
|
1118
1116
|
stack.push(b, a);
|
|
1119
1117
|
break;
|
|
1120
1118
|
}
|
|
1121
|
-
default: break;
|
|
1122
1119
|
}
|
|
1123
1120
|
}
|
|
1124
1121
|
/**
|
|
@@ -416,11 +416,17 @@ function interpretContent(bytes, fonts, initialCtm = IDENTITY, shadings = /* @__
|
|
|
416
416
|
});
|
|
417
417
|
};
|
|
418
418
|
const showString = (operand) => {
|
|
419
|
-
|
|
419
|
+
const origin = multiply(tm, state.ctm);
|
|
420
|
+
const text = consume(operand);
|
|
421
|
+
emitAt(origin, text, multiply(tm, state.ctm));
|
|
420
422
|
};
|
|
421
423
|
const showArray = (arr) => {
|
|
422
424
|
for (const el of arr) if (typeof el === "number") tm = multiply(translation(-el / 1e3 * state.fontSize * state.hScale, 0), tm);
|
|
423
|
-
else if (typeof el === "string" || el instanceof PdfHexString)
|
|
425
|
+
else if (typeof el === "string" || el instanceof PdfHexString) {
|
|
426
|
+
const origin = multiply(tm, state.ctm);
|
|
427
|
+
const text = consume(el);
|
|
428
|
+
emitAt(origin, text, multiply(tm, state.ctm));
|
|
429
|
+
}
|
|
424
430
|
};
|
|
425
431
|
const exec = (op) => {
|
|
426
432
|
switch (op) {
|
|
@@ -696,10 +702,7 @@ function interpretContent(bytes, fonts, initialCtm = IDENTITY, shadings = /* @__
|
|
|
696
702
|
break;
|
|
697
703
|
}
|
|
698
704
|
case "W":
|
|
699
|
-
case "W*":
|
|
700
|
-
pendingClip = true;
|
|
701
|
-
break;
|
|
702
|
-
default: break;
|
|
705
|
+
case "W*": pendingClip = true;
|
|
703
706
|
}
|
|
704
707
|
};
|
|
705
708
|
for (;;) {
|
|
@@ -741,9 +744,7 @@ function interpretContent(bytes, fonts, initialCtm = IDENTITY, shadings = /* @__
|
|
|
741
744
|
} else exec(tok.value);
|
|
742
745
|
operands = [];
|
|
743
746
|
break;
|
|
744
|
-
default:
|
|
745
|
-
operands = [];
|
|
746
|
-
break;
|
|
747
|
+
default: operands = [];
|
|
747
748
|
}
|
|
748
749
|
}
|
|
749
750
|
return {
|
|
@@ -863,7 +864,7 @@ function toBytes(operand) {
|
|
|
863
864
|
for (let i = 0; i < operand.length; i++) out[i] = operand.charCodeAt(i) & 255;
|
|
864
865
|
return out;
|
|
865
866
|
}
|
|
866
|
-
return new Uint8Array(0);
|
|
867
|
+
return /* @__PURE__ */ new Uint8Array(0);
|
|
867
868
|
}
|
|
868
869
|
function splitCodes(bytes, bytesPerCode) {
|
|
869
870
|
const out = [];
|
|
@@ -897,10 +898,7 @@ function readArray(lexer) {
|
|
|
897
898
|
case "dictOpen":
|
|
898
899
|
out.push(readDict(lexer));
|
|
899
900
|
break;
|
|
900
|
-
case "keyword":
|
|
901
|
-
if (tok.value === "true" || tok.value === "false") out.push(tok.value === "true");
|
|
902
|
-
break;
|
|
903
|
-
default: break;
|
|
901
|
+
case "keyword": if (tok.value === "true" || tok.value === "false") out.push(tok.value === "true");
|
|
904
902
|
}
|
|
905
903
|
}
|
|
906
904
|
return out;
|
|
@@ -1048,4 +1046,4 @@ function inlineLength(dict) {
|
|
|
1048
1046
|
return ((w * comps * bpc + 7) / 8 | 0) * h;
|
|
1049
1047
|
}
|
|
1050
1048
|
//#endregion
|
|
1051
|
-
export { IDENTITY, interpretContent, isRightToLeft, multiply };
|
|
1049
|
+
export { IDENTITY, interpretContent, isRightToLeft, multiply, statesACharacter };
|
|
@@ -41,8 +41,8 @@ var AES_SALT = Uint8Array.from([
|
|
|
41
41
|
108,
|
|
42
42
|
84
|
|
43
43
|
]);
|
|
44
|
-
var ZERO16 = new Uint8Array(16);
|
|
45
|
-
var EMPTY = new Uint8Array(0);
|
|
44
|
+
var ZERO16 = /* @__PURE__ */ new Uint8Array(16);
|
|
45
|
+
var EMPTY = /* @__PURE__ */ new Uint8Array(0);
|
|
46
46
|
/**
|
|
47
47
|
* Build a {@link Decryptor} from the `/Encrypt` dictionary and the file `/ID`
|
|
48
48
|
* (ISO 32000 §7.6.3 / ISO 32000-2 §7.6.4). Derives the file key for the
|
|
@@ -94,11 +94,12 @@ function deriveKeyR6(u, ue, password) {
|
|
|
94
94
|
const validationSalt = u.subarray(32, 40);
|
|
95
95
|
const keySalt = u.subarray(40, 48);
|
|
96
96
|
if (!equal(hash2B(pw, validationSalt, EMPTY), u.subarray(0, 32))) return void 0;
|
|
97
|
-
|
|
97
|
+
const intermediate = hash2B(pw, keySalt, EMPTY);
|
|
98
|
+
return aesCbcDecrypt(intermediate, ZERO16, ue.subarray(0, 32), false);
|
|
98
99
|
}
|
|
99
100
|
function padPassword(password) {
|
|
100
101
|
const raw = strToBytes(password);
|
|
101
|
-
const out = new Uint8Array(32);
|
|
102
|
+
const out = /* @__PURE__ */ new Uint8Array(32);
|
|
102
103
|
const n = Math.min(raw.length, 32);
|
|
103
104
|
out.set(raw.subarray(0, n), 0);
|
|
104
105
|
out.set(PAD.subarray(0, 32 - n), n);
|
|
@@ -24,6 +24,10 @@ var MAX_OBJSTM_N = 2e5;
|
|
|
24
24
|
* object scan recovers files whose xref is broken. Construct via {@link PdfFile.parse}.
|
|
25
25
|
*/
|
|
26
26
|
var PdfFile = class PdfFile {
|
|
27
|
+
buf;
|
|
28
|
+
xref;
|
|
29
|
+
trailer;
|
|
30
|
+
filters;
|
|
27
31
|
cache = /* @__PURE__ */ new Map();
|
|
28
32
|
objStmCache = /* @__PURE__ */ new Map();
|
|
29
33
|
decryptor;
|
|
@@ -265,7 +269,7 @@ var GENERAL_FILTERS = {
|
|
|
265
269
|
RunLengthDecode: runLengthDecode,
|
|
266
270
|
RL: runLengthDecode
|
|
267
271
|
};
|
|
268
|
-
var PASSTHROUGH_FILTERS = new Set([
|
|
272
|
+
var PASSTHROUGH_FILTERS = /* @__PURE__ */ new Set([
|
|
269
273
|
"DCTDecode",
|
|
270
274
|
"DCT",
|
|
271
275
|
"JPXDecode",
|
|
@@ -401,7 +405,7 @@ function inflateStream(stream, unknown, filters = {}) {
|
|
|
401
405
|
if (f.value === "FlateDecode" || f.value === "Fl") try {
|
|
402
406
|
data = unzlibSync(data);
|
|
403
407
|
} catch {
|
|
404
|
-
return new Uint8Array(0);
|
|
408
|
+
return /* @__PURE__ */ new Uint8Array(0);
|
|
405
409
|
}
|
|
406
410
|
else if (!PASSTHROUGH_FILTERS.has(f.value)) {
|
|
407
411
|
const decoded = runFilter(filters[f.value], data);
|
|
@@ -538,7 +538,7 @@ function floatOntoSheet(el, sheetWidth) {
|
|
|
538
538
|
}
|
|
539
539
|
};
|
|
540
540
|
};
|
|
541
|
-
const quarter = (rotation60k) => ((rotation60k ?? 0) +
|
|
541
|
+
const quarter = (rotation60k) => ((rotation60k ?? 0) + 54e5) % 216e5;
|
|
542
542
|
if (el.kind === "image" && el.image.float) {
|
|
543
543
|
const float = onto(el.image.float, el.image.width, el.image.height);
|
|
544
544
|
if (!float) return el;
|
|
@@ -605,8 +605,6 @@ var DEEPEST_MARGIN = .5;
|
|
|
605
605
|
* rest of it.
|
|
606
606
|
*/
|
|
607
607
|
var GUESSED_MARGIN = 1 / 3;
|
|
608
|
-
/** The narrowest measure a sheet's own lines may leave, as a share of the sheet. */
|
|
609
|
-
var NARROWEST_MEASURE = .2;
|
|
610
608
|
/**
|
|
611
609
|
* The lines a sheet's runs stand on — baselines further apart than half the
|
|
612
610
|
* size of the type on them — and how many of them END at the sheet's right
|
|
@@ -660,7 +658,7 @@ var ASCENDER = BASELINE_AT * NATURAL_LINE_EM;
|
|
|
660
658
|
* face's descender instead, bug1337429.pdf's last line did not fit the sheet
|
|
661
659
|
* it was drawn on and went to a second one.
|
|
662
660
|
*/
|
|
663
|
-
var DESCENDER =
|
|
661
|
+
var DESCENDER = .29999999999999993;
|
|
664
662
|
/**
|
|
665
663
|
* How small, against the document's own text, type may be set and still be
|
|
666
664
|
* read as text rather than as a mark the producer left on the sheet.
|
|
@@ -780,7 +778,7 @@ function withMeasuredMargins(section, shown, pageRuns, pageMarks = [], foot = []
|
|
|
780
778
|
const floor = inked.length > 0 ? footTop + textSize * FOOT_CLEAR_EM : Infinity;
|
|
781
779
|
const left = clamp(Math.min(...lefts), width);
|
|
782
780
|
const voters = rights.filter((r) => r.full);
|
|
783
|
-
const farthest = voters.length > 0 && voters.every((r) => r.edged) ? Math.max(width * GUESSED_MARGIN, width *
|
|
781
|
+
const farthest = voters.length > 0 && voters.every((r) => r.edged) ? Math.max(width * GUESSED_MARGIN, width * .8 - left) : width * GUESSED_MARGIN;
|
|
784
782
|
return {
|
|
785
783
|
...section,
|
|
786
784
|
margins: {
|
|
@@ -918,4 +916,4 @@ var RECONSTRUCTION_SHEET = {
|
|
|
918
916
|
defaultParagraphProperties: { widowControl: false }
|
|
919
917
|
};
|
|
920
918
|
//#endregion
|
|
921
|
-
export { ASCENDER, BASELINE_AT, CARRIER_LINE_PT, GUESSED_MARGIN, NATURAL_LINE_EM, buildFlowDoc, dedupeLosses, figureBlock, floatOntoSheet, imageBlock, imageMember, labelMember, membersBox, paragraphBlock, paragraphFromRuns, positionedText, sectionFromPdfPages, sectionOnSheet, shapeBlock, spaceAfter, textSizeOf, tooSmallToRead, vectorMember, withMeasuredMargins };
|
|
919
|
+
export { ASCENDER, BASELINE_AT, CARRIER_LINE_PT, FLOAT_CARRIER, GUESSED_MARGIN, NATURAL_LINE_EM, buildFlowDoc, dedupeLosses, figureBlock, floatOntoSheet, imageBlock, imageMember, labelMember, membersBox, paragraphBlock, paragraphFromRuns, positionedText, sectionFromPdfPages, sectionOnSheet, shapeBlock, spaceAfter, textSizeOf, tooSmallToRead, typesetRuns, typesetting, vectorMember, withMeasuredMargins };
|
|
@@ -149,7 +149,7 @@ function lettersOf(text) {
|
|
|
149
149
|
}
|
|
150
150
|
var LIGATURE = /[\uFB00-\uFB06]/u;
|
|
151
151
|
var LIGATURES = /[\uFB00-\uFB06]/gu;
|
|
152
|
-
var LATIN_LIGATURES = new Map([
|
|
152
|
+
var LATIN_LIGATURES = /* @__PURE__ */ new Map([
|
|
153
153
|
["ff", "ff"],
|
|
154
154
|
["fi", "fi"],
|
|
155
155
|
["fl", "fl"],
|
|
@@ -231,7 +231,7 @@ function coreGlyphOrder(file, fontDict) {
|
|
|
231
231
|
return out;
|
|
232
232
|
}
|
|
233
233
|
/** The core faces whose first glyphs stand in the standard Macintosh order. */
|
|
234
|
-
var CORE_FACES = new Set([
|
|
234
|
+
var CORE_FACES = /* @__PURE__ */ new Set([
|
|
235
235
|
"arial",
|
|
236
236
|
"timesnewroman",
|
|
237
237
|
"couriernew",
|
|
@@ -1230,4 +1230,4 @@ function asNumber(v, dflt) {
|
|
|
1230
1230
|
return typeof v === "number" ? v : dflt;
|
|
1231
1231
|
}
|
|
1232
1232
|
//#endregion
|
|
1233
|
-
export { buildContentFont, collectFaceFamilies };
|
|
1233
|
+
export { buildContentFont, collectFaceFamilies, familyOfFace };
|
|
@@ -161,12 +161,14 @@ function parseProgram(bytes) {
|
|
|
161
161
|
const tok = lexer.nextToken();
|
|
162
162
|
if (tok.kind === "eof") return depth === 0 ? out : void 0;
|
|
163
163
|
if (tok.kind === "num") out.push(tok.value);
|
|
164
|
-
else if (tok.kind === "keyword")
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
164
|
+
else if (tok.kind === "keyword") {
|
|
165
|
+
if (tok.value === "{") {
|
|
166
|
+
const inner = read(depth + 1);
|
|
167
|
+
if (!inner) return void 0;
|
|
168
|
+
out.push(inner);
|
|
169
|
+
} else if (tok.value === "}") return out;
|
|
170
|
+
else out.push(tok.value);
|
|
171
|
+
}
|
|
170
172
|
}
|
|
171
173
|
};
|
|
172
174
|
const top = read(0);
|
|
@@ -380,7 +382,6 @@ function run(program, stack, depth) {
|
|
|
380
382
|
}
|
|
381
383
|
break;
|
|
382
384
|
}
|
|
383
|
-
default: break;
|
|
384
385
|
}
|
|
385
386
|
}
|
|
386
387
|
}
|
|
@@ -71,7 +71,7 @@ function tagTable(data, view) {
|
|
|
71
71
|
if (count === 0 || count > MAX_TAGS) return void 0;
|
|
72
72
|
const out = /* @__PURE__ */ new Map();
|
|
73
73
|
for (let i = 0; i < count; i++) {
|
|
74
|
-
const at =
|
|
74
|
+
const at = 132 + i * 12;
|
|
75
75
|
if (at + 12 > data.length) break;
|
|
76
76
|
const offset = view.getUint32(at + 4);
|
|
77
77
|
const size = view.getUint32(at + 8);
|
|
@@ -235,7 +235,7 @@ function clippedUnitBox(ctm, clip) {
|
|
|
235
235
|
v1: Math.min(1, Math.max(0, v1))
|
|
236
236
|
};
|
|
237
237
|
if (!(cut.u1 - cut.u0 > CROPS) || !(cut.v1 - cut.v0 > CROPS)) return whole;
|
|
238
|
-
if (cut.u1 - cut.u0 >
|
|
238
|
+
if (cut.u1 - cut.u0 > .99 && cut.v1 - cut.v0 > .99) return whole;
|
|
239
239
|
return cut;
|
|
240
240
|
}
|
|
241
241
|
function matrixOf(file, dict) {
|