Compare commits
No commits in common. "eaf3acd4f58c65210b44d39188442ed85049398a" and "6566830258ed6721c7f5427b57f0efe3772290c0" have entirely different histories.
eaf3acd4f5
...
6566830258
1 changed files with 0 additions and 18 deletions
18
foliator.py
18
foliator.py
|
|
@ -88,23 +88,11 @@ def foliate_A6(input_pdf, strat_func, max_folio_size, append_to=PdfWriter()):
|
||||||
|
|
||||||
folio_page_size = 0
|
folio_page_size = 0
|
||||||
current_page = 0
|
current_page = 0
|
||||||
|
|
||||||
print("Folio sizes, in order")
|
|
||||||
old_l = L[0]
|
|
||||||
old_l_run = 0
|
|
||||||
for l in L:
|
for l in L:
|
||||||
if l != old_l:
|
|
||||||
print(old_l, "a5 sheet(s), x", old_l_run)
|
|
||||||
old_l = l
|
|
||||||
old_l_run = 1
|
|
||||||
else:
|
|
||||||
old_l_run += 1
|
|
||||||
|
|
||||||
# l is a number of _sheets_, each containing 4 pages
|
# l is a number of _sheets_, each containing 4 pages
|
||||||
folio_page_size = min(doc_length - current_page, 4*l)
|
folio_page_size = min(doc_length - current_page, 4*l)
|
||||||
append_folio_A6(input_pdf, current_page, folio_page_size, append_to)
|
append_folio_A6(input_pdf, current_page, folio_page_size, append_to)
|
||||||
current_page += folio_page_size
|
current_page += folio_page_size
|
||||||
print(old_l, "a5 sheet(s), x", old_l_run)
|
|
||||||
|
|
||||||
return writer
|
return writer
|
||||||
|
|
||||||
|
|
@ -150,15 +138,9 @@ parser.add_argument("-a5", help="output as a5, reverse on short edge",
|
||||||
action="store_true")
|
action="store_true")
|
||||||
parser.add_argument("-fs", help="maximum folio size, in sheets",
|
parser.add_argument("-fs", help="maximum folio size, in sheets",
|
||||||
action="store", default=-1, type=int)
|
action="store", default=-1, type=int)
|
||||||
parser.add_argument("--strategy", help="greedy packing of pages into folios",
|
|
||||||
action="store", default="balanced")
|
|
||||||
|
|
||||||
stratnames_dict = {"balanced": find_partition_mink, "greedy": find_partition_greedy}
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
input_pdf = PdfReader(args.infile)
|
input_pdf = PdfReader(args.infile)
|
||||||
strategy = stratnames_dict[args.strategy]
|
|
||||||
a5 = foliate_A6(input_pdf, find_partition_greedy, args.fs)
|
a5 = foliate_A6(input_pdf, find_partition_greedy, args.fs)
|
||||||
if (args.a5):
|
if (args.a5):
|
||||||
a5.write(args.outfile)
|
a5.write(args.outfile)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue