-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toDataURL() export PNG correct,but svg is wrong #784
Labels
Comments
Works for me. If you can provide the code that doesn't work I can try to help. |
Hi,
Here is part of the code :
......
const ref = React.useRef();
const pad = React.useRef();
......
React.useEffect(() => {
// resize canvas to full size
ref.current.width = ref.current.parentElement.offsetWidth;
pad.current = new SignaturePad(ref.current);
}, []);
...
return (
<div style={{ height: "100%", display: "flex", flexDirection: "column" }}>
<InputGroup
leftIcon="search"
placeholder="搜索..."
onChange={handleChange}
onKeyPress={handleKeyPress}
style={{
marginBottom: "10px",
}}
/>
<TagCloud
onSelect={handleSelectChange}
tags = {tags}
defValue = {'热门短语'}
/>
<Button onClick={addText} style={{ width: '100%', marginBottom: '5px',marginTop: '5px', }} >添加文字内容</Button>
<div>
自由手绘:
<canvas
ref={ref}
style={{ border: '1px solid grey', borderRadius: '5px' }}
/>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<Button
onClick={() => {
pad.current.clear();
}}
>
清除
</Button>
<Button
onClick={() => {
const src = pad.current.toDataURL('image/svg+xml');
store.activePage.addElement({
type: 'svg',
x: (store.width-ref.current.width)/2,
y: (store.height-ref.current.height)/2,
width: ref.current.width,
height: ref.current.height,
src,
});
}}
>
添加
</Button>
</div>
</div>
.......
Here is the result :
zhucm
…------------------ 原始邮件 ------------------
发件人: "szimek/signature_pad" ***@***.***>;
发送时间: 2024年8月20日(星期二) 晚上10:17
***@***.***>;
***@***.******@***.***>;
主题: Re: [szimek/signature_pad] toDataURL() export PNG correct,but svg is wrong (Issue #784)
Works for me. If you can provide the code that doesn't work I can try to help.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Could be an issue with DPI see https://github.com/szimek/signature_pad#handling-high-dpi-screens |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When toDataURL('image/svg+xml') , it's only export part of image,some data lost
version 5.0.2
The text was updated successfully, but these errors were encountered: