Những cập nhật mới trong GroupDocs.Signature cho Python 26.1 (Tháng 1 2026)
| ID | Thể loại | Tóm tắt |
|---|---|---|
| SIGNATURENET‑5528 | ✨ Tính năng | Hỗ trợ chữ ký số hình ảnh và xác thực (nhúng steganographic LSB cho PNG & JPG). |
| SIGNATURENET‑5445 | ✨ Tính năng | Kết xuất thích ứng cho bản xem trước chữ ký Barcode và QR Code – kiểm soát độ rộng/chiều cao một cách rõ ràng. |
| SIGNATURENET‑5479 | ✨ Tính năng | Hỗ trợ quay cho ảnh bản xem trước Barcode và QR Code. |
| SIGNATURENET‑5478 | ✨ Tính năng | Thêm xử lý định dạng ảnh APNG và TGA cho các chữ ký dựa trên ảnh. |
| SIGNATURENET‑5500 | ⚡ Cải tiến | Tối ưu truy vấn kiểu LINQ cho việc tìm kiếm & xác thực chữ ký (lọc bằng predicate). |
| SIGNATURENET‑5480 | ⚡ Cải tiến | Hỗ trợ nền trong suốt cho bản xem trước Barcode/QR. |
| SIGNATURENET‑5477 | ⚡ Cải tiến | Hỗ trợ ảnh phủ lên cho chữ ký số có màu nền (cờ foreground‑image). |
| SIGNATURENET‑5422 | ⚡ Cải tiến | Loại bỏ các thuật toán mã hoá không an toàn (RC2, DES, TripleDES và các chế độ AES yếu). |
| SIGNATURENET‑5555 | 🐞 Sửa lỗi | Sửa lỗi GeneratePreview() ném ngoại lệ TypeInitializerException cho tập tin DOC trên Linux. |
Dưới đây là phần walkthrough kỹ thuật ngắn gọn của các thay đổi có tác động lớn nhất.
1. Chữ ký số hình ảnh (steaganography)
- Các chữ ký được ẩn trong các bit ít quan trọng (least‑significant bits) của pixel PNG/JPG.
- Được bảo vệ bằng mật khẩu, tương thích với stream và hoạt động với bất kỳ kích thước ảnh nào ≥ 8 × 8 px.
Ký một ảnh
import groupdocs.signature as gs
import groupdocs.signature.options as gso
input_file = "image.png"
output_file = "signed_image.png"
password = "MySecurePassword123"
# Sign the image
with gs.Signature(input_file) as signature:
sign_options = gso.ImageDigitalSignOptions()
sign_options.password = password
sign_result = signature.sign(output_file, sign_options)
if sign_result.succeeded and len(sign_result.succeeded) > 0:
print("Image signed successfully!")
print(f"Signatures added: {len(sign_result.succeeded)}")
Xác minh một ảnh đã ký
import groupdocs.signature as gs
import groupdocs.signature.options as gso
signed_file = "signed_image.png"
password = "MySecurePassword123"
with gs.Signature(signed_file) as signature:
verify_options = gso.ImageDigitalVerifyOptions()
verify_options.password = password
verify_options.detection_threshold_percent = 75 # optional 0‑100%
verify_result = signature.verify(verify_options)
if verify_result.is_valid:
print("Digital signature is valid!")
print(f"Verified signatures: {len(verify_result.succeeded)}")
else:
print("Digital signature is invalid or not found.")
Xác thực nâng cao (trích xuất đầy đủ dữ liệu)
with gs.Signature("signed_image.png") as signature:
verify_options = gso.ImageDigitalVerifyOptions()
verify_options.password = "MySecurePassword123"
verify_options.use_full_data_extraction = True
verify_options.detection_threshold_percent = 85
verify_result = signature.verify(verify_options)
if verify_result.is_valid and verify_options.detected_probability is not None:
print(f"Signature detected with {verify_options.detected_probability}% probability")
2. Kết xuất thích ứng cho bản xem trước Barcode & QR Code
Các nhà phát triển giờ có thể chỉ định chính xác width và height khi tạo bản xem trước, loại bỏ các bất nhất “tự động‑đổi‑kích‑cỡ” trước đây.
import groupdocs.signature as gs
import groupdocs.signature.options as gso
import uuid
# QR code options
qr_sign_options = gso.QrCodeSignOptions("GROUP DOCS", gs.QrCodeTypes.QR)
qr_sign_options.width = 250
qr_sign_options.height = 270
qr_sign_options.fore_color = gs.Color.red
qr_sign_options.code_text_alignment = gs.CodeTextAlignment.BELOW
qr_sign_options.text = "GROUP DOCS"
# Preview generation
preview_options = gso.PreviewSignatureOptions(
qr_sign_options,
create_signature_stream, # user‑provided delegate
release_signature_stream # user‑provided delegate
)
preview_options.signature_id = str(uuid.uuid4())
preview_options.preview_format = gso.PreviewSignatureOptions.PreviewFormats.PNG
gs.Signature.generate_signature_preview(preview_options)
3. Hỗ trợ quay cho bản xem trước Barcode & QR
Đặt rotation_angle (độ) trên các tùy chọn barcode/QR để tạo bản xem trước đã quay.
import groupdocs.signature as gs
import groupdocs.signature.options as gso
import uuid
barcode_sign_options = gso.BarcodeSignOptions("GROUP DOCS", gs.BarcodeTypes.MaxiCode)
barcode_sign_options.width = 400
barcode_sign_options.height = 400
barcode_sign_options.fore_color = gs.Color.red
barcode_sign_options.code_text_alignment = gs.CodeTextAlignment.BELOW
barcode_sign_options.text = "GROUP DOCS"
barcode_sign_options.rotation_angle = 45 # rotate 45°
preview_options = gso.PreviewSignatureOptions(
barcode_sign_options,
create_signature_stream,
release_signature_stream
)
preview_options.signature_id = str(uuid.uuid4())
preview_options.preview_format = gso.PreviewSignatureOptions.PreviewFormats.PNG
gs.Signature.generate_signature_preview(preview_options)
4. Hỗ trợ định dạng ảnh mới – APNG & TGA
Các tệp APNG (PNG động) và TGA (Targa) hiện có thể được sử dụng như chữ ký hình ảnh, chèn, xem trước và xác thực giống như PNG/JPG.
5. Nền trong suốt cho bản xem trước Barcode/QR
Đặt thuộc tính transparency (0 – 1) trên các tùy chọn barcode/QR để tạo bản xem trước với nền trong suốt.
barcode_sign_options = gso.BarcodeSignOptions("GROUP DOCS", gs.BarcodeTypes.Codabar)
barcode_sign_options.width = 400
barcode_sign_options.height = 400
barcode_sign_options.fore_color = gs.Color.red
barcode_sign_options.code_text_alignment = gs.CodeTextAlignment.BELOW
barcode_sign_options.text = "GROUP DOCS"
barcode_sign_options.transparency = 0.5 # 50 % transparent background
preview_options = gso.PreviewSignatureOptions(
barcode_sign_options,
create_signature_stream,
release_signature_stream
)
preview_options.signature_id = str(uuid.uuid4())
preview_options.preview_format = gso.PreviewSignatureOptions.PreviewFormats.PNG
gs.Signature.generate_signature_preview(preview_options)
6. Hỗ trợ ảnh phủ lên cho chữ ký số
PdfDigitalSignatureAppearance giờ sẽ tôn trọng cả ảnh phủ lên và màu nền mà không làm ẩn ảnh. Điều khiển lớp bằng SignatureCustomAppearance.IsForegroundImage.
import groupdocs.signature as gs
import groupdocs.signature.options as gso
signature_image_path = "signature.png"
certificate_path = "JohnSmithCertificate.pfx"
input_pdf = "SampleDocument.pdf"
output_pdf = "SignedDocument.pdf"
with gs.Signature(input_pdf) as signature:
sign_options = gso.DigitalSignOptions(certificate_path)
sign_options.password = "1234567890"
sign_options.reason = "Document approval"
sign_options.contact = "John Smith"
sign_options.location = "Head Office"
# Visible signature placement
sign_options.visible = True
sign_options.left = 350
sign_options.top = 100
sign_options.width = 200
sign_options.height = 70
sign_options.image_file_path = signature_image_path
appearance = gso.PdfDigitalSignatureAppearance()
appearance.foreground = gs.Color.from_argb(50, gs.Color.brown)
appearance.font_family_name = "Times New Roman"
appearance.font_size = 12
appearance.background = gs.Color.from_argb(50, gs.Color.light_gray)
appearance.is_foreground_image = True # image on top of text
sign_options.appearance = appearance
sign_result = signature.sign(output_pdf, sign_options)
print(f"\nDocument signed successfully with {len(sign_result.succeeded)} signature(s).")
print(f"Signed file saved at: {output_pdf}")
7. Cứng nhắc bảo mật – loại bỏ các thuật toán không an toàn
RC2, DES, TripleDES và các chế độ AES yếu đã bị loại bỏ khỏi stack mật mã. Chỉ còn các thuật toán hiện đại, được NIST chấp nhận, nâng cao mức bảo mật mặc định của tài liệu đã ký.
8. Tối ưu truy vấn kiểu LINQ
search và verify của chữ ký giờ chấp nhận hàm predicate để lọc chữ ký trước các bước xử lý nặng. Điều này giảm tiêu thụ bộ nhớ và tăng tốc các thao tác batch.
Tìm kiếm với predicate
import groupdocs.signature as gs
import groupdocs.signature.options as gso
import groupdocs.signature.domain as gsd
with gs.Signature("document.pdf") as signature:
search_options = [gso.TextSearchOptions()]
# Keep only text signatures that contain the word "Approved"
result = signature.search(search_options,
lambda sig: isinstance(sig, gsd.TextSignature) and "Approved" in sig.text)
for sig in result.signatures:
print(f"Found: {sig.text}")
Xác thực với predicate
with gs.Signature("signed_document.pdf") as signature:
verify_options = gso.TextVerifyOptions("John Smith")
# Verify only signatures on page 1
result = signature.verify(verify_options,
lambda sig: sig.page_number == 1)
print(f"Found {len(result)} verified signatures on page 1")
9. Sửa lỗi treo preview DOC trên Linux
GeneratePreview() không còn ném TypeInitializerException khi xử lý tệp Microsoft Word (.doc) trên Linux, khôi phục lại chức năng preview đa nền tảng.
Hướng dẫn nâng cấp
pip install --upgrade groupdocs-signature-net
Lưu ý: Tên gói
groupdocs-signature-netđược dùng cho lớp bao Python‑via‑.NET.
Tài nguyên
- Ghi chú phát hành đầy đủ: (liên kết tới trang ghi chú phát hành chính thức, nếu có)
- Tài liệu: https://docs.groupdocs.com/signature/python/
- Cộng đồng & Hỗ trợ: https://forum.groupdocs.com/c/signature/10
Hãy theo dõi các bản phát hành sắp tới và để mắt tới blog chính thức để nhận các mẹo tối ưu hiệu năng và hướng dẫn thực tiễn.