@syzlm/ofdparser 0.0.1
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/.babelrc +14 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +18 -0
- package/.prettierrc.json +9 -0
- package/dist/OFD.d.ts +8 -0
- package/dist/Pages.d.ts +7 -0
- package/dist/RootDocumnet.d.ts +1 -0
- package/dist/bundle.cjs.js +64123 -0
- package/dist/bundle.esm.js +64115 -0
- package/dist/bundle.iife.js +14743 -0
- package/dist/bundle.umd.js +64045 -0
- package/dist/constant/index.d.ts +7 -0
- package/dist/constant.d.ts +6 -0
- package/dist/core/ofd-core/Annotations/AnnotationsXml.d.ts +16 -0
- package/dist/core/ofd-core/Asn.1Utils.d.ts +47 -0
- package/dist/core/ofd-core/Documents/DocumentResXml.d.ts +15 -0
- package/dist/core/ofd-core/Documents/DocumnetXml.d.ts +25 -0
- package/dist/core/ofd-core/Documents/PublicResXml.d.ts +15 -0
- package/dist/core/ofd-core/OFDElement.d.ts +232 -0
- package/dist/core/ofd-core/Ofd/OFDXml.d.ts +19 -0
- package/dist/core/ofd-core/Pages/PageXml.d.ts +20 -0
- package/dist/core/ofd-core/Signatures/Signatures.d.ts +20 -0
- package/dist/core/ofd-core/TemplatePages/TemplatePages.d.ts +20 -0
- package/dist/core/ofd-core/constant.d.ts +29 -0
- package/dist/core/ofd-core/utils.d.ts +21 -0
- package/dist/dicom/dicom.d.ts +15 -0
- package/dist/dicom/index.d.ts +1 -0
- package/dist/errors/ErrorHandle.d.ts +6 -0
- package/dist/errors/ErrorMsg.d.ts +16 -0
- package/dist/errors/FetchErrors.d.ts +4 -0
- package/dist/errors/MimeError.d.ts +4 -0
- package/dist/errors/OFDErrors.d.ts +4 -0
- package/dist/errors/UnzipErrors.d.ts +4 -0
- package/dist/errors/XmlErrors.d.ts +4 -0
- package/dist/errors/error-msg.d.ts +9 -0
- package/dist/es.d.ts +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/lib/ParseFile.d.ts +7 -0
- package/dist/lib/UnitCoversion.d.ts +31 -0
- package/dist/lib/asn1/Asn.1.d.ts +34 -0
- package/dist/lib/asn1/Stream.d.ts +27 -0
- package/dist/lib/asn1/asn1.d.ts +4 -0
- package/dist/lib/asn1/base64.d.ts +4 -0
- package/dist/lib/asn1/hex.d.ts +5 -0
- package/dist/lib/asn1/index.d.ts +5 -0
- package/dist/lib/asn1/int10.d.ts +34 -0
- package/dist/lib/asn1/oids.d.ts +2 -0
- package/dist/lib/asn1/string-cut.d.ts +2 -0
- package/dist/lib/decode-html.d.ts +7 -0
- package/dist/lib/fetch.d.ts +17 -0
- package/dist/lib/is-element.d.ts +5 -0
- package/dist/lib/load-files.d.ts +3 -0
- package/dist/lib/load-opentype.d.ts +34 -0
- package/dist/lib/load-script.d.ts +1 -0
- package/dist/lib/mime.d.ts +8 -0
- package/dist/lib/read-buffer.d.ts +2 -0
- package/dist/lib/toFixeds.d.ts +7 -0
- package/dist/libs/Asn.1Utils.d.ts +47 -0
- package/dist/libs/asn1/Asn.1.d.ts +34 -0
- package/dist/libs/asn1/Stream.d.ts +27 -0
- package/dist/libs/asn1/asn1.d.ts +4 -0
- package/dist/libs/asn1/base64.d.ts +4 -0
- package/dist/libs/asn1/hex.d.ts +5 -0
- package/dist/libs/asn1/index.d.ts +5 -0
- package/dist/libs/asn1/int10.d.ts +34 -0
- package/dist/libs/asn1/oids.d.ts +2 -0
- package/dist/libs/asn1/string-cut.d.ts +2 -0
- package/dist/libs/decode-html.d.ts +7 -0
- package/dist/libs/fetch.d.ts +17 -0
- package/dist/libs/mime.d.ts +8 -0
- package/dist/libs/ofdArray.d.ts +10 -0
- package/dist/libs/ofdImageObject.d.ts +9 -0
- package/dist/libs/ofdLayer.d.ts +3 -0
- package/dist/libs/ofdName.d.ts +17 -0
- package/dist/libs/ofdPathObject.d.ts +11 -0
- package/dist/libs/ofdTextObject.d.ts +6 -0
- package/dist/libs/parseAnnotation.d.ts +5 -0
- package/dist/libs/parseColor.d.ts +5 -0
- package/dist/libs/parsePageArea.d.ts +17 -0
- package/dist/libs/parser-elements.d.ts +8 -0
- package/dist/libs/parserElements.d.ts +8 -0
- package/dist/libs/pipeExtensions.d.ts +4 -0
- package/dist/libs/read-buffer.d.ts +2 -0
- package/dist/main.d.ts +15 -0
- package/dist/ofd/ConverterDpi.d.ts +16 -0
- package/dist/ofd/index.d.ts +1 -0
- package/dist/ofd/ofd-utils.d.ts +137 -0
- package/dist/ofd/ofd.d.ts +35 -0
- package/dist/ofd/parse-ofd.d.ts +18 -0
- package/dist/ofd/render.d.ts +18 -0
- package/dist/ofd/svg-image.d.ts +12 -0
- package/dist/ofd/svg-path.d.ts +5 -0
- package/dist/ofd/svg-text.d.ts +8 -0
- package/dist/ofd.parse.d.ts +6 -0
- package/dist/ofd.xml.d.ts +1 -0
- package/dist/ofdParse.d.ts +6 -0
- package/dist/pipe/annotations.d.ts +13 -0
- package/dist/pipe/attachments.d.ts +13 -0
- package/dist/pipe/commonData.d.ts +18 -0
- package/dist/pipe/customTags.d.ts +14 -0
- package/dist/pipe/extensions.d.ts +14 -0
- package/dist/pipe/output.d.ts +7 -0
- package/dist/pipe/pages.d.ts +13 -0
- package/dist/pipe/permissions.d.ts +14 -0
- package/dist/pipe/pipeline.d.ts +63 -0
- package/dist/pipe/startPipe.d.ts +11 -0
- package/dist/xml/index.d.ts +2 -0
- package/dist/xml/render.d.ts +6 -0
- package/dist/xml/xml.d.ts +18 -0
- package/package.json +47 -0
- package/public/index.html +75 -0
- package/public/opentype.min.js +2 -0
- package/rollup.config.dev.mjs +47 -0
- package/rollup.config.mjs +70 -0
- package/src/constant/index.ts +13 -0
- package/src/core/ofd-core/Annotations/Annotation.km +206 -0
- package/src/core/ofd-core/Annotations/Annotations.km +59 -0
- package/src/core/ofd-core/Annotations/Annotations.md +13 -0
- package/src/core/ofd-core/Annotations/AnnotationsXml.ts +114 -0
- package/src/core/ofd-core/Asn.1Utils.ts +225 -0
- package/src/core/ofd-core/Documents/DocumentResXml.ts +55 -0
- package/src/core/ofd-core/Documents/Documnet.km +862 -0
- package/src/core/ofd-core/Documents/DocumnetXml.ts +118 -0
- package/src/core/ofd-core/Documents/Documnets.md +296 -0
- package/src/core/ofd-core/Documents/PublicResXml.ts +63 -0
- package/src/core/ofd-core/Documents//345/233/276/345/261/202/346/270/262/346/237/223/351/241/272/345/272/217.png +0 -0
- package/src/core/ofd-core/Documents//350/241/25022/347/272/277/346/235/241/350/277/236/346/216/245/346/240/267/345/274/217.png +0 -0
- package/src/core/ofd-core/Documents//350/241/25023/347/272/277/346/235/241/350/231/232/347/272/277/346/240/267/345/274/217.png +0 -0
- package/src/core/ofd-core/Documents//350/241/25023/347/273/223/345/220/210/347/202/271/351/225/277/345/272/246.png +0 -0
- package/src/core/ofd-core/Documents//350/241/25024/347/272/277/346/235/241/347/253/257/347/202/271/346/240/267/345/274/217.png +0 -0
- package/src/core/ofd-core/Documents//351/241/265/350/276/271/347/225/214/345/261/202/346/254/241/347/273/223/346/236/204.png +0 -0
- package/src/core/ofd-core/OFDElement.ts +724 -0
- package/src/core/ofd-core/Ofd/CT_DocInfo.km +197 -0
- package/src/core/ofd-core/Ofd/OFD.km +114 -0
- package/src/core/ofd-core/Ofd/OFD.md +99 -0
- package/src/core/ofd-core/Ofd/OFDXml.ts +69 -0
- package/src/core/ofd-core/Pages/PAGE.md +40 -0
- package/src/core/ofd-core/Pages/PageXml.ts +59 -0
- package/src/core/ofd-core/Signatures/Signature.km +308 -0
- package/src/core/ofd-core/Signatures/Signature.md +21 -0
- package/src/core/ofd-core/Signatures/Signatures.km +315 -0
- package/src/core/ofd-core/Signatures/Signatures.md +24 -0
- package/src/core/ofd-core/Signatures/Signatures.ts +247 -0
- package/src/core/ofd-core/TemplatePages/TemplatePages.ts +56 -0
- package/src/core/ofd-core/asn.md +60 -0
- package/src/core/ofd-core/constant.ts +35 -0
- package/src/core/ofd-core/index.d.ts +867 -0
- package/src/core/ofd-core/utils.ts +86 -0
- package/src/dicom/dicom.ts +42 -0
- package/src/dicom/index.ts +1 -0
- package/src/errors/ErrorHandle.ts +14 -0
- package/src/errors/FetchErrors.ts +8 -0
- package/src/errors/MimeError.ts +9 -0
- package/src/errors/OFDErrors.ts +11 -0
- package/src/errors/UnzipErrors.ts +9 -0
- package/src/errors/XmlErrors.ts +11 -0
- package/src/errors/error-msg.ts +17 -0
- package/src/es.ts +3 -0
- package/src/global.d.ts +7 -0
- package/src/index.ts +7 -0
- package/src/lib/ParseFile.ts +12 -0
- package/src/lib/README.md +69 -0
- package/src/lib/UnitCoversion.ts +55 -0
- package/src/lib/asn1/Asn.1.ts +284 -0
- package/src/lib/asn1/README.md +1 -0
- package/src/lib/asn1/Stream.ts +314 -0
- package/src/lib/asn1/asn1.ts +120 -0
- package/src/lib/asn1/base64.ts +97 -0
- package/src/lib/asn1/hex.ts +60 -0
- package/src/lib/asn1/index.ts +5 -0
- package/src/lib/asn1/int10.ts +103 -0
- package/src/lib/asn1/oids.ts +6164 -0
- package/src/lib/asn1/string-cut.ts +8 -0
- package/src/lib/decode-html.ts +37 -0
- package/src/lib/fetch.ts +70 -0
- package/src/lib/is-element.ts +13 -0
- package/src/lib/jbig/README.md +1 -0
- package/src/lib/jbig/arithmetic_decoder.js +184 -0
- package/src/lib/jbig/base_stream.js +117 -0
- package/src/lib/jbig/ccitt.js +1068 -0
- package/src/lib/jbig/ccitt_stream.js +60 -0
- package/src/lib/jbig/compatibility.js +108 -0
- package/src/lib/jbig/core_utils.js +591 -0
- package/src/lib/jbig/decode_stream.js +184 -0
- package/src/lib/jbig/is_node.js +28 -0
- package/src/lib/jbig/jbig2.js +2582 -0
- package/src/lib/jbig/jbig2_stream.js +78 -0
- package/src/lib/jbig/primitives.js +441 -0
- package/src/lib/jbig/stream.js +101 -0
- package/src/lib/jbig/util.js +1231 -0
- package/src/lib/load-files.ts +26 -0
- package/src/lib/load-opentype.ts +161 -0
- package/src/lib/load-script.ts +33 -0
- package/src/lib/mime.ts +97 -0
- package/src/lib/read-buffer.ts +19 -0
- package/src/lib/toFixeds.ts +56 -0
- package/src/ofd/ConverterDpi.ts +35 -0
- package/src/ofd/OFD.md +38 -0
- package/src/ofd/TODO.md +10 -0
- package/src/ofd/index.ts +1 -0
- package/src/ofd/ofd-utils.ts +627 -0
- package/src/ofd/ofd.demo.md +12 -0
- package/src/ofd/ofd.ts +200 -0
- package/src/ofd/ofdxml.km +162 -0
- package/src/ofd/parse-ofd.ts +103 -0
- package/src/ofd/render.ts +393 -0
- package/src/ofd/svg-image.ts +318 -0
- package/src/ofd/svg-path.ts +283 -0
- package/src/ofd/svg-text.ts +272 -0
- package/src/xml/index.ts +3 -0
- package/src/xml/render.ts +171 -0
- package/src/xml/xml.ts +136 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": {
|
|
3
|
+
"data": {
|
|
4
|
+
"id": "cum73g0v1q00",
|
|
5
|
+
"created": 1691399536098,
|
|
6
|
+
"text": "Annot"
|
|
7
|
+
},
|
|
8
|
+
"children": [
|
|
9
|
+
{
|
|
10
|
+
"data": {
|
|
11
|
+
"id": "cum73ladkw80",
|
|
12
|
+
"created": 1691399547557,
|
|
13
|
+
"text": "attributues"
|
|
14
|
+
},
|
|
15
|
+
"children": [
|
|
16
|
+
{
|
|
17
|
+
"data": {
|
|
18
|
+
"id": "cum73ujvfug0",
|
|
19
|
+
"created": 1691399567722,
|
|
20
|
+
"text": "ID"
|
|
21
|
+
},
|
|
22
|
+
"children": []
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"data": {
|
|
26
|
+
"id": "cum73xmdxjk0",
|
|
27
|
+
"created": 1691399574405,
|
|
28
|
+
"text": "Type"
|
|
29
|
+
},
|
|
30
|
+
"children": []
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"data": {
|
|
34
|
+
"id": "cum740u5wdc0",
|
|
35
|
+
"created": 1691399581405,
|
|
36
|
+
"text": "Creator"
|
|
37
|
+
},
|
|
38
|
+
"children": []
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"data": {
|
|
42
|
+
"id": "cum747h98s00",
|
|
43
|
+
"created": 1691399595862,
|
|
44
|
+
"text": "LastModDate"
|
|
45
|
+
},
|
|
46
|
+
"children": []
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"data": {
|
|
50
|
+
"id": "cum74fjdm5c0",
|
|
51
|
+
"created": 1691399613405,
|
|
52
|
+
"text": "Visible"
|
|
53
|
+
},
|
|
54
|
+
"children": []
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"data": {
|
|
58
|
+
"id": "cum74jlipuo0",
|
|
59
|
+
"created": 1691399622241,
|
|
60
|
+
"text": "Subtype"
|
|
61
|
+
},
|
|
62
|
+
"children": []
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"data": {
|
|
66
|
+
"id": "cum74p56vkw0",
|
|
67
|
+
"created": 1691399634315,
|
|
68
|
+
"text": "Print"
|
|
69
|
+
},
|
|
70
|
+
"children": []
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"data": {
|
|
74
|
+
"id": "cum74tcrb5c0",
|
|
75
|
+
"created": 1691399643479,
|
|
76
|
+
"text": "NoZoom"
|
|
77
|
+
},
|
|
78
|
+
"children": []
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"data": {
|
|
82
|
+
"id": "cum74x64dlk0",
|
|
83
|
+
"created": 1691399651785,
|
|
84
|
+
"text": "NoRotate"
|
|
85
|
+
},
|
|
86
|
+
"children": []
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"data": {
|
|
90
|
+
"id": "cum752uassw0",
|
|
91
|
+
"created": 1691399664131,
|
|
92
|
+
"text": "ReadOnly"
|
|
93
|
+
},
|
|
94
|
+
"children": []
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"data": {
|
|
100
|
+
"id": "cum75akg4jk0",
|
|
101
|
+
"created": 1691399680950,
|
|
102
|
+
"text": "elements"
|
|
103
|
+
},
|
|
104
|
+
"children": [
|
|
105
|
+
{
|
|
106
|
+
"data": {
|
|
107
|
+
"id": "cum75iqtss00",
|
|
108
|
+
"created": 1691399698750,
|
|
109
|
+
"text": "Remark"
|
|
110
|
+
},
|
|
111
|
+
"children": []
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"data": {
|
|
115
|
+
"id": "cum75pckij40",
|
|
116
|
+
"created": 1691399713125,
|
|
117
|
+
"text": "Parameters"
|
|
118
|
+
},
|
|
119
|
+
"children": [
|
|
120
|
+
{
|
|
121
|
+
"data": {
|
|
122
|
+
"id": "cum76d6v2fk0",
|
|
123
|
+
"created": 1691399765023,
|
|
124
|
+
"text": "attributes"
|
|
125
|
+
},
|
|
126
|
+
"children": [
|
|
127
|
+
{
|
|
128
|
+
"data": {
|
|
129
|
+
"id": "cum76x1c4go0",
|
|
130
|
+
"created": 1691399808224,
|
|
131
|
+
"text": "Name"
|
|
132
|
+
},
|
|
133
|
+
"children": []
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"data": {
|
|
139
|
+
"id": "cum774cz1ts0",
|
|
140
|
+
"created": 1691399824165,
|
|
141
|
+
"text": "elements"
|
|
142
|
+
},
|
|
143
|
+
"children": [
|
|
144
|
+
{
|
|
145
|
+
"data": {
|
|
146
|
+
"id": "cum77eyggu00",
|
|
147
|
+
"created": 1691399847232,
|
|
148
|
+
"text": "text"
|
|
149
|
+
},
|
|
150
|
+
"children": []
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"data": {
|
|
158
|
+
"id": "cum7616mmw80",
|
|
159
|
+
"created": 1691399738887,
|
|
160
|
+
"text": "Appearance"
|
|
161
|
+
},
|
|
162
|
+
"children": [
|
|
163
|
+
{
|
|
164
|
+
"data": {
|
|
165
|
+
"id": "cum77ko10g00",
|
|
166
|
+
"created": 1691399859662,
|
|
167
|
+
"text": "attributes"
|
|
168
|
+
},
|
|
169
|
+
"children": [
|
|
170
|
+
{
|
|
171
|
+
"data": {
|
|
172
|
+
"id": "cum77tjn5mg0",
|
|
173
|
+
"created": 1691399878988,
|
|
174
|
+
"text": "Boundary"
|
|
175
|
+
},
|
|
176
|
+
"children": []
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"data": {
|
|
182
|
+
"id": "cum77po4u1s0",
|
|
183
|
+
"created": 1691399870553,
|
|
184
|
+
"text": "elements"
|
|
185
|
+
},
|
|
186
|
+
"children": [
|
|
187
|
+
{
|
|
188
|
+
"data": {
|
|
189
|
+
"id": "cum78el09pc0",
|
|
190
|
+
"created": 1691399924783,
|
|
191
|
+
"text": "PageBlock"
|
|
192
|
+
},
|
|
193
|
+
"children": []
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
"template": "default",
|
|
204
|
+
"theme": "fresh-blue",
|
|
205
|
+
"version": "1.4.43"
|
|
206
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": {
|
|
3
|
+
"data": {
|
|
4
|
+
"id": "cum6zoovzt40",
|
|
5
|
+
"created": 1691399241508,
|
|
6
|
+
"text": "Annotations"
|
|
7
|
+
},
|
|
8
|
+
"children": [
|
|
9
|
+
{
|
|
10
|
+
"data": {
|
|
11
|
+
"id": "cum707xtkl40",
|
|
12
|
+
"created": 1691399283407,
|
|
13
|
+
"text": "Page"
|
|
14
|
+
},
|
|
15
|
+
"children": [
|
|
16
|
+
{
|
|
17
|
+
"data": {
|
|
18
|
+
"id": "cum70hwta480",
|
|
19
|
+
"created": 1691399305114,
|
|
20
|
+
"text": "attribute"
|
|
21
|
+
},
|
|
22
|
+
"children": [
|
|
23
|
+
{
|
|
24
|
+
"data": {
|
|
25
|
+
"id": "cum712lw0a80",
|
|
26
|
+
"created": 1691399350166,
|
|
27
|
+
"text": "PageID",
|
|
28
|
+
"note": "引用注释所在页面的标识"
|
|
29
|
+
},
|
|
30
|
+
"children": []
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"data": {
|
|
36
|
+
"id": "cum71e482x40",
|
|
37
|
+
"created": 1691399375219,
|
|
38
|
+
"text": "elements"
|
|
39
|
+
},
|
|
40
|
+
"children": [
|
|
41
|
+
{
|
|
42
|
+
"data": {
|
|
43
|
+
"id": "cum71iwtn880",
|
|
44
|
+
"created": 1691399385656,
|
|
45
|
+
"text": "FIleLoc",
|
|
46
|
+
"note": "指向包内的分页注释文件\n"
|
|
47
|
+
},
|
|
48
|
+
"children": []
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"template": "default",
|
|
57
|
+
"theme": "fresh-blue",
|
|
58
|
+
"version": "1.4.43"
|
|
59
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import VaildOFDError from 'src/errors/OFDErrors';
|
|
2
|
+
import { Element } from 'xml-js';
|
|
3
|
+
import { replacePathPriex } from '../utils';
|
|
4
|
+
import OFDElement from '../OFDElement';
|
|
5
|
+
// import OFDXMl from '../ofd/OFDXml';
|
|
6
|
+
// import { OFD_PATH } from '../constant';
|
|
7
|
+
|
|
8
|
+
class AnnotationsXml extends OFDElement {
|
|
9
|
+
/**
|
|
10
|
+
* PublicRes.xml文件
|
|
11
|
+
* @date 2022/7/27 - 09:41:22
|
|
12
|
+
*
|
|
13
|
+
* @type {Element[]}
|
|
14
|
+
*/
|
|
15
|
+
static fileName: string;
|
|
16
|
+
constructor(documnetResElements: Element[]) {
|
|
17
|
+
super();
|
|
18
|
+
this.setAnnotationsXml(documnetResElements);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
formatAnnotationXml(annotFile: Element, annot: any) {
|
|
22
|
+
if (annotFile?.elements && annotFile.elements[0]) {
|
|
23
|
+
annotFile.elements[0].elements?.forEach(item => {
|
|
24
|
+
const { attributes, elements } = item;
|
|
25
|
+
Object.assign(annot, { ...attributes });
|
|
26
|
+
if (elements?.length) {
|
|
27
|
+
const appearanceInfo = elements.find(
|
|
28
|
+
cItem => cItem.name === this.OFDCommonQName('Appearance')
|
|
29
|
+
);
|
|
30
|
+
if (appearanceInfo && appearanceInfo.elements) {
|
|
31
|
+
const result = { ...appearanceInfo.attributes };
|
|
32
|
+
const block = this.getPageBlock(appearanceInfo.elements);
|
|
33
|
+
Object.assign(result, { PageBlock: block });
|
|
34
|
+
if (annot['Appearance'] === undefined) {
|
|
35
|
+
annot['Appearance'] = [];
|
|
36
|
+
}
|
|
37
|
+
annot['Appearance'].push({ ...result });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
setRootPath(annotationsXml: Element, relativePath: string) {
|
|
45
|
+
if (annotationsXml?.elements) {
|
|
46
|
+
annotationsXml.elements.forEach(item => {
|
|
47
|
+
if (item?.name) {
|
|
48
|
+
const { name, elements } = item;
|
|
49
|
+
const priexPath = relativePath.substring(
|
|
50
|
+
0,
|
|
51
|
+
relativePath.lastIndexOf('/') + 1
|
|
52
|
+
);
|
|
53
|
+
if (name === this.OFDCommonQName('Annotations')) {
|
|
54
|
+
// 设置资源路径
|
|
55
|
+
if (elements?.length) {
|
|
56
|
+
elements.forEach(cItem => {
|
|
57
|
+
const {
|
|
58
|
+
name: cName,
|
|
59
|
+
attributes: cAttributes,
|
|
60
|
+
elements: cElements
|
|
61
|
+
} = cItem;
|
|
62
|
+
if (cName === this.OFDCommonQName('Page')) {
|
|
63
|
+
if (
|
|
64
|
+
cElements?.length === 1 &&
|
|
65
|
+
cElements[0].name === this.OFDCommonQName('FileLoc')
|
|
66
|
+
) {
|
|
67
|
+
const { text: cText } = cElements[0].elements?.[0] || {};
|
|
68
|
+
const rootPath = replacePathPriex(
|
|
69
|
+
OFDElement.STLoc,
|
|
70
|
+
`${priexPath}${cText || ''}`
|
|
71
|
+
);
|
|
72
|
+
OFDElement.AnnotationsRoot = rootPath;
|
|
73
|
+
if (cAttributes?.PageID) {
|
|
74
|
+
const pageInfo = OFDElement.Pages?.find(
|
|
75
|
+
pItem => cAttributes.PageID === pItem.PageID
|
|
76
|
+
);
|
|
77
|
+
if (pageInfo) {
|
|
78
|
+
// annation写入pages
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
pageInfo['Annot'] = { FileLoc: cText as string };
|
|
81
|
+
|
|
82
|
+
this.formatAnnotationXml(
|
|
83
|
+
OFDElement.OFDElements[rootPath],
|
|
84
|
+
pageInfo['Annot']
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
setAnnotationsXml(annotationsElements: Element[]): void {
|
|
99
|
+
if (annotationsElements?.length && annotationsElements.length === 1) {
|
|
100
|
+
const annotationsXmlPath = replacePathPriex(
|
|
101
|
+
OFDElement.STLoc,
|
|
102
|
+
`${annotationsElements[0].text}`
|
|
103
|
+
);
|
|
104
|
+
this.setRootPath(
|
|
105
|
+
OFDElement.OFDElements[annotationsXmlPath],
|
|
106
|
+
annotationsElements[0].text as string
|
|
107
|
+
);
|
|
108
|
+
} else {
|
|
109
|
+
throw new VaildOFDError(9999, '获取Annotations失败');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export default AnnotationsXml;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Asn1 } from '../../lib/asn1';
|
|
2
|
+
import { ASN1Tag } from '../../lib/asn1/Asn.1';
|
|
3
|
+
import Stream from '../../lib/asn1/Stream';
|
|
4
|
+
|
|
5
|
+
interface ASN1 {
|
|
6
|
+
tagLen: number;
|
|
7
|
+
tag: ASN1Tag;
|
|
8
|
+
stream: Stream;
|
|
9
|
+
header: number;
|
|
10
|
+
length: number;
|
|
11
|
+
value: string;
|
|
12
|
+
tagName: string;
|
|
13
|
+
sub: ASN1[] | undefined | null;
|
|
14
|
+
}
|
|
15
|
+
// asn.1 节点标识相当于 xml element
|
|
16
|
+
export const STATIC_TAG_SEQUENCE = 'SEQUENCE';
|
|
17
|
+
// asn.1 节点标识相当于 xml element
|
|
18
|
+
|
|
19
|
+
export const STATIC_TAG_OCTET_STRING = 'OCTET_STRING';
|
|
20
|
+
|
|
21
|
+
export const STATIC_TAG_IA5STRING = 'IA5String';
|
|
22
|
+
|
|
23
|
+
//INTEGER
|
|
24
|
+
export const STATIC_TAG_INTEGER = 'INTEGER';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* utf8 string 转Uint8Array
|
|
28
|
+
* @param str
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export function toUint8Arr(str: string) {
|
|
32
|
+
const buffer = [];
|
|
33
|
+
for (let i of str) {
|
|
34
|
+
const _code = i.charCodeAt(0);
|
|
35
|
+
if (_code < 0x80) {
|
|
36
|
+
buffer.push(_code);
|
|
37
|
+
} else if (_code < 0x800) {
|
|
38
|
+
buffer.push(0xc0 + (_code >> 6));
|
|
39
|
+
buffer.push(0x80 + (_code & 0x3f));
|
|
40
|
+
} else if (_code < 0x10000) {
|
|
41
|
+
buffer.push(0xe0 + (_code >> 12));
|
|
42
|
+
buffer.push(0x80 + ((_code >> 6) & 0x3f));
|
|
43
|
+
buffer.push(0x80 + (_code & 0x3f));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return Uint8Array.from(buffer);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function loopAsn1(sub: ASN1[]): ASN1[] | undefined {
|
|
50
|
+
if (sub?.length) {
|
|
51
|
+
return sub.map(item => {
|
|
52
|
+
// const stream = new Stream(item.stream, item.stream.pos);
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
const tagName = item?.typeName.call(item, 8 * 80);
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
const val = item?.content.call(item, 8 * 80);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
tagLen: item.tagLen,
|
|
60
|
+
tag: item.tag,
|
|
61
|
+
stream: item.stream,
|
|
62
|
+
header: item.header,
|
|
63
|
+
length: item.length,
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
tagName: tagName,
|
|
66
|
+
value: val,
|
|
67
|
+
sub: item.sub ? loopAsn1(item.sub) : null
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
class Asn1Parse {
|
|
75
|
+
static asn1ESealHeader: ASN1;
|
|
76
|
+
static asn1ESealEsID: ASN1;
|
|
77
|
+
static asn1ESealPictureInfo: ASN1;
|
|
78
|
+
static asn1ESealExtDatas: ASN1;
|
|
79
|
+
static asn1ESealProperty: ASN1;
|
|
80
|
+
asn1: string;
|
|
81
|
+
static pricuteInfo: {
|
|
82
|
+
data: Uint8Array | null | string;
|
|
83
|
+
type: string;
|
|
84
|
+
width: string;
|
|
85
|
+
height: string;
|
|
86
|
+
} = {
|
|
87
|
+
data: null,
|
|
88
|
+
type: '',
|
|
89
|
+
width: '',
|
|
90
|
+
height: ''
|
|
91
|
+
};
|
|
92
|
+
constructor(str: string) {
|
|
93
|
+
this.asn1 = str;
|
|
94
|
+
this.init();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
init() {
|
|
98
|
+
try {
|
|
99
|
+
// 参考 [电子密码规范](http://c.gb688.cn/bzgk/gb/showGb?type=online&hcno=EBF1360C272E40E7A8B9B32ED0724AB1)
|
|
100
|
+
const asn1 = Asn1.decode(this.asn1, 0);
|
|
101
|
+
Asn1Parse.pricuteInfo = { data: null, type: '', width: '', height: '' };
|
|
102
|
+
// 平铺asn.1节点,获取每个节点tag name
|
|
103
|
+
const asnFlatArrays = [];
|
|
104
|
+
if (asn1?.sub) {
|
|
105
|
+
asnFlatArrays.push({
|
|
106
|
+
tagLen: asn1.tagLen,
|
|
107
|
+
tag: asn1.tag,
|
|
108
|
+
stream: asn1.stream,
|
|
109
|
+
header: asn1.header,
|
|
110
|
+
length: asn1.length,
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
tagName: asn1.typeName.call(asn1, 8 * 80),
|
|
113
|
+
sub: loopAsn1(asn1.sub as ASN1[])
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// 根据(电子签章规范)[http://c.gb688.cn/bzgk/gb/showGb?type=online&hcno=EBF1360C272E40E7A8B9B32ED0724AB1]获取签章
|
|
117
|
+
/**
|
|
118
|
+
* 第一级:
|
|
119
|
+
* 印章信息、制章者证书、签名算法标识、签名值
|
|
120
|
+
*/
|
|
121
|
+
if (asnFlatArrays[0]?.sub?.length) {
|
|
122
|
+
const childSub = asnFlatArrays[0].sub;
|
|
123
|
+
// 印章信息
|
|
124
|
+
const eSealInfo = childSub[0];
|
|
125
|
+
// 制章者证书
|
|
126
|
+
// const cert = childSub[1];
|
|
127
|
+
//签名算法标识
|
|
128
|
+
// const signAlgID = childSub[2];
|
|
129
|
+
// 签名值
|
|
130
|
+
// const signedValue = childSub[3];
|
|
131
|
+
|
|
132
|
+
// 印章信息解析
|
|
133
|
+
if (eSealInfo?.sub?.length) {
|
|
134
|
+
for (let i = 0; i < eSealInfo.sub.length; i++) {
|
|
135
|
+
const { tagName, sub } = eSealInfo.sub[i];
|
|
136
|
+
if (tagName === STATIC_TAG_SEQUENCE) {
|
|
137
|
+
// 实际印章信息包含非SEQUENCE节点类似 attribute,需要进一步遍历SEQUENCE节点
|
|
138
|
+
if (sub?.length) {
|
|
139
|
+
for (let j = 0; j < sub.length; j++) {
|
|
140
|
+
const { tagName: cTagName, sub: cSub } = sub[j];
|
|
141
|
+
if (cTagName === STATIC_TAG_SEQUENCE && cSub?.length) {
|
|
142
|
+
/**
|
|
143
|
+
* 第二级:印章信息
|
|
144
|
+
* 印章头、印章标识、印章属性、印章图像数据、自定义数据
|
|
145
|
+
*/
|
|
146
|
+
const header = cSub[0];
|
|
147
|
+
const esID = cSub[1];
|
|
148
|
+
const property = cSub[2];
|
|
149
|
+
const pictureInfo = cSub[3];
|
|
150
|
+
const extDatas = cSub[4];
|
|
151
|
+
Asn1Parse.asn1ESealHeader = header;
|
|
152
|
+
Asn1Parse.asn1ESealEsID = esID;
|
|
153
|
+
Asn1Parse.asn1ESealProperty = property;
|
|
154
|
+
Asn1Parse.asn1ESealPictureInfo = pictureInfo;
|
|
155
|
+
Asn1Parse.asn1ESealExtDatas = extDatas;
|
|
156
|
+
this.parsePricuter(pictureInfo);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
// console.log(item);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// console.log(
|
|
167
|
+
// 'asnFlatArrays:',
|
|
168
|
+
// asnFlatArrays,
|
|
169
|
+
// signedValue,
|
|
170
|
+
// cert,
|
|
171
|
+
// signAlgID
|
|
172
|
+
// );
|
|
173
|
+
}
|
|
174
|
+
} catch (e) {
|
|
175
|
+
console.error('Cannot decode string. :', e);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
decodeUTCTime(str: string) {
|
|
179
|
+
let strs = str.replace('Unrecognized time: ', '');
|
|
180
|
+
// const UTC = strs.indexOf('Z') > 0;
|
|
181
|
+
strs = strs.replace('Z', '');
|
|
182
|
+
strs = strs.substring(0, 1) < '5' ? '20' + strs : '19' + strs;
|
|
183
|
+
return strs;
|
|
184
|
+
}
|
|
185
|
+
parsePricuter(ans: ASN1) {
|
|
186
|
+
if (ans?.sub?.length) {
|
|
187
|
+
// 图片类型
|
|
188
|
+
Asn1Parse.pricuteInfo.type = ans?.sub[0].value;
|
|
189
|
+
// 图片数据
|
|
190
|
+
if (ans.sub[1].stream) {
|
|
191
|
+
// 获取 Uint8Array
|
|
192
|
+
const unit8arrs = ans.sub[1].stream.enc as Uint8Array;
|
|
193
|
+
const bytes = unit8arrs.subarray(
|
|
194
|
+
ans.sub[1].stream.pos + ans.sub[1].header,
|
|
195
|
+
ans.sub[1].stream.pos + ans.sub[1].header + ans.sub[1].length
|
|
196
|
+
);
|
|
197
|
+
// console.log(toUint8Arr(hex));
|
|
198
|
+
Asn1Parse.pricuteInfo.data = bytes;
|
|
199
|
+
}
|
|
200
|
+
// 图片宽度
|
|
201
|
+
Asn1Parse.pricuteInfo.width = ans?.sub[2].value;
|
|
202
|
+
// 图片高度
|
|
203
|
+
Asn1Parse.pricuteInfo.height = ans?.sub[3].value;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
getPicture(): {
|
|
208
|
+
type: string;
|
|
209
|
+
data: Uint8Array;
|
|
210
|
+
width: string;
|
|
211
|
+
height: string;
|
|
212
|
+
} | null {
|
|
213
|
+
if (Asn1Parse.pricuteInfo && Asn1Parse.pricuteInfo.data) {
|
|
214
|
+
return Asn1Parse.pricuteInfo as {
|
|
215
|
+
type: string;
|
|
216
|
+
data: Uint8Array;
|
|
217
|
+
width: string;
|
|
218
|
+
height: string;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export default Asn1Parse;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import VaildOFDError from 'src/errors/OFDErrors';
|
|
2
|
+
import { Element } from 'xml-js';
|
|
3
|
+
import { replacePathPriex } from '../utils';
|
|
4
|
+
import OFDElement from '../OFDElement';
|
|
5
|
+
// import OFDXMl from '../ofd/OFDXml';
|
|
6
|
+
// import { OFD_PATH } from '../constant';
|
|
7
|
+
|
|
8
|
+
class DocumentResXml extends OFDElement {
|
|
9
|
+
/**
|
|
10
|
+
* DocumentRes xml文件,
|
|
11
|
+
* @date 2022/7/27 - 09:41:22
|
|
12
|
+
*
|
|
13
|
+
* @type {Element[]}
|
|
14
|
+
*/
|
|
15
|
+
static fileName: string;
|
|
16
|
+
constructor(documnetResElements: Element[]) {
|
|
17
|
+
super();
|
|
18
|
+
this.setDocumnetResXml(documnetResElements);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
setRootPath(documnetResXml: Element) {
|
|
22
|
+
if (documnetResXml?.elements) {
|
|
23
|
+
documnetResXml.elements.forEach(item => {
|
|
24
|
+
if (item?.name) {
|
|
25
|
+
const { name, attributes, elements } = item;
|
|
26
|
+
// 设置资源路径
|
|
27
|
+
if (this.OFDCommonQName('Res') === name) {
|
|
28
|
+
const rootPath = `${OFDElement.STLoc}${String(attributes?.BaseLoc || '').replace(
|
|
29
|
+
/^\/Doc_0\/|^Doc_0\//,
|
|
30
|
+
'',
|
|
31
|
+
)}`;
|
|
32
|
+
OFDElement.DocumnetResRoot = rootPath;
|
|
33
|
+
if (elements && elements.length) {
|
|
34
|
+
this.setRes(elements, rootPath);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setDocumnetResXml(documnetResElements: Element[]): void {
|
|
43
|
+
if (documnetResElements?.length && documnetResElements.length === 1) {
|
|
44
|
+
const documentResXmlPath = replacePathPriex(
|
|
45
|
+
OFDElement.STLoc,
|
|
46
|
+
`${documnetResElements[0].text}`,
|
|
47
|
+
);
|
|
48
|
+
this.setRootPath(OFDElement.OFDElements[documentResXmlPath]);
|
|
49
|
+
} else {
|
|
50
|
+
throw new VaildOFDError(9999, '获取documentRes失败');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default DocumentResXml;
|