2021-08-10 15:41:18 +02:00
|
|
|
# CHAPTER 3. Pages
|
|
|
|
|
|
|
|
def scalePages(pdf, r, sx, sy):
|
|
|
|
"""scalePages(pdf, range, x scale, y scale) scales the page dimensions
|
|
|
|
and content by the given scale, about (0, 0). Other boxes (crop etc. are
|
|
|
|
altered as appropriate)"""
|
|
|
|
|
|
|
|
def scaleToFit(pdf, r, sx, sy, scale_to_fit_scale):
|
|
|
|
"""scaleToFit(pdf, range, width height, scale) scales the content to fit
|
|
|
|
new page dimensions (width x height) multiplied by scale (typically 1.0).
|
|
|
|
Other boxed (crop etc. are altered as appropriate)"""
|
|
|
|
|
|
|
|
def scaleToFitPaper(pdf, r, papersize, scale_to_fit_scale):
|
|
|
|
"""scaleToFitPaper(pdf, range, papersize, scale) scales the page content
|
|
|
|
to fit the given page size, possibly multiplied by scale (typically 1.0)"""
|
|
|
|
|
|
|
|
"""Positions with two numbers in a tuple e.g (posLeft, 10.0, 20.0):"""
|
|
|
|
posCentre = 0
|
|
|
|
posLeft = 1
|
|
|
|
posRight = 2
|
|
|
|
"""Positions with one number in a tuple e.g (top, 5.0):"""
|
|
|
|
top = 3
|
|
|
|
topLeft = 4
|
|
|
|
topRight = 5
|
|
|
|
left = 6
|
|
|
|
bottomLeft = 7
|
|
|
|
bottomRight = 8
|
|
|
|
right = 9
|
|
|
|
"""Positions with no numbers e.g diagonal:"""
|
|
|
|
diagonal = 10
|
|
|
|
reverseDiagonal = 11
|
|
|
|
|
|
|
|
def scaleContents(pdf, r, pos, scale):
|
|
|
|
"""scaleContents(pdf, range, position, scale) scales the contents of the
|
|
|
|
pages in the range about the point given by the position, by the
|
|
|
|
scale given."""
|
|
|
|
|
|
|
|
def shiftContents(pdf, r, dx, dy):
|
|
|
|
"""shiftContents(pdf, range, dx, dy) shifts the content of the pages in
|
|
|
|
the range."""
|
|
|
|
|
|
|
|
def rotate(pdf, r, rotation):
|
|
|
|
"""rotate(pdf, range, rotation) changes the viewing rotation to an
|
|
|
|
absolute value. Appropriate rotations are 0, 90, 180, 270."""
|
|
|
|
|
|
|
|
def rotateBy(pdf, r, rotation):
|
|
|
|
"""rotateBy(pdf, range, rotation) changes the viewing rotation by a
|
|
|
|
given number of degrees. Appropriate values are 90, 180, 270."""
|
|
|
|
|
|
|
|
def rotateContents(pdf, r, rotation):
|
|
|
|
"""rotateContents(pdf, range, angle) rotates the content about the centre
|
|
|
|
of the page by the given number of degrees, in a clockwise direction."""
|
|
|
|
|
|
|
|
def upright(pdf, r):
|
|
|
|
"""upright(pdf, range) changes the viewing rotation of the pages in the
|
|
|
|
range, counter-rotating the dimensions and content such that there is no
|
|
|
|
visual change."""
|
|
|
|
|
|
|
|
def hFlip(pdf, r):
|
|
|
|
"""hFlip(pdf, range) flips horizontally the pages in the range."""
|
|
|
|
|
|
|
|
def vFlip(pdf, r):
|
|
|
|
"""vFlip(pdf, range) flips vertically the pages in the range."""
|
|
|
|
|
|
|
|
def crop(pdf, r, x, y, w, h):
|
|
|
|
"""crop(pdf, range, x, y, w, h) crops a page, replacing any existing
|
|
|
|
crop box. The dimensions are in points."""
|
|
|
|
|
|
|
|
def removeCrop(pdf, r):
|
|
|
|
"""removeCrop(pdf, range) removes any crop box from pages in the range."""
|
|
|
|
|
|
|
|
def removeTrim(pdf, r):
|
|
|
|
"""removeTrim(pdf, range) removes any crop box from pages in the range."""
|
|
|
|
|
|
|
|
def removeArt(pdf, r):
|
|
|
|
"""removeArt(pdf, range) removes any crop box from pages in the range."""
|
|
|
|
|
|
|
|
def removeBleed(pdf, r):
|
|
|
|
"""removeBleed(pdf, range) removes any crop box from pages in the range."""
|
|
|
|
|
|
|
|
def trimMarks(pdf, r):
|
|
|
|
"""trimMarks(pdf, range) adds trim marks to the given pages, if the trimbox
|
|
|
|
exists."""
|
|
|
|
|
|
|
|
def showBoxes(pdf, r):
|
|
|
|
"""showBoxes(pdf, range) shows the boxes on the given pages, for debug."""
|
|
|
|
|
|
|
|
def hardBox(pdf, r, boxname):
|
|
|
|
"""hardBox make a given box a 'hard box' i.e clips it explicitly."""
|