main.py 1.0 KB
Newer Older
S
superyan 已提交
1
import streamlit as st
S
superyan 已提交
2
from PIL import Image
S
superyan 已提交
3

S
superyan 已提交
4 5
# Page Title
st.title("合同签字系统")
S
superyan 已提交
6

S
superyan 已提交
7 8
# Upload File
file_uploaded = st.file_uploader("上传你的合同文件", type=['pdf'])
S
superyan 已提交
9

S
superyan 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
if file_uploaded is not None:
    # Display Contract
    st.write("你的合同文件:")
    pdf_bytes = file_uploaded.read()
    st.write(pdf_bytes)
    
    # Contract Signature
    st.write("请在这里签字:")
    signature_canvas = st_canvas(
        fill_color='rgba(255, 165, 0, 0.3)',  # 颜色
        stroke_width=5,  # 笔画粗细
        stroke_color='rgb(255, 165, 0)',  # 笔画颜色
        background_color='white',  # 背景颜色
        height=200,  # 画布高度
        width=None,  # 画布宽度(默认为100%,可自适应)
        drawing_mode="freedraw",  # 笔画模式
        key="signature_canvas",
    )
    
    # Signature Save
    if st.button("保存签名"):
        image = Image.frombytes('RGB', signature_canvas.shape, signature_canvas.image_data)
        image.save("signature.png")
        st.write("签名已保存成功!")