Có gì 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ợ và xác thực chữ ký kỹ thuật số trên hình ảnh (nhúng steganography 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 kích thước chiều rộng/chieu cao một cách rõ ràng. |
| SIGNATURENET‑5479 | ✨ Tính năng | Hỗ trợ xoay cho hình ả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 chữ ký dựa trên hình ảnh. |
| SIGNATURENET‑5500 | ⚡ Cải tiến | Tối ưu truy vấn kiểu LINQ cho việc tìm kiếm và 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ý kỹ thuật 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ã hóa 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 ngoại lệ type‑initializer của GeneratePreview() cho các tệp DOC trên Linux. |
Dưới đây là hướng dẫn kỹ thuật ngắn gọn về những thay đổi có tác động lớn nhất.
1. Chữ ký kỹ thuật số trên hình ảnh (steganography)
- Chữ ký được ẩn trong các bit ít quan trọng nhất của các 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 hình ả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 hình ả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 toàn bộ 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 cho việc tạo bản xem trước, loại bỏ những bất nhất của chế độ “tự động‑định kích thướ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ợ xoay 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 đã xoay.
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) giờ có thể được sử dụng như chữ ký hình ảnh, chèn, xem trước và xác thực tương tự 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ý kỹ thuật số
PdfDigitalSignatureAppearance hiện hỗ trợ ảnh phủ lên và màu nền mà không che khuất ảnh. Kiểm soát lớp thông qua 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 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 ngăn xếp cryptographic. Chỉ còn các thuật toán hiện đại, được NIST phê duyệt, 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
Các thao tác search và verify chữ ký hiện 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 khi xem trước DOC trên Linux
GeneratePreview() không còn phát sinh TypeInitializerException khi xử lý các tệp Microsoft Word (.doc) trên Linux, khôi phục lại chức năng xem trước đ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 wrapper Python‑via‑.NET.
Tài nguyên
- Ghi chú phát hành đầy đủ: (link to the official release notes page, if available)
- 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à chú ý đến blog chính thức để nhận các mẹo về hiệu năng và hướng dẫn thực tiễn.