Exporting still images from animations

I have tried with this, but does not do anything

float blueX;
float blueY;

float redX;
float redY;

import processing.pdf.*;

void setup() {
  size(500, 500, PDF, "filename.pdf");
  
  blueX = width*.25;
  blueY = height/2;

  redX = width*.75;
  redY = height/2;

  background(255);
  
  frameRate(1000);
}

void draw() {

  stroke(0,0,255);
  strokeWeight(2);
  
  blueX += random(-2, 2);
  blueY += random(-2, 2);
    
  if(blueX < 0){
    blueX = width;
  }
  if(blueX > width){
    blueX = 0;
  }

  if(blueY < 0){
    blueY = height;
  }
  if(blueY > height){
    blueY = 0;
  }
  
  point(blueX, blueY);
  
  stroke(255,0,0);
  strokeWeight(2);
  
  redX += random(-2, 2);
  redY += random(-2, 2);
  
  if(redX < 0){
    redX = width;
  }
  if(redX > width){
    redX = 0;
  }
  
  if(redY < 0){
    redY = height;
  }
  if(redY > height){
    redY = 0;
  }  
  
  point(redX, redY);
  
 if (mousePressed == true) {
saveFrame();
} 

println("Finished."); 
exit();

  
}