首页 > 问答 > 正文
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{signatureURL ? (
<可拖动签名
url={签名URL}
onCancel={() =>; {
setSignatureURL(空);
}}
onSet={async()=>; {
const { 原始高度, 原始宽度 } = 页面详细信息;
常量尺度 =
原始宽度 / documentRef.current.clientWidth;
常量 y =
documentRef.current.clientHeight -
(位置.y -
位置.offsetY +
64 -
documentRef.current.offsetTop);
常量 x =
位置.x -
160 -
位置.offsetX -
documentRef.current.offsetLeft;
// 相对于实际文档大小的新 XY
常量新Y =
(y * 原始高度) / documentRef.current.clientHeight;
常量新X =
(x * 原始宽度) / documentRef.current.clientWidth;
const pdfDoc = 等待 PDFDocument.load(pdf);
const 页面 = pdfDoc.getPages();
const 第一页 = 页数[页数];
const pngImage = 等待 pdfDoc.embedPng(signatureURL);
const pngDims = pngImage.scale(scale * 0.3);
第一页.drawImage(pngImage, {
x:新X,
y:新Y,
宽度:pngDims.width,
高度:pngDims.height,
});
如果(自动日期){
第一页.drawText(
`电子签名:${dayjs().format(
“日/月/年 à HH:mm:ss”
)}`,
{
y:新Y - 10,
尺寸:14 * 比例,
颜色:RGB(0.074,0.545,0.262),
}
);
const pdfBytes = 等待 pdfDoc.save();
const blob = new Blob([newUint8Array(pdfBytes)]);
const blob =
new
Blob([newUint8Array(pdfBytes)]);
const URL = 等待 blobToURL(blob);
设置Pdf(网址);
设置位置(空);
onEnd={设置位置}
>>
) : 无效的}</pre>
<p>谢谢</p>
<p>我将onClick更改为onTouchtart,我更改了按钮位置,我使用了另一个CSS库。</p>
P粉3279030452023-08-19 10:15:22
尝试添加onTouchStart事件,并将按钮更改为div组件,并将其样式设置为按钮样式