# Create automatic pdf at certain point

**URL:** <https://discourse.processing.org/t/create-automatic-pdf-at-certain-point/25602>\
**Category:** Libraries\
**Created:** [November 22, 2020, 10:17am UTC](https://discourse.processing.org/t/create-automatic-pdf-at-certain-point/25602 "2020-11-22T10:17:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scooijmans](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@scooijmans](https://discourse.processing.org/u/scooijmans)\
**Post date:** [November 22, 2020, 10:17am UTC](https://discourse.processing.org/t/create-automatic-pdf-at-certain-point/25602/1 "2020-11-22T10:17:05Z")

</div>

Hi, I’m a beginner in programming and got this code, it draws a line of the audio input as time goes by. What I need is when the line hits the end of the screen it needs to take an automatic screenshot/pdf of this is around 15 seconds and then the line needs to start again and take a screenshot again after 15 seconds. I hope my question is clear. Thanks in advance for the help.

```auto
/**
 * Grab audio from the microphone input and draw a circle whose size
 * is determined by how loud the audio input is.
 */

import processing.sound.*;
import processing.svg.*;

boolean record; 

AudioIn input;
Amplitude loudness;

int streamSize = 1500;
float[] sensorHist = new float[streamSize]; //history data to show

void setup() {
  size(1500, 500);
  background(255);

  // Create an Audio input and grab the 1st channel
  input = new AudioIn(this, 0);

  // Begin capturing the audio input
  input.start();
  // start() activates audio capture so that you can use it as
  // the input to live sound analysis, but it does NOT cause the
  // captured audio to be played back to you. if you also want the
  // microphone input to be played back to you, call
  // input.play();
  // instead (be careful with your speaker volume, you might produce
  // painful audio feedback. best to first try it out wearing headphones!)

  // Create a new Amplitude analyzer
  loudness = new Amplitude(this);

  // Patch the input to the volume analyzer
  loudness.input(input);
}

void draw() {
  if (record) {
    beginRecord (SVG, "frame-####.svg");
  }
  // Adjust the volume of the audio input based on mouse position
  float inputLevel = map(mouseY, 0, height, 1.0, 0.0);
  input.amp(inputLevel);

  // loudness.analyze() return a value between 0 and 1. To adjust
  // the scaling and mapping of an ellipse we scale from 0 to 0.5
  float volume = loudness.analyze();
  appendArray(sensorHist, map(volume, 0, 0.5, 0, 500)); //store the data to history (for visualization)
  
  background(255);
  noFill();
  stroke(0);
  beginShape();
  for (int n=0; n<sensorHist.length; n++) {
    float h = sensorHist[n];
    vertex(n, h);
  }
  if (record) {
    endRecord();
    record = false;
  }
  endShape();
}

void mousePressed() {
  record = true;
}

//Append a value to a float[] array.
float[] appendArray (float[] _array, float _val) {
  float[] array = _array;
  float[] tempArray = new float[_array.length-1];
  arrayCopy(array, tempArray, tempArray.length);
  array[0] = _val;
  arrayCopy(tempArray, 0, array, 1, tempArray.length);
  return array;
}

```

---

<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:** [November 22, 2020, 1:28pm UTC](https://discourse.processing.org/t/create-automatic-pdf-at-certain-point/25602/2 "2020-11-22T13:28:01Z")

</div>

Hello,

> [@scooijmans](#):
>
> take an automatic screenshot/pdf of this is around 15 seconds and then the line needs to start again and take a screenshot again after 15 seconds.

**Resources for screenshot:**

> **[PDF Export / Libraries](https://processing.org/reference/libraries/pdf/index.html)**
>
> Create PDF files. These vector graphics files can be scaled to any size and printed at high resolutions.

Also look up save() and saveFrame() references at [Processing.org](http://Processing.org) in the references.

**Timers:**

There are numerous examples of timers in this forum.  
You can use millis(), frameCount, the [Java Timer Class](https://docs.oracle.com/javase/8/docs/api/java/util/Timer.html) etc.

Also look at _related_ functions when you look up millis() reference at [Processing.org](http://Processing.org)

[Learning Processing Timer example](http://learningprocessing.com/examples/chp10/example-10-04-timer)

`:)`

---

<div class="post-metadata">

**Author:** ![scooijmans](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@scooijmans](https://discourse.processing.org/u/scooijmans)\
**Post date:** [November 23, 2020, 7:54am UTC](https://discourse.processing.org/t/create-automatic-pdf-at-certain-point/25602/3 "2020-11-23T07:54:20Z")

</div>

Oke thank you very much, gonna look into that

---

<div class="post-metadata">

**Author:** ![scooijmans](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@scooijmans](https://discourse.processing.org/u/scooijmans)\
**Post date:** [November 24, 2020, 12:13pm UTC](https://discourse.processing.org/t/create-automatic-pdf-at-certain-point/25602/4 "2020-11-24T12:13:43Z")

</div>

I have another question about this code. Is it possible that when the line is formed till the end of the screen it stays there and then starts again underneath this line. so it will be a pattern?
