def get_transform(self, rotation, tx, ty): # Code taken from here: # http://stackoverflow.com/questions/6041244/how-to-merge-two-landscape-pdf-pages-using-pypdf/17392824#17392824 # Unclear why PyPDF2 builtin page rotation functions don't work translation = [[1, 0, 0], [0, 1, 0], [-tx, -ty, 1]] rotation = math.radians(rotation) rotating = [[math.cos(rotation), math.sin(rotation), 0], [-math.sin(rotation), math.cos(rotation), 0], [0, 0, 1]] rtranslation = [[1, 0, 0], [0, 1, 0], [tx, ty, 1]] ctm = utils.matrixMultiply(translation, rotating) ctm = utils.matrixMultiply(ctm, rtranslation) return ctm[0][0], ctm[0][1], ctm[1][0], ctm[1][1], ctm[2][0], ctm[2][1]
def get_transform(self, rotation, tx, ty): # Code taken from here: # http://stackoverflow.com/questions/6041244/how-to-merge-two-landscape-pdf-pages-using-pypdf/17392824#17392824 # Unclear why PyPDF2 builtin page rotation functions don't work translation = [[1, 0, 0], [0, 1, 0], [-tx,-ty,1]] rotation = math.radians(rotation) rotating = [[math.cos(rotation), math.sin(rotation),0], [-math.sin(rotation),math.cos(rotation), 0], [0, 0, 1]] rtranslation = [[1, 0, 0], [0, 1, 0], [tx,ty,1]] ctm = utils.matrixMultiply(translation, rotating) ctm = utils.matrixMultiply(ctm, rtranslation) return ctm[0][0], ctm[0][1], ctm[1][0], ctm[1][1], ctm[2][0], ctm[2][1]