Even if you set it to true at the top, the first time you enter the draw loop it is set to false.
import processing.pdf.*;
void setup() {
size(500, 500);
background(255);
beginRecord(PDF, "frame-####.pdf");
}
void draw () {
}
void mousePressed() {
circle(mouseX, mouseY, 50);
}
void keyPressed() {
if (key == 's') {
endRecord();
exit();
}
}