Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : How to save a PDF from a specific area of the app window?

$
0
0
I always go back to the PDF reference page to answer such questions...
The Pausing While Recording (With Screen Display) entry seems to fit your:
  1. import processing.pdf.*;
  2.  
  3. PGraphicsPDF pg;
  4.  
  5. boolean doSave = false;
  6. int canvasW = 320;
  7. int canvasH = 240;
  8.  
  9. void setup() {
  10.   size(640, 480);
  11.   pg = (PGraphicsPDF)createGraphics(canvasW, canvasH, PDF, "ellipse.pdf");
  12. }
  13.  
  14. void draw() {
  15.   if (doSave) {
  16.     println("saving pdf file");
  17.     beginRecord(pg);
  18.   }
  19.  
  20.   background(220, 20, 100);
  21.   stroke(255);
  22.   fill(125);
  23.   ellipse(canvasW / 2, canvasH / 2, 50, 50);
  24.   stroke(#00FF00, 50);
  25.   fill(#229933, 50);
  26.   ellipse(width / 2, height / 2, 450, 350);
  27.  
  28.   if (doSave) {
  29.     endRecord();
  30.     doSave = false;
  31.     println("save complete");
  32.   }
  33. }
  34.  
  35. void keyPressed() {
  36.   if (key == 's' || key == 'S') {
  37.     doSave = true;
  38.   }
  39. }


Viewing all articles
Browse latest Browse all 1768

Trending Articles