Saving PDF files
If you want to print your artwork and you save your sketch as an image, the size of your print will be based on the resolution of your image. If you want to print your images really big, you might want to save your sketch as a PDF file. Every shape you draw in Processing is vector-based and can thus be printed at any size. Note that if you work with pixels in Processing, you won't be able to save your work as PDF.
How to do it...
The first thing you need to do is to import the PDF library into your sketch. Go to Sketch | Import Library | pdf to do this. You also need to declare a boolean variable named savePDF
.
import processing.pdf.*; boolean savePDF = false; void setup() { size( 640, 480 ); smooth(); rectMode( CENTER ); stroke(0); }
Inside the draw()
function, we'll use the savePDF
variable to tell Processing when it needs to start recording the PDF file. Everything you draw between the beginRecord()
and endRecord()
functions will be included in the PDF file. The...