1
0
Fork 0

Fix format of PDF and XMP timezone offsets

The way to specify timezone offsets differs between the PDF and XMP
specs, so hardcode the UTC offset instead of using `%z`. This also
avoids the possibility of embedding the more granular timezones
supported by the datetime module but that are unsupported by either PDF
or XMP formats.
Patrick McCarty 1 year ago
parent 9c3753ed2b
commit 512478ac4e

@ -723,7 +723,7 @@ class pdfdoc(object):
def datetime_to_pdfdate(dt):
dt_utc = dt.astimezone(tz=timezone.utc)
return dt_utc.strftime("%Y%m%d%H%M%S%z")
return dt_utc.strftime("%Y%m%d%H%M%S+00'00'")
for k in ["Title", "Author", "Creator", "Producer", "Subject"]:
v = locals()[k.lower()]
@ -754,7 +754,7 @@ class pdfdoc(object):
def datetime_to_xmpdate(dt):
dt_utc = dt.astimezone(tz=timezone.utc)
return dt_utc.strftime("%Y-%m-%dT%H:%M:%S%z")
return dt_utc.strftime("%Y-%m-%dT%H:%M:%S+00:00")
self.xmp = b"""<?xpacket begin='\xef\xbb\xbf' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'>

Loading…
Cancel
Save