aspose-words / Aspose.Words-for-Python-via-.NET

Aspose.Words for Python via .NET examples and showcases
MIT License
105 stars 22 forks source link

sign date error #6

Closed zhongsdjn closed 2 years ago

zhongsdjn commented 2 years ago

你好! 在使用Python3.7-python3.9测试对word签名的时候 均出现日期比实际时间later 8小时的情况 请问怎么办?

hi! when use aspose.words to sign a word ,but sign date incorrect !later 8 hours. Is it a bug? what should I do ? Thanks~

AlexNosk commented 2 years ago

@zhongsdjn The problem might occur because the document is signed on the PC with different time zone. You can control signing date by specifying it explicitly. For example see the following code:

cert_holder = aw.digitalsignatures.CertificateHolder.create(MY_DIR + "morzal.pfx", "aw")

sign_options = aw.digitalsignatures.SignOptions()
sign_options.sign_time =  datetime(2021, 12, 2, 10, 0, 0)

aw.digitalsignatures.DigitalSignatureUtil.sign(MY_DIR + "Digitally signed.docx", ARTIFACTS_DIR + "Document.signed.docx", cert_holder, sign_options)
zhongsdjn commented 2 years ago

@AlexNosk Thanks! I use sign_options.sign_time = datetime.datetime.now() - datetime.timedelta(hours=8) to solve the problem!