@patrickdk77/xfa-flatten 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/LICENSE-APACHE-2.0 +202 -0
- package/NOTICE +14 -0
- package/README.md +112 -2
- package/dist/barcode-paint.d.ts +11 -0
- package/dist/barcode-paint.js +135 -0
- package/dist/barcode.d.ts +45 -0
- package/dist/barcode.js +750 -0
- package/dist/canvas.d.ts +59 -0
- package/dist/canvas.js +179 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +34 -0
- package/dist/css.d.ts +48 -0
- package/dist/css.js +288 -0
- package/dist/deadline.d.ts +6 -0
- package/dist/deadline.js +18 -0
- package/dist/filters.d.ts +21 -0
- package/dist/filters.js +296 -0
- package/dist/flatten.d.ts +25 -0
- package/dist/flatten.js +319 -0
- package/dist/font-metrics.d.ts +9 -0
- package/dist/font-metrics.js +215 -0
- package/dist/fonts.d.ts +36 -0
- package/dist/fonts.js +144 -0
- package/dist/images.d.ts +23 -0
- package/dist/images.js +519 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/index.mjs +3 -0
- package/dist/layout.d.ts +64 -0
- package/dist/layout.js +779 -0
- package/dist/limits.d.ts +2 -0
- package/dist/limits.js +6 -0
- package/dist/locale.d.ts +29 -0
- package/dist/locale.js +97 -0
- package/dist/paint.d.ts +15 -0
- package/dist/paint.js +533 -0
- package/dist/pdf-crypt.d.ts +35 -0
- package/dist/pdf-crypt.js +261 -0
- package/dist/pdf-read.d.ts +140 -0
- package/dist/pdf-read.js +1026 -0
- package/dist/pdf417-table.d.ts +2 -0
- package/dist/pdf417-table.js +146 -0
- package/dist/pdfjs-repair.d.ts +13 -0
- package/dist/pdfjs-repair.js +257 -0
- package/dist/pdfjs.d.ts +16 -0
- package/dist/pdfjs.js +62 -0
- package/dist/picture.d.ts +40 -0
- package/dist/picture.js +678 -0
- package/dist/saslprep.d.ts +11 -0
- package/dist/saslprep.js +178 -0
- package/dist/style.d.ts +29 -0
- package/dist/style.js +178 -0
- package/dist/text.d.ts +44 -0
- package/dist/text.js +199 -0
- package/dist/tiff.d.ts +3 -0
- package/dist/tiff.js +270 -0
- package/dist/tree.d.ts +23 -0
- package/dist/tree.js +54 -0
- package/dist/types.d.ts +31 -0
- package/dist/types.js +2 -0
- package/dist/writer.d.ts +38 -0
- package/dist/writer.js +145 -0
- package/dist/xfa-apply.d.ts +49 -0
- package/dist/xfa-apply.js +617 -0
- package/dist/xfa-model.d.ts +42 -0
- package/dist/xfa-model.js +227 -0
- package/dist/xfa-paint.d.ts +24 -0
- package/dist/xfa-paint.js +275 -0
- package/dist/xfa-spec.d.ts +47 -0
- package/dist/xfa-spec.js +3 -0
- package/dist/xml.d.ts +30 -0
- package/dist/xml.js +211 -0
- package/package.json +83 -4
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The bar and space patterns of PDF417's 929 symbol characters in each of its three clusters (0, 3 and 6), from
|
|
3
|
+
// ISO/IEC 15438 as ZXing publishes it in core/src/main/java/com/google/zxing/pdf417/encoder/PDF417.java.
|
|
4
|
+
// Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part. Licensed under the Apache License, Version 2.0;
|
|
5
|
+
// see LICENSE-APACHE-2.0 and NOTICE. Changed from Java integer arrays to packed hex strings, with the same values.
|
|
6
|
+
// Each pattern is 17 modules, bar first, packed as the low 16 bits in four hex digits; the leading module is always
|
|
7
|
+
// a bar.
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.pdf417Pattern = pdf417Pattern;
|
|
10
|
+
const PACKED = [
|
|
11
|
+
[
|
|
12
|
+
'd5c0eaf0f57cd4e0ea78f53ea8c0d470a8605040a8305020adc0d6f0eb7cace0d678eb3e58c0ac7058605dc0aef0d77c',
|
|
13
|
+
'5ce0ae78d73e5c70ae3c5ef0af7c5e78af3e5f7cf5fad2e0e978f4bea4c0d270e93ca460d2384840a430d21c4820a418',
|
|
14
|
+
'4810a6e0d378e9be4cc0a670d33c4c60a638d31e4c30a61c4ee0a778d3be4e70a73c4e38a71e4f78a7be4f3c4f1ea2c0',
|
|
15
|
+
'd170e8bca260d138e89e4440a230d11c4420a2184410440846c0a370d1bc4660a338d19e4630a31c4618460c4770a3bc',
|
|
16
|
+
'4738a39e471c47bca160d0b8e85e4240a130d09c4220a118d08e4210a10c4208a1064360a1b8d0de4330a19c4318a18e',
|
|
17
|
+
'430c4306a1de438e4140a0b0d05c4120a098d04e4110a08c4108a086410441b04198418c40a0d02ea04ca0464082cae0',
|
|
18
|
+
'e578f2be94c0ca70e53c9460ca38e51e28409430282096e0cb78e5be2cc09670cb3c2c6096382c302c182ee09778cbbe',
|
|
19
|
+
'2e70973c2e382e1c2f7897be2f3c2fbedac0ed70f6bcda60ed38f69eb440da30ed1cb420da18ed0eb410da0c92c0c970',
|
|
20
|
+
'e4bcb6c09260c938e49eb660db38ed9e6c4024209218c90e6c20b6186c1026c09370c9bc6ec026609338c99e6e60b738',
|
|
21
|
+
'db9e6e3026186e18277093bc6f702738939e6f38b79e6f1c27bc6fbc279e6f9ed960ecb8f65eb240d930ec9cb220d918',
|
|
22
|
+
'ec8eb210d90cb208b2049160c8b8e45eb3609130c89c66402220d99cc88e66202210910c6610b30c91062204236091b8',
|
|
23
|
+
'c8de67602330919c6730b39c918e6718230c230623b891de67b8239c679c238e678e67deb140d8b0ec5cb120d898ec4e',
|
|
24
|
+
'b110d88cb108d886b104b102214090b0c85c634021209098c84e6320b198d8ce6310210890866308b186630421b090dc',
|
|
25
|
+
'63b0219890ce6398b1ce638c2186638663dc63ceb0a0d858ec2eb090d84cb088d846b084b08220a09058c82e61a02090',
|
|
26
|
+
'904c6190b0cc9046618820846184208220d861d861cc61c6d82cd826b042902c204860c860c460c28ac0c570e2bc8a60',
|
|
27
|
+
'c53814408a30c51c14208a181410140816c08b70c5bc16608b38c59e16308b1c1618160c17708bbc17388b9e171c17bc',
|
|
28
|
+
'179ecd60e6b8f35e9a40cd30e69c9a20cd18e68e9a10cd0c9a08cd068960c4b8e25e9b608930c49c36401220cd9cc48e',
|
|
29
|
+
'36209b18890c361012083608136089b8c4de37601330cdde37309b9c898e3718130c370c13b889de37b8139c379c138e',
|
|
30
|
+
'13de37dedd40eeb0f75cdd20ee98f74edd10ee8cdd08ee86dd049940ccb0e65cbb409920eedce64ebb20dd98eecebb10',
|
|
31
|
+
'9908cc86bb08dd869902114088b0c45c334011208898c44e774033209998ccce7720bb98ddce88867710330899867708',
|
|
32
|
+
'110211b088dc33b0119888ce77b0339899ce7798bbce1186338611dc33dc11ce77dc33cedca0ee58f72edc90ee4cdc88',
|
|
33
|
+
'ee46dc84dc8298a0cc58e62eb9a09890ee6eb990dccccc46b9889884b9849882b98210a08858c42e31a01090884c73a0',
|
|
34
|
+
'319098cc88467390b9cc1084738831841082318210d8886e31d810cc73d831cc10c673cc31c610ee73eedc50ee2cdc48',
|
|
35
|
+
'ee26dc44dc429850cc2cb8d09848cc26b8c8dc66b8c49842b8c21050882c30d01048882671d030c8986671c8b8e61042',
|
|
36
|
+
'71c430c271c230ec71ec71e6ee16dc22cc16982498221028306870e81022306285600a4085300a208518c28e0a10850c',
|
|
37
|
+
'0a0885060b6085b8c2de0b30859c0b18858e0b0c0b060bb885de0b9c0b8e0bde8d40c6b0e35c8d20c6988d10c68c8d08',
|
|
38
|
+
'c6868d04094084b0c25c1b400920c6dcc24e1b208d98c6ce1b10090884861b088d86090209b084dc1bb0099884ce1b98',
|
|
39
|
+
'8dce1b8c098609dc1bdc09ce1bcecea0e758f3aece90e74cce88e746ce84ce828ca0c6589da08c90c64c9d90ceccc646',
|
|
40
|
+
'9d888c849d848c829d8208a0845819a00890c66e3ba019908ccc84463b909dcc08843b8819840882198208d8846e19d8',
|
|
41
|
+
'08cc3bd819cc08c63bcc19c608ee19ee3beeef50f7acef48f7a6ef44ef42ce50e72cded0ef6ce726dec8ef66dec4ce42',
|
|
42
|
+
'dec28c50c62c9cd08c48c626bdd09cc8ce66bdc8dee68c42bdc49cc2bdc20850842c18d00848842639d018c88c667bd0',
|
|
43
|
+
'39c89ce608427bc8bde618c27bc4086c18ec086639ec18e67bec39e67be6ef28f796ef24ef22ce28e716de68ef36de64',
|
|
44
|
+
'ce22de628c28c6169c688c24bce89c648c22bce49c62bce20828841618688c3638e81864082279e838e4186279e438e2',
|
|
45
|
+
'79e2187679f6ef12de34de329c34bc74bc721834387478f478f205400520829805100508050405b00598058c058605dc',
|
|
46
|
+
'05ce86a08690c34c8688c3468684868204a082580da086d8824c0d9086cc0d8886c60d8404820d8204d8826e0dd886ee',
|
|
47
|
+
'0dcc04c60dc604ee0deec750c748c744c74286508ed0c76cc3268ec8c7668ec486428ec204500cd0044882261dd00cc8',
|
|
48
|
+
'04441dc80cc404421dc40cc2046c0cec04661dec0ce61de6e7a8e7a4e7a2c728cf68e7b6cf64c722cf628628c3168e68',
|
|
49
|
+
'c7369ee88e6486229ee48e629ee2042882160c6886361ce80c6404223de81ce40c623de41ce204360c761cf63df6f7d4',
|
|
50
|
+
'f7d2e794efb4e792efb2c714cf34c712df74cf32df7286148e3486129e748e32bef4',
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
'f560fab8ea40f530fa9cea20f518fa8eea10f50cea08f506ea04eb60f5b8faded640eb30f59cd620eb18f58ed610eb0c',
|
|
54
|
+
'd608eb06d604d760ebb8f5deae40d730eb9cae20d718eb8eae10d70cae08d706ae04af60d7b8ebde5e40af30d79c5e20',
|
|
55
|
+
'af18d78e5e10af0c5e08af065f60afb8d7de5f30af9c5f18af8e5f0c5fb8afde5f9c5f8ee940f4b0fa5ce920f498fa4e',
|
|
56
|
+
'e910f48ce908f486e904e902d340e9b0f4dcd320e998f4ced310e98cd308e986d304d302a740d3b0e9dca720d398e9ce',
|
|
57
|
+
'a710d38ca708d386a704a7024f40a7b0d3dc4f20a798d3ce4f10a78c4f08a7864f044fb0a7dc4f98a7ce4f8c4f864fdc',
|
|
58
|
+
'4fcee8a0f458fa2ee890f44ce888f446e884e882d1a0e8d8f46ed190e8ccd188e8c6d184d182a3a0d1d8e8eea390d1cc',
|
|
59
|
+
'a388d1c6a384a38247a0a3d8d1ee4790a3cc4788a3c64784478247d8a3ee47cc47c647eee850f42ce848f426e844e842',
|
|
60
|
+
'd0d0e86cd0c8e866d0c4d0c2a1d0d0eca1c8d0e6a1c4a1c243d0a1ec43c8a1e643c443c243ec43e6e828f416e824e822',
|
|
61
|
+
'd068e836d064d062a0e8d076a0e4a0e241e8a0f641e441e2e814e812d034d032a074a072e540f2b0f95ce520f298f94e',
|
|
62
|
+
'e510f28ce508f286e504e502cb40e5b0f2dccb20e598f2cecb10e58ccb08e586cb04cb029740cbb0e5dc9720cb98e5ce',
|
|
63
|
+
'9710cb8c9708cb86970497022f4097b0cbdc2f209798cbce2f10978c2f0897862f042fb097dc2f9897ce2f8c2f862fdc',
|
|
64
|
+
'2fcef6a0fb586bf0f690fb4c69f8f688fb4668fcf684f682e4a0f258f92eeda0e490fb6eed90f6ccf246ed88e484ed84',
|
|
65
|
+
'e482ed82c9a0e4d8f26edba0c990e4ccdb90edcce4c6db88c984db84c982db8293a0c9d8e4eeb7a09390c9ccb790dbcc',
|
|
66
|
+
'c9c6b7889384b7849382b78227a093d8c9ee6fa0279093cc6f90b7cc93c66f8827846f84278227d893ee6fd827cc6fcc',
|
|
67
|
+
'27c66fc627eef650fb2c65f8f648fb2664fcf644647ef642e450f22cecd0e448f226ecc8f666ecc4e442ecc2c8d0e46c',
|
|
68
|
+
'd9d0c8c8e466d9c8ece6d9c4c8c2d9c291d0c8ecb3d091c8c8e6b3c8d9e6b3c491c2b3c223d091ec67d023c891e667c8',
|
|
69
|
+
'b3e667c423c267c223ec67ec23e667e6f628fb1662fcf624627ef622e428f216ec68f636ec64e422ec62c868e436d8e8',
|
|
70
|
+
'c864d8e4c862d8e290e8c876b1e8d8f6b1e490e2b1e221e890f663e821e463e421e263e221f663f6f614617ef612e414',
|
|
71
|
+
'ec34e412ec32c834d874c832d8729074b0f49072b0f220f461f420f261f2f60ae40aec1ac81ad83a903ab07ae2a0f158',
|
|
72
|
+
'f8aee290f14ce288f146e284e282c5a0e2d8f16ec590e2ccc588e2c6c584c5828ba0c5d8e2ee8b90c5cc8b88c5c68b84',
|
|
73
|
+
'8b8217a08bd8c5ee17908bcc17888bc61784178217d88bee17cc17c617eef350f9ac35f8f348f9a634fcf344347ef342',
|
|
74
|
+
'e250f12ce6d0e248f126e6c8f366e6c4e242e6c2c4d0e26ccdd0c4c8e266cdc8e6e6cdc4c4c2cdc289d0c4ec9bd089c8',
|
|
75
|
+
'c4e69bc8cde69bc489c29bc213d089ec37d013c889e637c89be637c413c237c213ec37ec13e637e6fba875f0bafcfba4',
|
|
76
|
+
'74f8ba7efba2747c743ef328f99632fcf768fbb676fc327ef764f322767ef762e228f116e668e224eee8f776e222eee4',
|
|
77
|
+
'e662eee2c468e236cce8c464dde8cce4c462dde4cce2dde288e8c47699e888e4bbe899e488e2bbe499e2bbe211e888f6',
|
|
78
|
+
'33e811e477e833e411e277e433e277e211f633f6fb9472f8b97efb92727c723ef314317ef734f312737ef732e214e634',
|
|
79
|
+
'e212ee74e632ee72c434cc74c432dcf4cc72dcf2887498f48872b9f498f2b9f210f431f410f273f431f273f2fb8a717c',
|
|
80
|
+
'713ef30af71ae20ae61aee3ac41acc3adc7a883a987ab8fa107a30fa71fa70bee150f0ace148f0a6e144e142c2d0e16c',
|
|
81
|
+
'c2c8e166c2c4c2c285d0c2ec85c8c2e685c485c20bd085ec0bc885e60bc40bc20bec0be6f1a8f8d61afcf1a41a7ef1a2',
|
|
82
|
+
'e128f096e368e124e364e122e362c268e136c6e8c264c6e4c262c6e284e8c2768de884e48de484e28de209e884f61be8',
|
|
83
|
+
'09e41be409e21be209f61bf6f9d43af89d7ef9d23a7c3a3ef194197ef3b4f1923b7ef3b2e114e334e112e774e332e772',
|
|
84
|
+
'c234c674c232cef4c672cef284748cf484729df48cf29df208f419f408f23bf419f23bf27af0bd7c7a78bd3e7a3c7a1e',
|
|
85
|
+
'f9ca397cfbda7b7c393e7b3ef18af39af7bae10ae31ae73aef7ac21ac63ace7adefa843a8c7a9cfabdfa087a18fa39fa',
|
|
86
|
+
'7978bcbe793c791e38be79be78bc789e785ee0a8e0a4e0a2c168e0b6c164c16282e8c17682e482e205e882f605e405e2',
|
|
87
|
+
'05f6f0d40d7ef0d2e094e1b4e092e1b2c134c374c132c372827486f4827286f204f40df404f20df2f8ea1d7c1d3ef0ca',
|
|
88
|
+
'f1dae08ae19ae3bac11ac33ac77a823a867a8efa047a0cfa1dfa3d789ebe3d3c3d1e1cbe3dbe7d70bebc7d38be9e7d1c',
|
|
89
|
+
'7d0e3cbc7dbc3c9e7d9e7cb8be5e7c9c7c8e3c5e7cde7c5c7c4e7c2ec0b4c0b28174817202f402f2e0dac09ac1ba813a',
|
|
90
|
+
'837a027a06fa0ebe1ebc1e9e3eb89f5e3e9c3e8e1e5e3ede7eb0bf5c7e98bf4e7e8c7e863e5c7edc3e4e7ece7e58bf2e',
|
|
91
|
+
'7e4c7e463e2e7e6e7e2c7e260f5e1f5c1f4e3f589fae3f4c3f461f2e3f6e3f2c3f26',
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
'abe0d5f853c0a9f0d4fc51e0a8f8d47e50f0a87c5078fad05be0adf8fac859f0acfcfac458f8ac7efac2587cf5d0faec',
|
|
95
|
+
'5df8f5c8fae65cfcf5c45c7ef5c2ebd0f5ecebc8f5e6ebc4ebc2d7d0ebecd7c8ebe6d7c4d7c2afd0d7ecafc8d7e6afc4',
|
|
96
|
+
'4bc0a5f0d2fc49e0a4f8d27e48f0a47c4878a43e483cfa684df0a6fcfa644cf8a67efa624c7c4c3ef4e8fa764efcf4e4',
|
|
97
|
+
'4e7ef4e2e9e8f4f6e9e4e9e2d3e8e9f6d3e4d3e2a7e8d3f6a7e4a7e245e0a2f8d17e44f0a27c4478a23e443c441efa34',
|
|
98
|
+
'46f8a37efa32467c463ef474477ef472e8f4e8f2d1f4d1f2a3f4a3f242f0a17c4278a13e423c421efa1a437c433ef43a',
|
|
99
|
+
'e87ad0fa4178a0be413c411e41be40bc409e2bc095f0cafc29e094f8ca7e28f0947c2878943e283cf9682df096fcf964',
|
|
100
|
+
'2cf8967ef9622c7c2c3ef2e8f9762efcf2e42e7ef2e2e5e8f2f6e5e4e5e2cbe8e5f6cbe4cbe297e8cbf697e497e2b5e0',
|
|
101
|
+
'daf8ed7e69c0b4f0da7c68e0b478da3e6870b43c6838b41e681c25e092f8c97e6de024f0927c6cf0b67c923e6c78243c',
|
|
102
|
+
'6c3c241e6c1ef93426f8937efb74f9326ef8267cfb726e7c263e6e3ef274277ef6f4f2726f7ef6f2e4f4edf4e4f2edf2',
|
|
103
|
+
'c9f4dbf4c9f2dbf293f493f265c0b2f0d97c64e0b278d93e6470b23c6438b21e641c640e22f0917c66f02278913e6678',
|
|
104
|
+
'b33e663c221e661ef91a237cfb3a677c233e673ef23af67ae47aecfac8fad9fa91fa62e0b178d8be6270b13c6238b11e',
|
|
105
|
+
'621c620e217890be6378213c633c211e631e21be63be6170b0bc6138b09e611c610e20bc61bc209e619e60b8b05e609c',
|
|
106
|
+
'608e205e60de605c604e15e08af8c57e14f08a7c14788a3e143c141ef8b416f88b7ef8b2167c163ef174177ef172e2f4',
|
|
107
|
+
'e2f2c5f4c5f28bf48bf235c09af0cd7c34e09a78cd3e34709a3c34389a1e341c340e12f0897c36f01278893e36789b3e',
|
|
108
|
+
'363c121e361ef89a137cf9ba377c133e373ef13af37ae27ae6fac4facdfa89fabae0dd78eebe74c0ba70dd3c7460ba38',
|
|
109
|
+
'dd1e7430ba1c7418ba0e740c32e09978ccbe76e03270993c7670bb3c991e7638321c761c320e760e117888be3378113c',
|
|
110
|
+
'7778333c111e773c331e771e11be33be77be72c0b970dcbc7260b938dc9e7230b91c7218b90e720c7206317098bc7370',
|
|
111
|
+
'3138989e7338b99e731c310e730e10bc31bc109e73bc319e739e7160b8b8dc5e7130b89c7118b88e710c710630b8985e',
|
|
112
|
+
'71b8309c719c308e718e105e30de71de70b0b85c7098b84e708c7086305c70dc304e70ce7058b82e704c7046302e706e',
|
|
113
|
+
'702c70260af0857c0a78853e0a3c0a1e0b7c0b3ef0bae17ac2fa85fa1ae08d78c6be1a708d3c1a388d1e1a1c1a0e0978',
|
|
114
|
+
'84be1b78093c1b3c091e1b1e09be1bbe3ac09d70cebc3a609d38ce9e3a309d1c3a189d0e3a0c3a0619708cbc3b701938',
|
|
115
|
+
'8c9e3b38191c3b1c190e3b0e08bc19bc089e3bbc199e3b9ebd60deb8ef5e7a40bd30de9c7a20bd18de8e7a10bd0c7a08',
|
|
116
|
+
'bd067a0439609cb8ce5e7b6039309c9c7b30bd9c9c8e7b18390c7b0c39067b0618b88c5e39b8189c7bb8399c188e7b9c',
|
|
117
|
+
'398e7b8e085e18de39de7bde7940bcb0de5c7920bc98de4e7910bc8c7908bc867904790238b09c5c79b038989c4e7998',
|
|
118
|
+
'bcce798c38867986185c38dc184e79dc38ce79ce78a0bc58de2e7890bc4c7888bc467884788238589c2e78d8384c78cc',
|
|
119
|
+
'384678c6182e386e78ee7850bc2c7848bc2678447842382c786c382678667828bc167824782238167836057882be053c',
|
|
120
|
+
'051e05be0d7086bc0d38869e0d1c0d0e04bc0dbc049e0d9e1d608eb8c75e1d308e9c1d188e8e1d0c1d060cb8865e1db8',
|
|
121
|
+
'0c9c1d9c0c8e1d8e045e0cde1dde3d409eb0cf5c3d209e98cf4e3d109e8c3d089e863d043d021cb08e5c3db01c988e4e',
|
|
122
|
+
'3d989ece3d8c1c863d860c5c1cdc0c4e3ddc1cce3dcebea0df58efaebe90df4cbe88df46be84be823ca09e58cf2e7da0',
|
|
123
|
+
'3c909e4c7d90becc9e467d883c847d843c827d821c588e2e3cd81c4c7dd83ccc1c467dcc3cc67dc60c2e1c6e3cee7dee',
|
|
124
|
+
'be50df2cbe48df26be44be423c509e2c7cd03c489e267cc8be667cc43c427cc21c2c3c6c1c267cec3c667ce6be28df16',
|
|
125
|
+
'be24be223c289e167c683c247c643c227c621c163c367c76be14be123c147c343c127c3202bc029e06b8835e069c068e',
|
|
126
|
+
'025e06de0eb0875c0e98874e0e8c0e86065c0edc064e0ece1ea08f58c7ae1e908f4c1e888f461e841e820e58872e1ed8',
|
|
127
|
+
'8f6e1ecc0e461ec6062e0e6e1eee9f50cfac9f48cfa69f449f421e508f2c3ed09f6c8f263ec81e443ec41e423ec20e2c',
|
|
128
|
+
'1e6c0e263eec1e663ee6dfa8efd6dfa4dfa29f28cf96bf689f24bf649f22bf621e288f163e681e247ee83e641e227ee4',
|
|
129
|
+
'3e627ee20e161e363e767ef6df94df929f14bf349f12bf321e143e341e127e743e327e72df8a9f0abf1a1e0a3e1a7e3a',
|
|
130
|
+
'035c034e075883ae074c0746032e076e0f5087ac0f4887a60f440f42072c0f6c07260f668fa8c7d68fa48fa20f288796',
|
|
131
|
+
'1f688fb61f640f221f6207160f361f76cfd4cfd28f949fb48f929fb20f141f340f123f741f323f72cfca8f8a9f9a0f0a',
|
|
132
|
+
'1f1a3f3a03ac03a607a883d607a407a2039607b687d487d207940fb407920fb2c7ea',
|
|
133
|
+
],
|
|
134
|
+
];
|
|
135
|
+
let table = null;
|
|
136
|
+
/** The 17-module pattern of a codeword in a cluster (0, 1 or 2 for clusters 0, 3 and 6), bit 16 first. */
|
|
137
|
+
function pdf417Pattern(rowCluster, codeword) {
|
|
138
|
+
table ??= PACKED.map(parts => {
|
|
139
|
+
const hex = parts.join('');
|
|
140
|
+
const out = new Uint32Array(hex.length / 4);
|
|
141
|
+
for (let i = 0; i < out.length; i++)
|
|
142
|
+
out[i] = 0x10000 | Number.parseInt(hex.slice(i * 4, i * 4 + 4), 16);
|
|
143
|
+
return out;
|
|
144
|
+
});
|
|
145
|
+
return table[rowCluster][codeword];
|
|
146
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface PdfjsRepair {
|
|
2
|
+
/** The copy for pdf.js. */
|
|
3
|
+
bytes: Uint8Array;
|
|
4
|
+
/** One sentence per repair made. */
|
|
5
|
+
fixes: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Builds the copy for pdf.js, or returns null when none of the repairs applies (or the file cannot be read), in which
|
|
9
|
+
* case pdf.js's own error stands.
|
|
10
|
+
*/
|
|
11
|
+
export declare function repairForPdfjs(bytes: Uint8Array, passwords: readonly string[], deadline?: number): PdfjsRepair | null;
|
|
12
|
+
/** Why pdf.js has no form to lay out, when the cause is in the XFA itself; null when nothing here explains it. */
|
|
13
|
+
export declare function xfaProblem(bytes: Uint8Array, passwords: readonly string[], deadline?: number): string | null;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// pdf.js 6 stops before laying out some forms that a reader shows. This module builds a copy of the PDF, for pdf.js
|
|
3
|
+
// alone, with an incremental update that works around those stops. The caller's bytes are not changed, and the copy
|
|
4
|
+
// is never part of the output; the flattened PDF is written from scratch as before.
|
|
5
|
+
//
|
|
6
|
+
// The copy is made only after pdf.js has failed on the form as written, so a form pdf.js lays out is laid out from
|
|
7
|
+
// the caller's bytes. The repairs, each made only where its condition holds:
|
|
8
|
+
// - No /DR /Font in the AcroForm: pdf.js never builds its font finder and fails on the first text it measures. An
|
|
9
|
+
// empty /Font dictionary makes it load its own substitutes for every typeface the form names.
|
|
10
|
+
// - A <traverse ref> that pdf.js's SOM search cannot follow, for example "#subform[0]" from a field, throws in its
|
|
11
|
+
// tab-order pass. The flattened output has no tab order, so the copy drops every traverse ref.
|
|
12
|
+
// - A page set whose page areas all have a finite occur max, when the content needs more pages than they allow:
|
|
13
|
+
// pdf.js recurses until the stack runs out. The copy lifts the max of the last page area in such a set, so the
|
|
14
|
+
// extra pages repeat it.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.repairForPdfjs = repairForPdfjs;
|
|
17
|
+
exports.xfaProblem = xfaProblem;
|
|
18
|
+
const node_zlib_1 = require("node:zlib");
|
|
19
|
+
const pdf_read_1 = require("./pdf-read");
|
|
20
|
+
const writer_1 = require("./writer");
|
|
21
|
+
const xml_1 = require("./xml");
|
|
22
|
+
const TEMPLATE_NS = 'http://www.xfa.org/schema/xfa-template/';
|
|
23
|
+
/** The namespace an element is in, from its own or an ancestor's xmlns declarations. */
|
|
24
|
+
function namespaceOf(node) {
|
|
25
|
+
const colon = node.name.indexOf(':');
|
|
26
|
+
const key = colon >= 0 ? `xmlns:${node.name.slice(0, colon)}` : 'xmlns';
|
|
27
|
+
for (let n = node; n; n = n.parent) {
|
|
28
|
+
const v = n.attrs[key];
|
|
29
|
+
if (v !== undefined)
|
|
30
|
+
return v;
|
|
31
|
+
}
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
/** The template packet pdf.js recognizes: a template element in the XFA template namespace. */
|
|
35
|
+
function templateOf(doc) {
|
|
36
|
+
let found = null;
|
|
37
|
+
(0, xml_1.walk)(doc, n => {
|
|
38
|
+
if (found)
|
|
39
|
+
return false;
|
|
40
|
+
if (n.local === 'template' && namespaceOf(n).startsWith(TEMPLATE_NS)) {
|
|
41
|
+
found = n;
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
});
|
|
46
|
+
return found;
|
|
47
|
+
}
|
|
48
|
+
function elementKids(node, local) {
|
|
49
|
+
return node.kids.filter(k => k.local === local);
|
|
50
|
+
}
|
|
51
|
+
/** Whether pdf.js limits a page area to a number of uses (its Occur defaults: no max and no min is unlimited). */
|
|
52
|
+
function finiteArea(area) {
|
|
53
|
+
const occur = (0, xml_1.child)(area, 'occur');
|
|
54
|
+
if (!occur)
|
|
55
|
+
return false;
|
|
56
|
+
const max = occur.attrs.max;
|
|
57
|
+
if (max !== undefined && max.trim() !== '')
|
|
58
|
+
return Number.parseInt(max, 10) !== -1;
|
|
59
|
+
return occur.attrs.min !== undefined && occur.attrs.min.trim() !== '';
|
|
60
|
+
}
|
|
61
|
+
/** Rewrites the attribute in a start tag, or adds it before the tag's end. */
|
|
62
|
+
function setAttribute(src, node, key, value) {
|
|
63
|
+
const tag = src.slice(node.tagStart, node.tagEnd);
|
|
64
|
+
const re = new RegExp(`\\s${key}\\s*=\\s*("[^"]*"|'[^']*')`);
|
|
65
|
+
let text;
|
|
66
|
+
if (re.test(tag))
|
|
67
|
+
text = tag.replace(re, value === null ? '' : ` ${key}="${value}"`);
|
|
68
|
+
else if (value === null)
|
|
69
|
+
text = tag;
|
|
70
|
+
else {
|
|
71
|
+
const close = tag.endsWith('/>') ? tag.length - 2 : tag.length - 1;
|
|
72
|
+
text = `${tag.slice(0, close)} ${key}="${value}"${tag.slice(close)}`;
|
|
73
|
+
}
|
|
74
|
+
return { start: node.tagStart, end: node.tagEnd, text };
|
|
75
|
+
}
|
|
76
|
+
/** The template edits, and a sentence for each kind made. */
|
|
77
|
+
function templateEdits(xdp, deadline) {
|
|
78
|
+
const doc = (0, xml_1.parseXml)(xdp, deadline);
|
|
79
|
+
const template = templateOf(doc);
|
|
80
|
+
if (!template)
|
|
81
|
+
return null;
|
|
82
|
+
const edits = [];
|
|
83
|
+
const fixes = [];
|
|
84
|
+
let refs = 0;
|
|
85
|
+
(0, xml_1.walk)(template, n => {
|
|
86
|
+
if (n.local === 'exData')
|
|
87
|
+
return false;
|
|
88
|
+
if (n.local === 'traverse' && n.attrs.ref !== undefined && n.tagStart >= 0) {
|
|
89
|
+
edits.push(setAttribute(xdp, n, 'ref', null));
|
|
90
|
+
refs++;
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
});
|
|
94
|
+
if (refs > 0)
|
|
95
|
+
fixes.push(`pdf.js was given the form without its ${refs} tab-order references, which it could not follow; the flattened form has no tab order.`);
|
|
96
|
+
let lifted = 0;
|
|
97
|
+
(0, xml_1.walk)(template, n => {
|
|
98
|
+
if (n.local !== 'pageSet')
|
|
99
|
+
return undefined;
|
|
100
|
+
const relation = n.attrs.relation ?? 'orderedOccurrence';
|
|
101
|
+
if (relation !== 'orderedOccurrence' || elementKids(n, 'pageSet').length > 0)
|
|
102
|
+
return undefined;
|
|
103
|
+
const areas = elementKids(n, 'pageArea');
|
|
104
|
+
if (areas.length === 0 || !areas.every(finiteArea))
|
|
105
|
+
return undefined;
|
|
106
|
+
const occur = (0, xml_1.child)(areas[areas.length - 1], 'occur');
|
|
107
|
+
if (!occur || occur.tagStart < 0)
|
|
108
|
+
return undefined;
|
|
109
|
+
edits.push(setAttribute(xdp, occur, 'max', '-1'));
|
|
110
|
+
lifted++;
|
|
111
|
+
return undefined;
|
|
112
|
+
});
|
|
113
|
+
if (lifted > 0) {
|
|
114
|
+
fixes.push('The form needs more pages than its page areas allow, which stops pdf.js; the last page area of each such page set was repeated for the extra pages.');
|
|
115
|
+
}
|
|
116
|
+
return finishEdits(xdp, edits, fixes);
|
|
117
|
+
}
|
|
118
|
+
function finishEdits(xdp, edits, fixes) {
|
|
119
|
+
if (edits.length === 0)
|
|
120
|
+
return null;
|
|
121
|
+
edits.sort((a, b) => b.start - a.start);
|
|
122
|
+
let text = xdp;
|
|
123
|
+
for (const e of edits)
|
|
124
|
+
text = text.slice(0, e.start) + e.text + text.slice(e.end);
|
|
125
|
+
return { text, fixes };
|
|
126
|
+
}
|
|
127
|
+
function hex(bytes) {
|
|
128
|
+
return `<${Buffer.from(bytes).toString('hex')}>`;
|
|
129
|
+
}
|
|
130
|
+
/** Writes a value read from the file back as PDF syntax, encrypting strings for the object they are written into. */
|
|
131
|
+
function serialize(v, sealString) {
|
|
132
|
+
if (v === null)
|
|
133
|
+
return 'null';
|
|
134
|
+
if (typeof v === 'number')
|
|
135
|
+
return (0, writer_1.formatNumber)(v);
|
|
136
|
+
if (typeof v === 'boolean')
|
|
137
|
+
return v ? 'true' : 'false';
|
|
138
|
+
if (typeof v === 'string')
|
|
139
|
+
return v;
|
|
140
|
+
if (v instanceof pdf_read_1.PName)
|
|
141
|
+
return (0, writer_1.formatName)(v.name);
|
|
142
|
+
if (v instanceof pdf_read_1.PRef)
|
|
143
|
+
return `${v.num} ${v.gen} R`;
|
|
144
|
+
if (v instanceof pdf_read_1.PString)
|
|
145
|
+
return hex(sealString ? sealString(v.bytes) : v.bytes);
|
|
146
|
+
if (v instanceof pdf_read_1.PStream)
|
|
147
|
+
return 'null';
|
|
148
|
+
if (Array.isArray(v))
|
|
149
|
+
return `[${v.map(x => serialize(x, sealString)).join(' ')}]`;
|
|
150
|
+
const parts = [];
|
|
151
|
+
for (const [k, val] of v)
|
|
152
|
+
parts.push(`${(0, writer_1.formatName)(k)} ${serialize(val, sealString)}`);
|
|
153
|
+
return `<<${parts.join(' ')}>>`;
|
|
154
|
+
}
|
|
155
|
+
function objectBody(num, gen, value, security) {
|
|
156
|
+
const seal = security ? (b) => security.sealString(num, gen, b) : null;
|
|
157
|
+
return Buffer.from(`${num} ${gen} obj\n${serialize(value, seal)}\nendobj\n`, 'latin1');
|
|
158
|
+
}
|
|
159
|
+
function streamBody(num, data, security) {
|
|
160
|
+
const packed = (0, node_zlib_1.deflateSync)(data);
|
|
161
|
+
const body = security ? security.sealStream(num, 0, packed) : new Uint8Array(packed);
|
|
162
|
+
return Buffer.concat([Buffer.from(`${num} 0 obj\n<</Length ${body.length} /Filter /FlateDecode>>\nstream\n`, 'latin1'), Buffer.from(body), Buffer.from('\nendstream\nendobj\n', 'latin1')]);
|
|
163
|
+
}
|
|
164
|
+
function appendUpdate(bytes, r, objects) {
|
|
165
|
+
const base = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
166
|
+
const lead = Buffer.from(base.length > 0 && base[base.length - 1] === 10 ? '' : '\n', 'latin1');
|
|
167
|
+
const chunks = [base, lead];
|
|
168
|
+
let offset = base.length + lead.length;
|
|
169
|
+
const offsets = new Map();
|
|
170
|
+
for (const o of objects) {
|
|
171
|
+
offsets.set(o.num, { at: offset, gen: o.gen });
|
|
172
|
+
chunks.push(o.body);
|
|
173
|
+
offset += o.body.length;
|
|
174
|
+
}
|
|
175
|
+
// When the original cross-references were broken, the new section lists every object, from the scan, so a reader
|
|
176
|
+
// needs nothing before it; otherwise it lists only the new objects and points back with /Prev.
|
|
177
|
+
const all = r.rebuilt ? r.offsetEntries() : null;
|
|
178
|
+
if (all)
|
|
179
|
+
for (const [num, at, gen] of all)
|
|
180
|
+
if (!offsets.has(num))
|
|
181
|
+
offsets.set(num, { at, gen });
|
|
182
|
+
let xref = all ? 'xref\n0 1\n0000000000 65535 f \n' : 'xref\n';
|
|
183
|
+
for (const [num, e] of [...offsets].sort((a, b) => a[0] - b[0])) {
|
|
184
|
+
xref += `${num} 1\n${String(e.at).padStart(10, '0')} ${String(e.gen).padStart(5, '0')} n \n`;
|
|
185
|
+
}
|
|
186
|
+
const size = Math.max(r.size, ...objects.map(o => o.num + 1));
|
|
187
|
+
const trailer = [`/Size ${size}`];
|
|
188
|
+
for (const key of ['Root', 'Encrypt', 'ID', 'Info']) {
|
|
189
|
+
const v = r.trailerEntry(key);
|
|
190
|
+
if (v !== undefined)
|
|
191
|
+
trailer.push(`/${key} ${serialize(v, null)}`);
|
|
192
|
+
}
|
|
193
|
+
if (!all)
|
|
194
|
+
trailer.push(`/Prev ${r.previousXref ?? 0}`);
|
|
195
|
+
chunks.push(Buffer.from(`${xref}trailer\n<<${trailer.join(' ')}>>\nstartxref\n${offset}\n%%EOF\n`, 'latin1'));
|
|
196
|
+
return new Uint8Array(Buffer.concat(chunks));
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Builds the copy for pdf.js, or returns null when none of the repairs applies (or the file cannot be read), in which
|
|
200
|
+
* case pdf.js's own error stands.
|
|
201
|
+
*/
|
|
202
|
+
function repairForPdfjs(bytes, passwords, deadline) {
|
|
203
|
+
const r = pdf_read_1.PdfReader.open(bytes, passwords.length ? passwords : [''], deadline);
|
|
204
|
+
if (!r)
|
|
205
|
+
return null;
|
|
206
|
+
const root = r.root;
|
|
207
|
+
const rootRef = r.trailerEntry('Root');
|
|
208
|
+
if (!(0, pdf_read_1.isDict)(root) || !(rootRef instanceof pdf_read_1.PRef))
|
|
209
|
+
return null;
|
|
210
|
+
const afEntry = root.get('AcroForm');
|
|
211
|
+
const af = r.resolve(afEntry);
|
|
212
|
+
if (!(0, pdf_read_1.isDict)(af))
|
|
213
|
+
return null;
|
|
214
|
+
const fixes = [];
|
|
215
|
+
const newAf = new Map(af);
|
|
216
|
+
const objects = [];
|
|
217
|
+
const packets = (0, pdf_read_1.readPackets)(r);
|
|
218
|
+
const edited = packets ? templateEdits((0, pdf_read_1.joinPackets)(packets), deadline) : null;
|
|
219
|
+
if (edited) {
|
|
220
|
+
const num = r.size;
|
|
221
|
+
objects.push({ num, gen: 0, body: streamBody(num, Buffer.from(edited.text, 'utf8'), r.security) });
|
|
222
|
+
newAf.set('XFA', new pdf_read_1.PRef(num, 0));
|
|
223
|
+
fixes.push(...edited.fixes);
|
|
224
|
+
}
|
|
225
|
+
const dr = r.resolve(af.get('DR'));
|
|
226
|
+
if (!(0, pdf_read_1.isDict)(r.resolve((0, pdf_read_1.isDict)(dr) ? dr.get('Font') : null))) {
|
|
227
|
+
const newDr = (0, pdf_read_1.isDict)(dr) ? new Map(dr) : new Map();
|
|
228
|
+
newDr.set('Font', new Map());
|
|
229
|
+
newAf.set('DR', newDr);
|
|
230
|
+
fixes.push('The PDF names no fonts for its form, and pdf.js measures no text without them; it was told to use its own substitutes for every typeface.');
|
|
231
|
+
}
|
|
232
|
+
if (fixes.length === 0)
|
|
233
|
+
return null;
|
|
234
|
+
if (afEntry instanceof pdf_read_1.PRef) {
|
|
235
|
+
const gen = r.generation(afEntry.num);
|
|
236
|
+
objects.push({ num: afEntry.num, gen, body: objectBody(afEntry.num, gen, newAf, r.security) });
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const newRoot = new Map(root);
|
|
240
|
+
newRoot.set('AcroForm', newAf);
|
|
241
|
+
const gen = r.generation(rootRef.num);
|
|
242
|
+
objects.push({ num: rootRef.num, gen, body: objectBody(rootRef.num, gen, newRoot, r.security) });
|
|
243
|
+
}
|
|
244
|
+
return { bytes: appendUpdate(bytes, r, objects), fixes };
|
|
245
|
+
}
|
|
246
|
+
/** Why pdf.js has no form to lay out, when the cause is in the XFA itself; null when nothing here explains it. */
|
|
247
|
+
function xfaProblem(bytes, passwords, deadline) {
|
|
248
|
+
const r = pdf_read_1.PdfReader.open(bytes, passwords.length ? passwords : [''], deadline);
|
|
249
|
+
if (!r)
|
|
250
|
+
return null;
|
|
251
|
+
const packets = (0, pdf_read_1.readPackets)(r);
|
|
252
|
+
if (!packets)
|
|
253
|
+
return null;
|
|
254
|
+
if (!templateOf((0, xml_1.parseXml)((0, pdf_read_1.joinPackets)(packets), deadline)))
|
|
255
|
+
return 'The XFA has no template in the XFA template namespace, so there is no form to lay out.';
|
|
256
|
+
return null;
|
|
257
|
+
}
|
package/dist/pdfjs.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type PdfjsModule = typeof import('pdfjs-dist/legacy/build/pdf.mjs', { with: { 'resolution-mode': 'import' } });
|
|
2
|
+
export declare function loadPdfjs(): Promise<PdfjsModule>;
|
|
3
|
+
export interface XfaDocument {
|
|
4
|
+
pureXfa: boolean;
|
|
5
|
+
html: unknown;
|
|
6
|
+
/** Page sizes in points, from each page's view box. */
|
|
7
|
+
pages: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}[];
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function isPasswordError(e: unknown): boolean;
|
|
14
|
+
/** Opens a PDF with pdf.js's XFA layout on, trying each password in the order given. */
|
|
15
|
+
export declare function openXfa(bytes: Uint8Array, passwords: readonly string[]): Promise<XfaDocument>;
|
|
16
|
+
export {};
|
package/dist/pdfjs.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Loads pdf.js, which ships as ES modules only, with a real dynamic import from this CommonJS build.
|
|
3
|
+
// pdf.js 6 has no eval code path, so there is no isEvalSupported option to turn off; it never runs XFA scripts.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.loadPdfjs = loadPdfjs;
|
|
6
|
+
exports.isPasswordError = isPasswordError;
|
|
7
|
+
exports.openXfa = openXfa;
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
let loading = null;
|
|
10
|
+
function loadPdfjs() {
|
|
11
|
+
loading ??= import('pdfjs-dist/legacy/build/pdf.mjs');
|
|
12
|
+
return loading;
|
|
13
|
+
}
|
|
14
|
+
let fontData = null;
|
|
15
|
+
/**
|
|
16
|
+
* pdf.js measures XFA text with the fonts in the form, and falls back to its own standard font files for fonts the
|
|
17
|
+
* form does not embed. In Node it reads them from this directory of the installed pdfjs-dist.
|
|
18
|
+
*/
|
|
19
|
+
function standardFontDataPath() {
|
|
20
|
+
fontData ??= (0, node_path_1.join)((0, node_path_1.dirname)(require.resolve('pdfjs-dist/package.json')), 'standard_fonts') + node_path_1.sep;
|
|
21
|
+
return fontData;
|
|
22
|
+
}
|
|
23
|
+
function isPasswordError(e) {
|
|
24
|
+
return typeof e === 'object' && e !== null && 'name' in e && e.name === 'PasswordException';
|
|
25
|
+
}
|
|
26
|
+
/** Opens a PDF with pdf.js's XFA layout on, trying each password in the order given. */
|
|
27
|
+
async function openXfa(bytes, passwords) {
|
|
28
|
+
const pdfjs = await loadPdfjs();
|
|
29
|
+
const tries = passwords.length ? passwords : [''];
|
|
30
|
+
let lastError = null;
|
|
31
|
+
for (const pw of tries) {
|
|
32
|
+
const task = pdfjs.getDocument({
|
|
33
|
+
data: new Uint8Array(bytes),
|
|
34
|
+
enableXfa: true,
|
|
35
|
+
verbosity: 0,
|
|
36
|
+
password: pw === '' ? undefined : pw,
|
|
37
|
+
stopAtErrors: false,
|
|
38
|
+
standardFontDataUrl: standardFontDataPath(),
|
|
39
|
+
});
|
|
40
|
+
try {
|
|
41
|
+
const doc = await task.promise;
|
|
42
|
+
const pages = [];
|
|
43
|
+
const pureXfa = doc.isPureXfa;
|
|
44
|
+
const html = pureXfa ? doc.allXfaHtml : null;
|
|
45
|
+
if (pureXfa) {
|
|
46
|
+
for (let i = 1; i <= doc.numPages; i++) {
|
|
47
|
+
const page = await doc.getPage(i);
|
|
48
|
+
const [x0, y0, x1, y1] = page.view;
|
|
49
|
+
pages.push({ width: Math.abs(x1 - x0), height: Math.abs(y1 - y0) });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { pureXfa, html, pages, close: () => task.destroy() };
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
await task.destroy().catch(() => undefined);
|
|
56
|
+
lastError = e;
|
|
57
|
+
if (!isPasswordError(e))
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
62
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { LocaleInfo, Locales } from './locale';
|
|
2
|
+
export type ValueKind = 'date' | 'time' | 'datetime' | 'num' | 'text';
|
|
3
|
+
declare const CATEGORIES: string[];
|
|
4
|
+
export interface DateParts {
|
|
5
|
+
y: number;
|
|
6
|
+
m: number;
|
|
7
|
+
d: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TimeParts {
|
|
10
|
+
h: number;
|
|
11
|
+
mi: number;
|
|
12
|
+
s: number;
|
|
13
|
+
ms: number;
|
|
14
|
+
/** Offset from UTC in minutes, or null when the value has none. */
|
|
15
|
+
zone: number | null;
|
|
16
|
+
}
|
|
17
|
+
export declare function parseDate(v: string): DateParts | null;
|
|
18
|
+
export declare function parseTime(v: string): TimeParts | null;
|
|
19
|
+
interface Decimal {
|
|
20
|
+
negative: boolean;
|
|
21
|
+
/** Digits of the integer part, without leading zeros ('' for zero). */
|
|
22
|
+
int: string;
|
|
23
|
+
/** Digits of the fraction. */
|
|
24
|
+
frac: string;
|
|
25
|
+
}
|
|
26
|
+
/** Parses a canonical number (pdf.js's toString, or a datasets value) into exact digits. */
|
|
27
|
+
export declare function parseDecimal(v: string): Decimal | null;
|
|
28
|
+
export interface FormatArgs {
|
|
29
|
+
picture: string;
|
|
30
|
+
value: string;
|
|
31
|
+
kind: ValueKind;
|
|
32
|
+
/** The ambient locale name of the field. */
|
|
33
|
+
locale: string;
|
|
34
|
+
locales: Locales;
|
|
35
|
+
}
|
|
36
|
+
/** Formats a canonical value with a display picture. Null when the picture cannot format it. */
|
|
37
|
+
export declare function formatPicture(a: FormatArgs): string | null;
|
|
38
|
+
/** Parses a date written with a simple data picture (D, DD, M, MM, MMM, MMMM, YY, YYYY and literals) to canonical. */
|
|
39
|
+
export declare function parseWithDatePicture(picture: string, value: string, loc: LocaleInfo): string | null;
|
|
40
|
+
export { CATEGORIES };
|