+# if necessary, pad pages to multiple of 8
+if args.nup4:
+ mod_to_8 = len(pages_to_add) % 8
+ if mod_to_8 > 0:
+ print("-n: number of input pages %d not multiple of 8, padding to that" % len(pages_to_add))
+ for _ in range(8 - mod_to_8):
+ new_page = pypdf.PageObject.create_blank_page(width=a4_width, height=a4_height)
+ pages_to_add += [new_page]
+