db-pkpass

Convert Deutsche Bahn PDF tickets to PKPass
git clone https://git.ce9e.org/db-pkpass.git

commit
4a425800b23a83653d6bf862999ccd59f9cf8f17
parent
d2199a7e6616613233783954e614ad48bc0b4914
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2025-05-30 15:01
refactor: iterate over pdf pages

Diffstat

M db_pkpass.py 8 ++++----

1 files changed, 4 insertions, 4 deletions


diff --git a/db_pkpass.py b/db_pkpass.py

@@ -61,15 +61,15 @@ def dump_pkpass(files: dict[str, bytes]) -> bytes:
   61    61 
   62    62 
   63    63 def pdf_iter_text_lines(pdf):
   64    -1     for i in range(len(pdf)):
   65    -1         text = pdf.get_page_text(i)
   -1    64     for page in pdf:
   -1    65         text = page.get_text()
   66    66         yield from text.split('\n')
   67    67 
   68    68 
   69    69 def extract_barcodes(pdf):
   70    70     barcodes = []
   71    -1     for i in range(len(pdf)):
   72    -1         for xref in pdf.get_page_images(i):
   -1    71     for page in pdf:
   -1    72         for xref in page.get_images():
   73    73             img_data = pdf.extract_image(xref[0])
   74    74             arr = numpy.frombuffer(img_data['image'], numpy.uint8)
   75    75             img = cv2.imdecode(arr, cv2.IMREAD_COLOR)