mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-09-11 20:47:56 +03:00
Fix PDF format of attachment creation and modification dates
Fix #2064.
This commit is contained in:
parent
f85a09eb10
commit
586998ea8d
@ -348,8 +348,8 @@ class Attachment:
|
||||
modified = datetime.fromtimestamp(getmtime(filename))
|
||||
else:
|
||||
modified = datetime.now()
|
||||
self.created = created.strftime('D:%Y%m%d%H%M%SZ')
|
||||
self.modified = modified.strftime('D:%Y%m%d%H%M%SZ')
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
@ -312,14 +312,16 @@ def write_pdf_attachment(pdf, attachment, compress):
|
||||
if not mime_type:
|
||||
mime_type = 'application/octet-stream'
|
||||
|
||||
creation = pydyf.String(attachment.created.strftime('D:%Y%m%d%H%M%SZ'))
|
||||
mod = pydyf.String(attachment.modified.strftime('D:%Y%m%d%H%M%SZ'))
|
||||
file_extra = pydyf.Dictionary({
|
||||
'Type': '/EmbeddedFile',
|
||||
'Subtype': f'/{mime_type.replace("/", "#2f")}',
|
||||
'Params': pydyf.Dictionary({
|
||||
'CheckSum': f'<{attachment.md5}>',
|
||||
'Size': uncompressed_length,
|
||||
'CreationDate': attachment.created,
|
||||
'ModDate': attachment.modified,
|
||||
'CreationDate': creation,
|
||||
'ModDate': mod,
|
||||
})
|
||||
})
|
||||
file_stream = pydyf.Stream([stream], file_extra, compress=compress)
|
||||
|
Loading…
Reference in New Issue
Block a user