Skip to content

Instantly share code, notes, and snippets.

@apwan
Created October 28, 2019 12:11
Show Gist options
  • Save apwan/7cf3bbd0fed510594b6a89d5ea6551c5 to your computer and use it in GitHub Desktop.
Save apwan/7cf3bbd0fed510594b6a89d5ea6551c5 to your computer and use it in GitHub Desktop.
print 2 pages per sheet and double side
# rearrange pages
def gen(n4):
n = n4//4
a1 = [[4*n-2*i, 2*i+1, 2*i+2, 4*n-2*i-1] for i in range(n)]
return [str(k) for x in a1 for k in x]
'''
Example: ','.join(gen(44))
Output: '44,1,2,43,42,3,4,41,40,5,6,39,38,7,8,37,36,9,10,35,34,11,12,33,32,13,14,31,30,15,16,29,28,17,18,27,26,19,20,25,24,21,22,23'
'''
# Usage:
# pdfjam input.pdf 'OUTPUT_STRING' --a4paper --rotateoversize false --outfile output.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment