Initial commit of Roster
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import fitz # PyMuPDF
|
||||
|
||||
LETTER_WIDTH = 792 # 8.5 inches
|
||||
LETTER_HEIGHT = 612 # 11 inches
|
||||
BOTTOM_MARGIN = 30
|
||||
|
||||
def adjust_layout(input_path, output_path, shift_amount):
|
||||
doc = fitz.open(input_path)
|
||||
new_doc = fitz.open()
|
||||
|
||||
for page in doc:
|
||||
rect = page.rect
|
||||
|
||||
# Keep original width, enforce standard height
|
||||
new_rect = fitz.Rect(0, 0, LETTER_WIDTH, LETTER_HEIGHT)
|
||||
new_page = new_doc.new_page(width=new_rect.width, height=new_rect.height)
|
||||
|
||||
# Shift original content down by shift_amount
|
||||
# Clip it back to fit on a Letter-sized page
|
||||
content_rect = fitz.Rect(0, shift_amount, rect.width, rect.height + shift_amount - BOTTOM_MARGIN)
|
||||
|
||||
new_page.show_pdf_page(content_rect, doc, page.number)
|
||||
|
||||
new_doc.save(output_path)
|
||||
new_doc.close()
|
||||
doc.close()
|
||||
Reference in New Issue
Block a user