end_page = int(end)
return start_page, end_page
+def draw_cut(canvas, x_spine_limit, direction, half_height):
+ outer_start_x = x_spine_limit - 0.5 * CUT_WIDTH * direction
+ inner_start_x = x_spine_limit + 0.5 * CUT_WIDTH * direction
+ middle_point_y = half_height + MIDDLE_POINT_DEPTH * direction
+ end_point_y = half_height + CUT_DEPTH * direction
+ canvas.line(inner_start_x, half_height, x_spine_limit, end_point_y)
+ canvas.line(x_spine_limit, end_point_y, x_spine_limit, middle_point_y)
+ canvas.line(x_spine_limit, middle_point_y, outer_start_x, half_height)
+
def parse_args():
parser = argparse.ArgumentParser(description=__doc__, epilog=help_epilogue, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("-i", "--input_file", action="append", required=True, help="input PDF file")
c.line(x_right_spine_limit, A4_HEIGHT, x_right_spine_limit, 0)
if front_page:
c.setLineWidth(0.2)
- # cut upper left
- start_up_left_left_x = x_left_spine_limit - 0.5 * CUT_WIDTH
- start_up_left_right_x = x_left_spine_limit + 0.5 * CUT_WIDTH
- middle_point_up_left_y = half_height + MIDDLE_POINT_DEPTH
- end_point_up_left_y = half_height + CUT_DEPTH
- c.line(start_up_left_right_x, half_height, x_left_spine_limit, end_point_up_left_y)
- c.line(x_left_spine_limit, end_point_up_left_y, x_left_spine_limit, middle_point_up_left_y)
- c.line(x_left_spine_limit, middle_point_up_left_y, start_up_left_left_x, half_height)
- # cut lower right
- start_down_right_left_x = x_right_spine_limit - 0.5 * CUT_WIDTH
- start_down_right_right_x = x_right_spine_limit + 0.5 * CUT_WIDTH
- middle_point_down_right_y = half_height - MIDDLE_POINT_DEPTH
- end_point_down_right_y = half_height - CUT_DEPTH
- c.line(start_down_right_left_x, half_height, x_right_spine_limit, end_point_down_right_y)
- c.line(x_right_spine_limit, end_point_down_right_y, x_right_spine_limit, middle_point_down_right_y)
- c.line(x_right_spine_limit, middle_point_down_right_y, start_down_right_right_x, half_height)
+ draw_cut(c, x_left_spine_limit, (1), half_height)
+ draw_cut(c, x_right_spine_limit, (-1), half_height)
if args.analyze or front_page:
c.save()
new_pdf = pypdf.PdfReader(packet)