Added support for 'Hermes Paketschein'

This commit is contained in:
fleaz 2024-10-20 14:24:36 +02:00
parent ca219e56c3
commit ce057bd4b4
3 changed files with 49 additions and 2 deletions

View file

@ -26,3 +26,27 @@ def convert_dhl(id):
with open(f"./downloads/{id}.pdf", "wb") as fh:
writer.write(fh)
def convert_hermes(id):
with open(f"./uploads/{id}.pdf", "rb") as fh:
reader = PdfReader(fh)
writer = PdfWriter()
numPages = len(reader.pages)
if numPages != 1:
exit(1)
#page = reader.pages[0].rotate(90)
page = reader.pages[0]
left = 30
bottom = 452
right = 564
# calculate last value to get a 3:2 rectangle
top = bottom+((right-left)/3)*2
page.mediabox = RectangleObject((left, bottom,right,top))
writer.add_page(page)
with open(f"./downloads/{id}.pdf", "wb") as fh:
writer.write(fh)