@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,393 @@
|
|
|
1
|
+
import VaildOFDError from '../errors/OFDErrors';
|
|
2
|
+
import {
|
|
3
|
+
ResultData,
|
|
4
|
+
Page,
|
|
5
|
+
LayerPageBlock,
|
|
6
|
+
Signatures,
|
|
7
|
+
// Res
|
|
8
|
+
} from '../core/ofd-core/index.d';
|
|
9
|
+
// import ParseFile from '../lib/ParseFile';
|
|
10
|
+
import { parseColor, getDrawParam, setStyle, formatSTBox, pageZIndex } from './ofd-utils';
|
|
11
|
+
import ConverterDpi from './ConverterDpi';
|
|
12
|
+
import renderTextObject from './svg-text';
|
|
13
|
+
import renderPathObject from './svg-path';
|
|
14
|
+
import renderImageObject, { renderBitImage } from './svg-image';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 渲染OFD
|
|
18
|
+
* @param data OFD元数据
|
|
19
|
+
* @param zip 解压
|
|
20
|
+
* @param defaultWall 最大宽度
|
|
21
|
+
* @param isSeal 是否是签章渲染
|
|
22
|
+
*/
|
|
23
|
+
export const OFDRender = (data: ResultData, defaultWidth?: number, isSeal = false) => {
|
|
24
|
+
// 优化 当OFD文件不存在 PageArea,获取Pages最大的PhysicalBox
|
|
25
|
+
if (data.PageArea && !data.PageArea.PhysicalBox && !data.Pages) {
|
|
26
|
+
throw new VaildOFDError(9999, 'OFD 绘制区域坐标为空!');
|
|
27
|
+
}
|
|
28
|
+
if (!data.Pages || !data.Pages.length) {
|
|
29
|
+
throw new VaildOFDError(9999, 'OFD Pages为空,不绘制!');
|
|
30
|
+
}
|
|
31
|
+
const { PhysicalBox } = data.PageArea || { PhysicalBox: '' };
|
|
32
|
+
|
|
33
|
+
// 确定绘制区域
|
|
34
|
+
// const { width } = formatSTBox(PhysicalBox);
|
|
35
|
+
const div = document.createElement('div');
|
|
36
|
+
// 渲染签章
|
|
37
|
+
if (isSeal) {
|
|
38
|
+
setStyle(div, {
|
|
39
|
+
position: 'relative',
|
|
40
|
+
overflow: 'hidden',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// 非签章渲染
|
|
44
|
+
if (!isSeal) {
|
|
45
|
+
setStyle(div, {
|
|
46
|
+
position: 'relative',
|
|
47
|
+
overflow: 'hidden',
|
|
48
|
+
// 'min-width': `${width}px`,
|
|
49
|
+
// 'min-height': `${height}px`,
|
|
50
|
+
background: '#fff',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// const pageDivs: any[] = [];
|
|
55
|
+
let columnTop = 0;
|
|
56
|
+
let maxWidth = 0;
|
|
57
|
+
// 传入宽高容器限制,需要计算缩放比例
|
|
58
|
+
let scale = 1;
|
|
59
|
+
data.Pages.forEach(item => {
|
|
60
|
+
const { Area, Template, PageID } = item;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* 定义该页页面区域的大小和位置,仅对该页有效。该节点不出现时。
|
|
64
|
+
* 则使用模板页中的定义,如果模板页不存在或模板页中没有定义页面区域,
|
|
65
|
+
* 则使用文件CommonData中的定义
|
|
66
|
+
*/
|
|
67
|
+
if (!Area || !Area.PhysicalBox) {
|
|
68
|
+
// Page 未确定起点坐标不绘制
|
|
69
|
+
// 查找 Template
|
|
70
|
+
if ((!Template || !data?.Tpls || !data.Tpls[Template.TemplateID]) && !PhysicalBox) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// 根据规则查找 页面坐标
|
|
75
|
+
let PageBox = Area.PhysicalBox;
|
|
76
|
+
|
|
77
|
+
if (!PageBox && Template?.TemplateID && data.Tpls && data.Tpls[Template.TemplateID]) {
|
|
78
|
+
PageBox = data.Tpls[Template.TemplateID][0].Area.PhysicalBox;
|
|
79
|
+
}
|
|
80
|
+
if (!PageBox) {
|
|
81
|
+
PageBox = PhysicalBox;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const [, , wh] = PageBox.split(' ');
|
|
85
|
+
if (defaultWidth && wh) {
|
|
86
|
+
scale = Number((defaultWidth / Number(wh)).toFixed(1));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!isSeal) {
|
|
90
|
+
// 防止签章多次渲染变小
|
|
91
|
+
ConverterDpi.setInitScale(scale);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 设置缩放比例
|
|
95
|
+
ConverterDpi.setScale(scale, isSeal);
|
|
96
|
+
|
|
97
|
+
const {
|
|
98
|
+
left: pageLeft,
|
|
99
|
+
// top: pageTop,
|
|
100
|
+
width: pageWidth,
|
|
101
|
+
height: pageHeight,
|
|
102
|
+
} = formatSTBox(PageBox);
|
|
103
|
+
//
|
|
104
|
+
let {
|
|
105
|
+
width: physicalWidth,
|
|
106
|
+
// height: physicalHeight
|
|
107
|
+
} = formatSTBox(PhysicalBox);
|
|
108
|
+
|
|
109
|
+
const pageDiv = document.createElement('div');
|
|
110
|
+
// const pHeight = pageHeight > physicalHeight ? pageHeight : physicalHeight;
|
|
111
|
+
const pHeight = pageHeight;
|
|
112
|
+
const pWidth = pageWidth > physicalWidth ? pageWidth : physicalWidth;
|
|
113
|
+
setStyle(pageDiv, {
|
|
114
|
+
overflow: 'hidden',
|
|
115
|
+
position: 'absolute',
|
|
116
|
+
width: `${pWidth}px`,
|
|
117
|
+
top: `${columnTop}px`,
|
|
118
|
+
left: `${pageLeft}px`,
|
|
119
|
+
height: `${pHeight}px`,
|
|
120
|
+
});
|
|
121
|
+
columnTop += pHeight;
|
|
122
|
+
// 使用Page最大宽度
|
|
123
|
+
if (pWidth > maxWidth) {
|
|
124
|
+
maxWidth = pWidth;
|
|
125
|
+
div.style.width = `${maxWidth}px`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// page渲染
|
|
129
|
+
renderPage(item, data, pageDiv);
|
|
130
|
+
// 判断是否有签章并渲染
|
|
131
|
+
if (data.PageSignatures?.[PageID]) {
|
|
132
|
+
renderSignature(data.PageSignatures[PageID], pageDiv);
|
|
133
|
+
}
|
|
134
|
+
div.appendChild(pageDiv);
|
|
135
|
+
if (Template && Template.TemplateID) {
|
|
136
|
+
// 查找是否有背景
|
|
137
|
+
const ZOrder = String(Template.ZOrder || 'Background') as
|
|
138
|
+
| 'Background'
|
|
139
|
+
| 'Body'
|
|
140
|
+
| 'Foreground';
|
|
141
|
+
if (data.Tpls && data.Tpls[Template.TemplateID]) {
|
|
142
|
+
const TplsDivs = renderTplsPage(
|
|
143
|
+
data.Tpls[Template.TemplateID],
|
|
144
|
+
data,
|
|
145
|
+
pageZIndex[ZOrder] - 1,
|
|
146
|
+
) as HTMLElement[];
|
|
147
|
+
if (TplsDivs?.length) {
|
|
148
|
+
TplsDivs.forEach(divItem => {
|
|
149
|
+
pageDiv.appendChild(divItem);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
div.style.height = `${columnTop}px`;
|
|
156
|
+
|
|
157
|
+
return div;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 序列化绘制 Template pages
|
|
162
|
+
* @param pages
|
|
163
|
+
* @param data
|
|
164
|
+
* @param zIndex
|
|
165
|
+
* @param pageDivs
|
|
166
|
+
*/
|
|
167
|
+
export const renderTplsPage = (pages: Page[], data: ResultData, zIndex: number) => {
|
|
168
|
+
const result: any[] = [];
|
|
169
|
+
if (pages?.length) {
|
|
170
|
+
pages.forEach(item => {
|
|
171
|
+
const { Area } = item;
|
|
172
|
+
// if (!Area || !Area.PhysicalBox) {
|
|
173
|
+
// // Template Page 未确定起点坐标不绘制
|
|
174
|
+
// return;
|
|
175
|
+
// }
|
|
176
|
+
const {
|
|
177
|
+
left: tplLeft,
|
|
178
|
+
top: tplTop,
|
|
179
|
+
width: tplWidth,
|
|
180
|
+
height: tplHeight,
|
|
181
|
+
} = formatSTBox(Area.PhysicalBox);
|
|
182
|
+
const div = document.createElement('div');
|
|
183
|
+
|
|
184
|
+
setStyle(div, {
|
|
185
|
+
overflow: 'hidden',
|
|
186
|
+
position: 'absolute',
|
|
187
|
+
width: tplWidth ? `${tplWidth}px` : '100%',
|
|
188
|
+
top: `${tplTop}px`,
|
|
189
|
+
left: `${tplLeft}px`,
|
|
190
|
+
height: tplHeight ? `${tplHeight}px` : '100%',
|
|
191
|
+
'z-index': zIndex,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
renderPage(item, data, div);
|
|
195
|
+
result.push(div);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const renderPage = (page: Page, data: ResultData, content?: HTMLElement) => {
|
|
202
|
+
const { Area, Content: PageContent, Annot } = page;
|
|
203
|
+
const {
|
|
204
|
+
left: pageLeft,
|
|
205
|
+
top: pageTop,
|
|
206
|
+
width: pageWidth,
|
|
207
|
+
height: pageHeight,
|
|
208
|
+
} = formatSTBox(Area.PhysicalBox);
|
|
209
|
+
const pageContents: any[] = [];
|
|
210
|
+
|
|
211
|
+
let drawFillColor: string = '';
|
|
212
|
+
let drawStrokeColor: string = '';
|
|
213
|
+
let drawLineWidth: number = 2;
|
|
214
|
+
|
|
215
|
+
if (PageContent?.length) {
|
|
216
|
+
PageContent.forEach(item => {
|
|
217
|
+
const { Type = 'Body', PageBlock, DrawParam: drawParam } = item;
|
|
218
|
+
const ZIndex = pageZIndex[Type as 'Background' | 'Body' | 'Foreground'];
|
|
219
|
+
if (drawParam && getDrawParam(data.Res, drawParam)) {
|
|
220
|
+
let currentDrawParam = getDrawParam(data.Res, drawParam);
|
|
221
|
+
if (currentDrawParam?.Relative) {
|
|
222
|
+
currentDrawParam = getDrawParam(data.Res, currentDrawParam['Relative']);
|
|
223
|
+
}
|
|
224
|
+
if (currentDrawParam?.FillColor && currentDrawParam?.FillColor?.Value) {
|
|
225
|
+
drawFillColor = parseColor(currentDrawParam.FillColor['Value']);
|
|
226
|
+
}
|
|
227
|
+
if (currentDrawParam?.StrokeColor && currentDrawParam?.StrokeColor?.Value) {
|
|
228
|
+
drawStrokeColor = parseColor(currentDrawParam['StrokeColor']['Value']);
|
|
229
|
+
}
|
|
230
|
+
if (currentDrawParam?.LineWidth) {
|
|
231
|
+
drawLineWidth = Number(currentDrawParam?.LineWidth) > 0 ? 2 : 1;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (PageBlock?.length) {
|
|
235
|
+
const div = document.createElement('div');
|
|
236
|
+
|
|
237
|
+
setStyle(div, {
|
|
238
|
+
// overflow: 'hidden',
|
|
239
|
+
position: 'absolute',
|
|
240
|
+
width: pageWidth ? `${pageWidth}px` : '100%',
|
|
241
|
+
top: `${pageTop}px`,
|
|
242
|
+
left: `${pageLeft}px`,
|
|
243
|
+
height: pageHeight ? `${pageHeight}px` : '100%',
|
|
244
|
+
'z-index': ZIndex,
|
|
245
|
+
});
|
|
246
|
+
PageBlock.forEach(item => {
|
|
247
|
+
const { Type } = item;
|
|
248
|
+
|
|
249
|
+
if (Type === 'TextObject') {
|
|
250
|
+
renderTextObject(
|
|
251
|
+
item as LayerPageBlock & { [k: string]: unknown },
|
|
252
|
+
data,
|
|
253
|
+
div,
|
|
254
|
+
drawFillColor,
|
|
255
|
+
drawStrokeColor,
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
if (Type === 'PathObject') {
|
|
259
|
+
renderPathObject(
|
|
260
|
+
item as LayerPageBlock & { [k: string]: unknown },
|
|
261
|
+
data,
|
|
262
|
+
div,
|
|
263
|
+
drawLineWidth,
|
|
264
|
+
// 线条填充颜色去除,防止签章纯色
|
|
265
|
+
'',
|
|
266
|
+
drawStrokeColor,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
if (Type === 'ImageObject') {
|
|
270
|
+
renderImageObject(item as LayerPageBlock & { [k: string]: unknown }, data, div);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
if (content) {
|
|
274
|
+
// Tpls 插入节点
|
|
275
|
+
content.appendChild(div);
|
|
276
|
+
} else {
|
|
277
|
+
pageContents.push(div);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* 注释文件类型
|
|
284
|
+
* 标准文档 表62
|
|
285
|
+
* Watermark:水印
|
|
286
|
+
* Stamp:签章
|
|
287
|
+
*/
|
|
288
|
+
if (
|
|
289
|
+
Annot &&
|
|
290
|
+
(Annot.Subtype === 'Watermark' ||
|
|
291
|
+
Annot.Type === 'Watermark' ||
|
|
292
|
+
Annot.Subtype === 'Stamp' ||
|
|
293
|
+
Annot.Type === 'Stamp') &&
|
|
294
|
+
Annot.Appearance?.length
|
|
295
|
+
) {
|
|
296
|
+
Annot.Appearance.forEach(aItem => {
|
|
297
|
+
if (aItem.PageBlock?.length) {
|
|
298
|
+
const annotPageBlock = aItem.PageBlock as LayerPageBlock[];
|
|
299
|
+
const annotDiv = document.createElement('div');
|
|
300
|
+
const {
|
|
301
|
+
left: annotPageLeft,
|
|
302
|
+
top: annotPageTop,
|
|
303
|
+
width: annotPageWidth,
|
|
304
|
+
height: annotPageHeight,
|
|
305
|
+
} = formatSTBox(aItem.Boundary);
|
|
306
|
+
setStyle(annotDiv, {
|
|
307
|
+
overflow: 'hidden',
|
|
308
|
+
position: 'absolute',
|
|
309
|
+
width: annotPageWidth ? `${annotPageWidth}px` : '100%',
|
|
310
|
+
top: `${annotPageTop}px`,
|
|
311
|
+
left: `${annotPageLeft}px`,
|
|
312
|
+
height: annotPageHeight ? `${annotPageHeight}px` : '100%',
|
|
313
|
+
'z-index': pageZIndex[Annot.Type || Annot.Subtype || 'WatermarkAnnot'],
|
|
314
|
+
});
|
|
315
|
+
annotPageBlock.forEach(item => {
|
|
316
|
+
const { Type } = item;
|
|
317
|
+
if (Type === 'TextObject') {
|
|
318
|
+
renderTextObject(
|
|
319
|
+
item as LayerPageBlock & { [k: string]: unknown },
|
|
320
|
+
data,
|
|
321
|
+
annotDiv,
|
|
322
|
+
drawFillColor,
|
|
323
|
+
drawStrokeColor,
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
if (Type === 'PathObject') {
|
|
327
|
+
renderPathObject(
|
|
328
|
+
item as LayerPageBlock & { [k: string]: unknown },
|
|
329
|
+
data,
|
|
330
|
+
annotDiv,
|
|
331
|
+
drawLineWidth,
|
|
332
|
+
drawFillColor,
|
|
333
|
+
drawStrokeColor,
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
if (Type === 'ImageObject') {
|
|
337
|
+
renderImageObject(item as LayerPageBlock & { [k: string]: unknown }, data, annotDiv);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
if (content) {
|
|
341
|
+
content.appendChild(annotDiv);
|
|
342
|
+
} else {
|
|
343
|
+
pageContents.push(annotDiv);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
return pageContents;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* 格式化渲染签名
|
|
353
|
+
* @param signedInfo
|
|
354
|
+
* @param content
|
|
355
|
+
*/
|
|
356
|
+
const renderSignature = (signedInfo: Signatures[], content: HTMLElement) => {
|
|
357
|
+
// const div = document.createElement('div');
|
|
358
|
+
// setStyle(div, {
|
|
359
|
+
// overflow: 'hidden',
|
|
360
|
+
// position: 'absolute',
|
|
361
|
+
// width: '100%',
|
|
362
|
+
// top: 0,
|
|
363
|
+
// left: 0,
|
|
364
|
+
// height: '100%',
|
|
365
|
+
// 'z-index': 99
|
|
366
|
+
// });
|
|
367
|
+
signedInfo.forEach(item => {
|
|
368
|
+
const pictureInfo = item?.Signature?.SignedInfo?.Seal?.picture;
|
|
369
|
+
// 获取签章信息
|
|
370
|
+
if (pictureInfo && item?.Signature?.SignedInfo?.StampAnnot?.length) {
|
|
371
|
+
const StampAnnot = item.Signature.SignedInfo.StampAnnot;
|
|
372
|
+
StampAnnot.forEach(cItem => {
|
|
373
|
+
if (cItem?.Boundary) {
|
|
374
|
+
renderBitImage(
|
|
375
|
+
pictureInfo as {
|
|
376
|
+
type: string;
|
|
377
|
+
data: Uint8Array;
|
|
378
|
+
width: string;
|
|
379
|
+
height: string;
|
|
380
|
+
},
|
|
381
|
+
cItem,
|
|
382
|
+
content,
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
// if (content) {
|
|
390
|
+
// content.appendChild(div);
|
|
391
|
+
// }
|
|
392
|
+
// return div;
|
|
393
|
+
};
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// import { xml2js } from 'xml-js';
|
|
2
|
+
import JSZip from 'jszip';
|
|
3
|
+
import parseOfd from './parse-ofd';
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import { Jbig2Image } from '../lib/jbig/jbig2.js';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
ResultData,
|
|
9
|
+
LayerPageBlock,
|
|
10
|
+
StampAnnot
|
|
11
|
+
} from '../core/ofd-core/index.d';
|
|
12
|
+
import OFDErrors from '../errors/OFDErrors';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
formatSTBox,
|
|
16
|
+
getMultiMedia,
|
|
17
|
+
converterDpi,
|
|
18
|
+
setStyle,
|
|
19
|
+
drawBMPImage
|
|
20
|
+
} from './ofd-utils';
|
|
21
|
+
|
|
22
|
+
interface PictureInfo {
|
|
23
|
+
type: string;
|
|
24
|
+
data: Uint8Array;
|
|
25
|
+
width: string;
|
|
26
|
+
height: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* uint8array 转base64
|
|
31
|
+
* @param u8Arr
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
function uint8arrayToBase64(u8Arr: Uint8Array) {
|
|
35
|
+
let CHUNK_SIZE = 0x8000; //arbitrary number
|
|
36
|
+
let index = 0;
|
|
37
|
+
let length = u8Arr.length;
|
|
38
|
+
let result = '';
|
|
39
|
+
let slice;
|
|
40
|
+
while (index < length) {
|
|
41
|
+
slice = u8Arr.subarray(index, Math.min(index + CHUNK_SIZE, length));
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
result += String.fromCharCode.apply(null, slice);
|
|
44
|
+
index += CHUNK_SIZE;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return window.btoa(result);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const renderImageObject = async (
|
|
51
|
+
imageObject: LayerPageBlock & { [k: string]: any },
|
|
52
|
+
data: ResultData,
|
|
53
|
+
content: HTMLElement,
|
|
54
|
+
isStampAnnot?: boolean,
|
|
55
|
+
StampId?: string,
|
|
56
|
+
PageRef?: string,
|
|
57
|
+
compositeObjectCTM?: any
|
|
58
|
+
) => {
|
|
59
|
+
const { Boundary, ResourceID, CTM } = imageObject;
|
|
60
|
+
const media = getMultiMedia(data.Res, ResourceID);
|
|
61
|
+
let left = 0,
|
|
62
|
+
top = 0,
|
|
63
|
+
width = 0,
|
|
64
|
+
height = 0;
|
|
65
|
+
if (Boundary) {
|
|
66
|
+
let boundary = formatSTBox(Boundary);
|
|
67
|
+
left = boundary.left;
|
|
68
|
+
top = boundary.top;
|
|
69
|
+
width = boundary.width;
|
|
70
|
+
height = boundary.height;
|
|
71
|
+
}
|
|
72
|
+
if (media && media.Path) {
|
|
73
|
+
// 获取图片格式
|
|
74
|
+
let mime = 'jpeg';
|
|
75
|
+
mime = media.Path.replace(/.*\.(.*)$/, '$1');
|
|
76
|
+
if (/jb2|bmp|gbig2/i.test(mime)) {
|
|
77
|
+
renderBitImage(
|
|
78
|
+
{
|
|
79
|
+
type: mime,
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
data: data.OFDElements[media.Path],
|
|
82
|
+
width: String(width),
|
|
83
|
+
height: String(height)
|
|
84
|
+
},
|
|
85
|
+
imageObject,
|
|
86
|
+
content
|
|
87
|
+
);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const baseStr = data.OFDElements[media.Path] as string;
|
|
91
|
+
if (!baseStr) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const imgSrc = `data:image/${mime};base64,` + baseStr;
|
|
95
|
+
|
|
96
|
+
// const imgSrc = ParseFile.parseImageFromZip(media as { Path: string });
|
|
97
|
+
if (imgSrc) {
|
|
98
|
+
const domImg = new Image();
|
|
99
|
+
domImg.src = imgSrc;
|
|
100
|
+
domImg.onload = () => {
|
|
101
|
+
const svg = document.createElementNS(
|
|
102
|
+
'http://www.w3.org/2000/svg',
|
|
103
|
+
'svg'
|
|
104
|
+
);
|
|
105
|
+
const img = document.createElementNS(
|
|
106
|
+
'http://www.w3.org/2000/svg',
|
|
107
|
+
'image'
|
|
108
|
+
);
|
|
109
|
+
if (isStampAnnot) {
|
|
110
|
+
setStyle(svg, {
|
|
111
|
+
viewbox: `0 0 ${width} ${height}`,
|
|
112
|
+
name: 'seal_img_div',
|
|
113
|
+
'data-signature-id': StampId || '',
|
|
114
|
+
'data-page-ref': PageRef || ''
|
|
115
|
+
});
|
|
116
|
+
setStyle(img, {
|
|
117
|
+
preserveAspectRatio: 'none slice'
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
img.setAttribute('xlink:href', imgSrc);
|
|
122
|
+
img.href.baseVal = imgSrc;
|
|
123
|
+
|
|
124
|
+
img.setAttribute('width', `100%`);
|
|
125
|
+
|
|
126
|
+
let transform = '';
|
|
127
|
+
if (CTM) {
|
|
128
|
+
const [a, b, c, d, e, f] = CTM.split(' ').filter(Boolean);
|
|
129
|
+
if (a && b && c && d) {
|
|
130
|
+
const domWidth = converterDpi(a) / width;
|
|
131
|
+
|
|
132
|
+
transform = `matrix(${domWidth} ${converterDpi(b) / width} ${
|
|
133
|
+
converterDpi(c) / height
|
|
134
|
+
} ${
|
|
135
|
+
domImg.height < domImg.width
|
|
136
|
+
? converterDpi(d) / height
|
|
137
|
+
: domWidth / (domImg.width / domImg.height)
|
|
138
|
+
} ${converterDpi(e)} ${converterDpi(f)})`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (compositeObjectCTM) {
|
|
142
|
+
transform = `${transform} matrix(${compositeObjectCTM.a} ${
|
|
143
|
+
compositeObjectCTM.b
|
|
144
|
+
} ${compositeObjectCTM.c} ${compositeObjectCTM.d} ${converterDpi(
|
|
145
|
+
compositeObjectCTM.e
|
|
146
|
+
)} ${converterDpi(compositeObjectCTM.f)})`;
|
|
147
|
+
}
|
|
148
|
+
img.setAttribute('transform', transform);
|
|
149
|
+
|
|
150
|
+
svg.appendChild(img);
|
|
151
|
+
|
|
152
|
+
// if (clip) {
|
|
153
|
+
// clip = converterBox(clip);
|
|
154
|
+
// c = `clip: rect(${clip.y}px, ${clip.w + clip.x}px, ${
|
|
155
|
+
// clip.h + clip.y
|
|
156
|
+
// }px, ${clip.x}px)`;
|
|
157
|
+
// }
|
|
158
|
+
|
|
159
|
+
if (compositeObjectCTM) {
|
|
160
|
+
const a = compositeObjectCTM.a;
|
|
161
|
+
const b = compositeObjectCTM.b;
|
|
162
|
+
const c = compositeObjectCTM.c;
|
|
163
|
+
const d = compositeObjectCTM.d;
|
|
164
|
+
const sx =
|
|
165
|
+
a > 0
|
|
166
|
+
? Math.sign(a) * Math.sqrt(a * a + c * c)
|
|
167
|
+
: Math.sqrt(a * a + c * c);
|
|
168
|
+
const sy =
|
|
169
|
+
d > 0
|
|
170
|
+
? Math.sign(d) * Math.sqrt(b * b + d * d)
|
|
171
|
+
: Math.sqrt(b * b + d * d);
|
|
172
|
+
const angel = Math.atan2(-b, d);
|
|
173
|
+
if (!(angel == 0 && a != 0 && d == 1)) {
|
|
174
|
+
top *= sy;
|
|
175
|
+
left *= sx;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
svg.setAttribute(
|
|
179
|
+
'style',
|
|
180
|
+
`cursor: pointer; overflow: visible; position: absolute; left: ${left}px; top: ${top}px; width: ${width}px; height: ${height}px; `
|
|
181
|
+
);
|
|
182
|
+
if (content) {
|
|
183
|
+
content.appendChild(svg);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// return svg;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const renderBitImage = (
|
|
193
|
+
pictureInfo: PictureInfo,
|
|
194
|
+
Box: StampAnnot,
|
|
195
|
+
content: HTMLElement
|
|
196
|
+
) => {
|
|
197
|
+
if (!Box.Boundary) return;
|
|
198
|
+
const { type, data } = pictureInfo;
|
|
199
|
+
const {
|
|
200
|
+
left,
|
|
201
|
+
top,
|
|
202
|
+
width: boundaryWidth,
|
|
203
|
+
height: boundaryHeight
|
|
204
|
+
} = formatSTBox(Box.Boundary);
|
|
205
|
+
|
|
206
|
+
if (
|
|
207
|
+
data &&
|
|
208
|
+
(type.toLocaleLowerCase() === 'png' || /gif|png|jpeg|bmp|jpg/i.test(type))
|
|
209
|
+
) {
|
|
210
|
+
const img = document.createElement('img');
|
|
211
|
+
let imgSrc =
|
|
212
|
+
`data:image/${type.toLocaleLowerCase()};base64,` +
|
|
213
|
+
// @ts-ignore
|
|
214
|
+
uint8arrayToBase64(data);
|
|
215
|
+
if (type.toLocaleLowerCase() === 'bmp') {
|
|
216
|
+
// 使用canvas转换图片格式
|
|
217
|
+
drawBMPImage(imgSrc).then(r => {
|
|
218
|
+
if (r) {
|
|
219
|
+
setStyle(img, {
|
|
220
|
+
left: `${left}px`,
|
|
221
|
+
top: `${top}px`,
|
|
222
|
+
width: `${boundaryWidth}px`,
|
|
223
|
+
height: `${boundaryHeight}px`,
|
|
224
|
+
position: 'absolute',
|
|
225
|
+
'z-index': '9'
|
|
226
|
+
});
|
|
227
|
+
img.setAttribute('src', r);
|
|
228
|
+
content.appendChild(img);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
setStyle(img, {
|
|
236
|
+
left: `${left}px`,
|
|
237
|
+
top: `${top}px`,
|
|
238
|
+
width: `${boundaryWidth}px`,
|
|
239
|
+
height: `${boundaryHeight}px`,
|
|
240
|
+
position: 'absolute',
|
|
241
|
+
'z-index': '9'
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
img.setAttribute('src', imgSrc);
|
|
245
|
+
content.appendChild(img);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
// OFD格式签章
|
|
249
|
+
if (/ofd/i.test(type)) {
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
const baseStr = String.fromCharCode.apply(null, data);
|
|
252
|
+
const zip = new JSZip();
|
|
253
|
+
zip
|
|
254
|
+
.loadAsync(baseStr)
|
|
255
|
+
.then(r => {
|
|
256
|
+
const signedOfd = r as any;
|
|
257
|
+
if (signedOfd.files) {
|
|
258
|
+
const wh = pictureInfo.width;
|
|
259
|
+
parseOfd(signedOfd.files, zip, Number(wh), undefined, true).then(
|
|
260
|
+
res => {
|
|
261
|
+
const div = document.createElement('div');
|
|
262
|
+
setStyle(div, {
|
|
263
|
+
left: `${left}px`,
|
|
264
|
+
top: `${top}px`,
|
|
265
|
+
width: `${boundaryWidth}px`,
|
|
266
|
+
height: `${boundaryHeight}px`,
|
|
267
|
+
position: 'absolute',
|
|
268
|
+
overflow: 'hidden',
|
|
269
|
+
'z-index': '9'
|
|
270
|
+
});
|
|
271
|
+
// 清空 container 防止xml重复渲染
|
|
272
|
+
div.innerHTML = '';
|
|
273
|
+
div.appendChild(res as HTMLElement);
|
|
274
|
+
if (content) {
|
|
275
|
+
content.appendChild(div);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
} else {
|
|
280
|
+
console.error('渲染OFD类型签章错误!!');
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
.catch(err => new OFDErrors(500, err.message || 'OFD解析失败'));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (data && (/gbig2/i.test(type) || /jb2/i.test(type))) {
|
|
287
|
+
let jbig2 = new Jbig2Image();
|
|
288
|
+
|
|
289
|
+
const imgData = jbig2.parse(data);
|
|
290
|
+
if (imgData) {
|
|
291
|
+
const arr = new Uint8ClampedArray(4 * jbig2.width * jbig2.height);
|
|
292
|
+
for (let i = 0; i < imgData.length; i++) {
|
|
293
|
+
arr[4 * i] = imgData[i];
|
|
294
|
+
arr[4 * i + 1] = imgData[i];
|
|
295
|
+
arr[4 * i + 2] = imgData[i];
|
|
296
|
+
arr[4 * i + 3] = 255;
|
|
297
|
+
}
|
|
298
|
+
let bitImageData = new ImageData(arr, jbig2.width, jbig2.height);
|
|
299
|
+
const devRatio = window.devicePixelRatio || 1;
|
|
300
|
+
|
|
301
|
+
const canvas = document.createElement('canvas');
|
|
302
|
+
canvas.width = jbig2.width * devRatio;
|
|
303
|
+
canvas.height = jbig2.height * devRatio;
|
|
304
|
+
const context = canvas.getContext('2d') as CanvasRenderingContext2D;
|
|
305
|
+
|
|
306
|
+
context.putImageData(bitImageData, 0, 0, 0, 0, jbig2.width, jbig2.height);
|
|
307
|
+
canvas.setAttribute(
|
|
308
|
+
'style',
|
|
309
|
+
`left: ${left}px; top: ${top}px; width: ${boundaryWidth}px; height: ${boundaryHeight}px;`
|
|
310
|
+
);
|
|
311
|
+
canvas.style.position = 'absolute';
|
|
312
|
+
content.appendChild(canvas);
|
|
313
|
+
return canvas;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export default renderImageObject;
|