-
Original pdf is below Converted is below Code used. def convert_pdf_to_a4(input_pdf_path, output_pdf_path):
使用示例input_pdf = r"F:\Binder1 - 副本.pdf" # 输入文件路径 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 13 replies
-
The following 10-line script does the job: import sys, pymupdf
src = pymupdf.open(sys.argv[1]) # file to be reformatted to A4
out = pymupdf.open() # result file
for spage in src: # walk through input pages
spage.remove_rotation() # remove rotation - keeping visual appearance
page = out.new_page() # make A4 output page
# insert source page content, appropriately scaled to full A4
page.show_pdf_page(page.rect, src, spage.number)
out.ez_save(src.name + "-reformatted.pdf") Because your example file pages have an aspect ratio different from sqrt(2):1, white borders result left and right. Specify |
Beta Was this translation helpful? Give feedback.
-
Another question is: original pdf is very small, 241KB. |
Beta Was this translation helpful? Give feedback.
-
Thank you. Any possible solution? |
Beta Was this translation helpful? Give feedback.
-
There are 2 column pages, Use Insert_rect for white textbox to cover? |
Beta Was this translation helpful? Give feedback.
-
Can redactions remove rect any area to be blank? |
Beta Was this translation helpful? Give feedback.
The following 10-line script does the job:
Because your example file pages have an aspect ratio different from sqrt(2):1, white borders result left and right. Specify
keep_proportion=False
to stretch.