2021-08-10 15:41:18 +02:00
|
|
|
def twoUp(pdf):
|
2024-04-17 01:59:48 +02:00
|
|
|
"""Impose a document two up by retaining the existing page size, scaling
|
|
|
|
pages down."""
|
2021-07-26 20:50:33 +02:00
|
|
|
|
2021-08-10 15:41:18 +02:00
|
|
|
def twoUpStack(pdf):
|
2024-04-17 01:59:48 +02:00
|
|
|
"""Impose a document two up by doubling the page size, to fit two pages on
|
|
|
|
one."""
|
2021-07-26 20:50:33 +02:00
|
|
|
|
2022-01-23 14:06:53 +01:00
|
|
|
def impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, linewidth):
|
2024-04-17 01:59:48 +02:00
|
|
|
"""Impose a PDF. There are two modes: imposing x * y, or imposing to fit a
|
|
|
|
page of size x * y. This is controlled by fit. Columns imposes by columns
|
|
|
|
rather than rows. rtl is right-to-left, btt bottom-to-top. Center is unused
|
|
|
|
for now. Margin is the margin around the output, spacing the spacing
|
|
|
|
between imposed inputs."""
|
|
|
|
|
|
|
|
def chop(pdf, r, x, y, columns, rtl, btt):
|
|
|
|
"""Chop each page in the range into x * y pieces. If columns is set, the
|
|
|
|
pieces go by columns instead of rows. If rtl is set, the pieces are taken
|
|
|
|
right-to-left. If btt is set, the pieces are taken from bottom to top. """
|
|
|
|
|
|
|
|
def chopH(pdf, r, columns, y):
|
|
|
|
"""Chop each page in the range horizontally at position y. If columns is
|
|
|
|
set, the pieces are arranged in reverse order. """
|
|
|
|
|
|
|
|
def chopV(pdf, r, columns, x):
|
|
|
|
"""Chop each page in the range vertically at position x. If columns is
|
|
|
|
set, the pieces are arranged in reverse order. """
|
2022-01-23 14:06:53 +01:00
|
|
|
|
2021-08-10 15:41:18 +02:00
|
|
|
def padBefore(pdf, r):
|
2021-09-01 19:41:10 +02:00
|
|
|
"""Adds a blank page before each page in the given range."""
|
2021-07-26 20:50:33 +02:00
|
|
|
|
2021-08-10 15:41:18 +02:00
|
|
|
def padAfter(pdf, r):
|
2021-09-01 19:41:10 +02:00
|
|
|
"""Adds a blank page after each page in the given range."""
|
2021-07-26 20:50:33 +02:00
|
|
|
|
2021-08-10 15:41:18 +02:00
|
|
|
def padEvery(pdf, n):
|
2021-09-01 19:41:10 +02:00
|
|
|
"""Adds a blank page after every n pages."""
|
2021-07-26 20:50:33 +02:00
|
|
|
|
2021-08-10 15:41:18 +02:00
|
|
|
def padMultiple(pdf, n):
|
2021-09-01 19:41:10 +02:00
|
|
|
"""Adds pages at the end to pad the file to a multiple of n pages in
|
|
|
|
length."""
|
2021-07-26 20:50:33 +02:00
|
|
|
|
2021-08-10 15:41:18 +02:00
|
|
|
def padMultipleBefore(pdf, n):
|
2024-04-17 01:59:48 +02:00
|
|
|
"""Adds pages at the beginning to pad the file to a multiple of n pages in
|
|
|
|
length."""
|