# Saving to PDF while using the copy() function

**URL:** <https://discourse.processing.org/t/saving-to-pdf-while-using-the-copy-function/13201>\
**Category:** Coding Questions\
**Created:** [August 5, 2019, 9:48pm UTC](https://discourse.processing.org/t/saving-to-pdf-while-using-the-copy-function/13201 "2019-08-05T21:48:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel\_betts](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@daniel\_betts](https://discourse.processing.org/u/daniel_betts)\
**Post date:** [August 5, 2019, 9:48pm UTC](https://discourse.processing.org/t/saving-to-pdf-while-using-the-copy-function/13201/1 "2019-08-05T21:48:43Z")

</div>

Hey,  
I’m have written a small code for a sort of text-warping tool using PGraphics, PFont, and the copy() function. I would like to output “Many Frames Into One File (With Screen Display)” as explained in the PDF library, but I am now receiving the error code: “No copy() for PGraphicsPDF” when I run my code. Below is my code as it stands. Any thoughts on how to remedy this issue and export a PDF (or even just a very High-Res .png or .jpeg) of my screen display while using the copy() function?

```auto
PGraphics pg;
PFont font;

int on=1;
int move = 0;

float x;
float y;
float easing = 0.05;

import processing.pdf.*;

void setup(){
  size(800,800);
  background(0);
  
  beginRecord(PDF, "everything.pdf");
 
  font = createFont("governor.ttf", 300); 
  pg = createGraphics(800,800);
}

void draw() {
  float targetX = mouseX; //Movement Easing
  float dx = targetX - x;
  x += dx * easing;
  
  float targetY = mouseY;
  float dy = targetY - y;
  y += dy * easing;
  
  pg.beginDraw(); //Draw Letters
  pg.background(0,0,0);
  pg.fill(255);
  pg.textFont(font);
  pg.textSize(150);
  pg.pushMatrix();
  pg.translate(x, y);
  pg.textAlign(CENTER, CENTER);
  pg.text("TEXT", 0, 0);
  pg.popMatrix();
  pg.endDraw();
  
   copy(pg, 0, move, width, 1, 0, move, width, 1); // Copy/Paste
  
   move = move + 1; //Advance Copy/Paste line
   
   if (move > height){
   move = 0;
   background(0); 
  }}
 
void mousePressed() { //ON/OFF switch
  if(on<0){
  loop(); on=on*-1;
  }else{ noLoop();on=on*-1;}
}

void keyPressed() { //End recording/Exit
  if (key == 'q') {
    endRecord();
    exit();
  }
}

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 5, 2019, 11:30pm UTC](https://discourse.processing.org/t/saving-to-pdf-while-using-the-copy-function/13201/2 "2019-08-05T23:30:55Z")

</div>

I have not worked with PDFs so just exploring…

[https://processing.org/reference/libraries/pdf/index.html](https://processing.org/reference/libraries/pdf/index.html)  
[https://processing.org/reference/PGraphics.html](https://processing.org/reference/PGraphics.html)

I took some examples from links and merged with yours and cut some code and this will save to a PDF when I hit ‘q’:

```auto
import processing.pdf.*;
PGraphics pg;

float x;
float y;
float easing = 0.05;

void setup() 
  {
  size(400, 400);
  beginRecord(PDF, "everything.pdf");
  pg = createGraphics(400, 400); 
  background(0);
  }

void draw() 
  {
  float targetX = mouseX; //Movement Easing
  float dx = targetX - x;
  x += dx * easing;
  
  float targetY = mouseY;
  float dy = targetY - y;
  y += dy * easing;

  pg.beginDraw(); //Draw Letters
// pg.background(0,0,0);
  pg.fill(255);
  pg.textSize(50);
  pg.pushMatrix();
  pg.translate(x, y);
  pg.textAlign(CENTER, CENTER);
  pg.text("TEXT", 0, 0);
  pg.popMatrix();
  pg.endDraw();
  
  image(pg, 0, 0);
  }

void keyPressed()
  {
  if (key == 'q') 
    {
    endRecord();
    exit();
    }
  }

```

🙂

---

<div class="post-metadata">

**Author:** ![daniel\_betts](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@daniel\_betts](https://discourse.processing.org/u/daniel_betts)\
**Post date:** [August 6, 2019, 6:56pm UTC](https://discourse.processing.org/t/saving-to-pdf-while-using-the-copy-function/13201/3 "2019-08-06T18:56:56Z")

</div>

Hey thanks for taking a look at this! However, looks like you removed the copy() function from the code which defeats the purpose a little bit. My goal is to be able to use the copy() function with a PGraphics element and export multiple frames of the animation to a PDF. thoughts?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 6, 2019, 7:54pm UTC](https://discourse.processing.org/t/saving-to-pdf-while-using-the-copy-function/13201/4 "2019-08-06T19:54:39Z")

</div>

This did save to a PDF when I pressed ‘q’.  
I removed “copy” because it did not work.

You may want to consider saving frames:  
[https://processing.org/reference/saveFrame\_.html](https://processing.org/reference/saveFrame_.html)

I do this for making animated GIFs:

> **[Creating Animated GIFs in Processing](https://cre8math.com/2017/10/02/creating-animated-gifs-in-processing/)**
>
> Last week at our Digital Art Club meeting, I mentioned that I had started making a few animated gifs using Processing.  Like this one. (I’m not sure exactly why the circles look like they hav…

🙂
