winziprint: update progress more often
This commit is contained in:
@ -19,7 +19,7 @@ def convert(input_files: list[str], output_files: str, encoding: str = None, pro
|
||||
page_nums = []
|
||||
tmp_file_names = []
|
||||
|
||||
steps = len(input_files) // BATCH_SIZE + 1
|
||||
steps = len(input_files) + len(input_files) // BATCH_SIZE + 1
|
||||
|
||||
try:
|
||||
for i in range(0, len(input_files), BATCH_SIZE):
|
||||
@ -30,8 +30,10 @@ def convert(input_files: list[str], output_files: str, encoding: str = None, pro
|
||||
doc = html.render()
|
||||
documents.append(doc)
|
||||
del html
|
||||
if progress:
|
||||
print(f'progress: {i + n + i // BATCH_SIZE + 1}/{steps}', flush=True)
|
||||
all_pages = [p for doc in documents for p in doc.pages]
|
||||
tmp_file_name = f'{output_files}.part.{i:0000}'
|
||||
tmp_file_name = f'{output_files}.part.{i:04}'
|
||||
documents[0].copy(all_pages).write_pdf(tmp_file_name)
|
||||
tmp_file_names.append(tmp_file_name)
|
||||
page_nums += [len(doc.pages) for doc in documents]
|
||||
@ -39,7 +41,7 @@ def convert(input_files: list[str], output_files: str, encoding: str = None, pro
|
||||
del all_pages
|
||||
gc.collect()
|
||||
if progress:
|
||||
print(f'progress: {i // BATCH_SIZE + 1}/{steps}', flush=True)
|
||||
print(f'progress: {i + BATCH_SIZE + i // BATCH_SIZE + 1}/{steps}', flush=True)
|
||||
|
||||
merger = pypdf.PdfWriter()
|
||||
for pdf in tmp_file_names:
|
||||
|
Reference in New Issue
Block a user