page splitter : support empty clip
parent
e574407fe6
commit
00fc8d07fb
|
|
@ -362,12 +362,14 @@ class PDFPreviewer:
|
|||
rect_left = fitz.Rect(0, 0, line_x, page.rect.height)
|
||||
else:
|
||||
rect_left = fitz.Rect(page.rect.width-line_x, 0, page.rect.width, page.rect.height)
|
||||
|
||||
if (keep == "both" or keep == "left") and line_x > 0:
|
||||
|
||||
doc_left = fitz.open()
|
||||
page_left = doc_left.new_page(width=rect_left.width, height=rect_left.height)
|
||||
page_left.show_pdf_page(page_left.rect, self.doc, i, clip=rect_left)
|
||||
page_left.set_rotation(rotation)
|
||||
|
||||
if keep == "both" or keep == "left":
|
||||
output_path_left = self.split_filename_left(i)
|
||||
doc_left.save(output_path_left)
|
||||
doc_left.close()
|
||||
|
|
@ -377,12 +379,11 @@ class PDFPreviewer:
|
|||
rect_right = fitz.Rect(line_x, 0, page.rect.width, page.rect.height)
|
||||
else:
|
||||
rect_right = fitz.Rect(0, 0, page.rect.width-line_x, page.rect.height)
|
||||
if (keep == "both" or keep == "right") and line_x < page.rect.width:
|
||||
doc_right = fitz.open()
|
||||
page_right = doc_right.new_page(width=rect_right.width, height=rect_right.height)
|
||||
page_right.show_pdf_page(page_right.rect, self.doc, i, clip=rect_right)
|
||||
page_right.set_rotation(rotation)
|
||||
|
||||
if keep == "both" or keep == "right":
|
||||
output_path_right = self.split_filename_right(i)
|
||||
doc_right.save(output_path_right)
|
||||
doc_right.close()
|
||||
|
|
|
|||
Loading…
Reference in New Issue