V2: Added Webserver for faster formatting
This commit is contained in:
Binary file not shown.
@@ -1,10 +1,10 @@
|
||||
import fitz # PyMuPDF
|
||||
|
||||
LETTER_WIDTH = 792 # 8.5 inches
|
||||
LETTER_HEIGHT = 612 # 11 inches
|
||||
LETTER_WIDTH = 792 # 11 inches at 72 points per inch
|
||||
LETTER_HEIGHT = 612 # 8.5 inches at 72 points per inch
|
||||
BOTTOM_MARGIN = 60
|
||||
|
||||
def adjust_layout(input_path, output_path, shift_amount):
|
||||
def adjust_layout(input_path, output_path, shift_amount, bottom_margin=BOTTOM_MARGIN):
|
||||
doc = fitz.open(input_path)
|
||||
new_doc = fitz.open()
|
||||
|
||||
@@ -17,7 +17,12 @@ def adjust_layout(input_path, output_path, shift_amount):
|
||||
|
||||
# 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)
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user