Skip to content

Instantly share code, notes, and snippets.

@typoman
Created December 29, 2025 11:51
Show Gist options
  • Select an option

  • Save typoman/9a4eb44ab7fb0756626795baf5c59963 to your computer and use it in GitHub Desktop.

Select an option

Save typoman/9a4eb44ab7fb0756626795baf5c59963 to your computer and use it in GitHub Desktop.
Tile a PDF for printing or PDF imposer in drawbot app
path = 'file.pdf'
w, h = imageSize(path, pageNumber=1)
points_to_mm = 25.4 / 72
mm_to_points = 72 / 25.4
bleed = 3 * mm_to_points # bleed size of the original PDF
margin = 5 * mm_to_points # margin size in the final export to display the bleed marks
canvas_w = w * 2 + margin * 2
canvas_h = h * 2 + margin * 2
count = numberOfPages(path)
print(f"Number of pages: {count}")
for i in range(count):
page_num = i + 1
newPage(canvas_w, canvas_h)
translate(margin, margin)
image(path, (0, 0), pageNumber=page_num)
image(path, (w, 0), pageNumber=page_num)
image(path, (0, h), pageNumber=page_num)
image(path, (w, h), pageNumber=page_num)
save()
stroke(0)
strokeWidth(0.5)
cut_x_positions = [bleed, w - bleed, w + bleed, w * 2 - bleed]
cut_y_positions = [bleed, h - bleed, h + bleed, h * 2 - bleed]
for cx in cut_x_positions:
line((cx, 0), (cx, -margin))
line((cx, h * 2), (cx, h * 2 + margin))
for cy in cut_y_positions:
line((0, cy), (-margin, cy))
line((w * 2, cy), (w * 2 + margin, cy))
print(f"Final size: {canvas_w * points_to_mm}mm x {canvas_h * points_to_mm}mm")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment