Saving

drawBot.saveImage(paths, multipage=None)

Save or export the canvas to a specified format. The argument paths can either be a single path or a list of paths.

The file extension is important because it will determine the format in which the image will be exported.

All supported file extensions: pdf, svg, png, jpg, jpeg, tiff, tif, gif, bmp and mov.

  • A pdf can be multipage. If multipage is False only the current page is saved.
  • A mov will use each page as a frame.
  • A gif can be animated when there are multiple pages and it will use each page as a frame.
  • All images and svg formats will only save the current page. If multipage is True all pages are saved to disk (a page index will be added to the file name).
# set the canvas size
size(150, 100)

# draw a background
rect(10, 10, width()-20, height()-20)

# set a fill
fill(1)
# draw some text
text("Hello World!", (20, 40))
# save it as a png and pdf on the current users desktop
saveImage(["~/Desktop/firstImage.png", "~/Desktop/firstImage.pdf"])
drawBot.printImage()

Export the canvas to a printing dialog, ready to print.

# set A4 page size
size(595, 842)
# draw something
oval(0, 0, width(), height())
# send it to the printer
printImage()
drawBot.pdfImage()

Return the image as a pdf document object.