Open g-raffy opened 1 month ago
Here's what I found until now:
/Group
element)).Here's a test function that exhibits the bug:
def bug_shower_1(trigger_bug: bool):
src_pdf_file_path = Path('/home/graffy/private/melting-notes/partitions/scans/888-bug.pdf')
tmp_dir = Path('/home/graffy/private/dev/pymusco/tickets/ticket0008/tmp')
scanned_image_file_paths = []
with open(src_pdf_file_path, 'rb') as src_pdf_file:
pdf_reader = PyPDF2.PdfReader(src_pdf_file)
page_index = 0
for page in pdf_reader.pages:
print(f'============= page_index = {page_index}')
# image_file_path = extract_pdf_page_main_image(page, image_dir=tmp_dir, image_name=('page%03d' % page_index))
image_file_path = extract_pdf_page(page, image_dir=tmp_dir, image_name=f'page{page_index:03d}')
print(image_file_path)
# check_pdf_file(image_file_path)
scanned_image_file_paths.append(image_file_path)
page_index += 1
# stamp_descs = stamp_descs if stamp_descs is not None else []
orchestra = load_orchestra('/home/graffy/private/dev/pymusco/samples/harmony.orchestra')
piece = load_piece_description(Path('/home/graffy/private/melting-notes/partitions/scans/888-bug.desc'), orchestra)
dst_stub_pdf_file_path = Path('/home/graffy/private/dev/pymusco/tickets/ticket0008/stub.pdf')
toc = piece.scan_toc
if trigger_bug:
stamp_descs = piece.stamp_descs
else:
stamp_descs = []
images_to_pdf(StubContents(image_file_paths=scanned_image_file_paths, toc=toc, title='toto', stamp_descs=stamp_descs, page_info_line_y_pos=1.0), dst_stub_pdf_file_path)
# check_pdf_file(dst_stub_pdf_file_path)
dst_stub_copy_pdf_file_path = Path('/home/graffy/private/dev/pymusco/tickets/ticket0008/stub-copy.pdf')
duplicate_pdf_file_001(dst_stub_pdf_file_path, dst_stub_copy_pdf_file_path)
# check_pdf_file(dst_pdf_file_path)