# How do I get my PDF to render properly?

**URL:** https://discourse.processing.org/t/how-do-i-get-my-pdf-to-render-properly/37349
**Category:** Beginners
**Created:** [June 6, 2022, 9:09am UTC](https://discourse.processing.org/t/how-do-i-get-my-pdf-to-render-properly/37349 "2022-06-06T09:09:14Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jakebeamish](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jakebeamish/32/16403_2.png) [@jakebeamish](https://discourse.processing.org/u/jakebeamish)
#### Post date: [June 6, 2022, 9:09am UTC](https://discourse.processing.org/t/how-do-i-get-my-pdf-to-render-properly/37349/1 "2022-06-06T09:09:14Z")

</div>

I’ve just started getting my feet wet with Processing, and I’m having trouble figuring out why I’m having problems with this sketch rendering out PDFs and SVGs that are missing a lot of the picture. I’m using the beginRecord(); endRecord(); method to save them, as well as save(); to make a PNG (which works fine). It looks like the PDF and SVG have a bunch of lines missing, wherever a line crosses another. If anyone has any pointers on why this might be happening I’d be really appreciative.

On the left is the pdf, on the right is the png:

 ![Screenshot 2022-06-06 at 10.07.00](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/e/fe6063e2b9aa22b6ce48a8ad1e83217be13e377a.png)

* * *

```auto
import processing.pdf.*;
import processing.svg.*;

String title = "curves";

int counter;
int seed;

void setup() {
  size(720, 720);
  noFill();
  smooth();
  seed = millis();
  seededRender();
}
  
void draw() {
}

void seededRender() {
  randomSeed(seed);
  noiseSeed(seed);
  render();
}

void render() {
  
  int points = 2;
  int lines = 200;
  float zoff = 0.03;

  float z = 0.0;
  background(255);
  stroke(0);
  for (int i = 0; i <= width; i += width / lines) {
    beginShape();
    curveVertex(i, 0);
    curveVertex(i, 0);
    for (float p = 1; p <= points; p++) {
      curveVertex(width * noise(z + p), height * (p / (points + 1)));
    }
    curveVertex(i, height);
    curveVertex(i, height);
    endShape();
    z += zoff;
  }
}

//

void keyReleased() {
  if (key == TAB) {
    newSeed();
  }
  if (key == ENTER) {
    saveImage();
  }
}

void newSeed() {
  seed = millis();
  println("rendered with new seed " + seed);
  seededRender();
}

void saveImage() {
  String filename = "data/" + title + "_" + nf(counter, 3) + "_" + seed;
  beginRecord(PDF, filename + ".pdf");
  seededRender();
  endRecord();
  beginRecord(SVG, filename + ".svg");
  seededRender();
  endRecord();
  save(filename + ".png");
  println("saved " + filename);
  counter++;
}

```

---

<div class="post-metadata">

### Author: ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)
#### Post date: [June 6, 2022, 11:53am UTC](https://discourse.processing.org/t/how-do-i-get-my-pdf-to-render-properly/37349/2 "2022-06-06T11:53:19Z")

</div>

I believe its overriding the stroke data with a fill, add a noFill(); to the render function and it works fine mate  
Edit: Not sure why it works with png and on the screen itself though

---

<div class="post-metadata">

### Author: ![jakebeamish](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jakebeamish/32/16403_2.png) [@jakebeamish](https://discourse.processing.org/u/jakebeamish)
#### Post date: [June 6, 2022, 12:03pm UTC](https://discourse.processing.org/t/how-do-i-get-my-pdf-to-render-properly/37349/3 "2022-06-06T12:03:38Z")

</div>

Oh wow, that’s great thank you so much 😁

I didn’t even consider if I’d need to add it into the function, as noFill() is there in setup(), but I’m very new to the idea of not doing things in draw().

Cheers for taking the time to help me out!

---

<div class="post-metadata">

### Author: ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)
#### Post date: [June 6, 2022, 12:12pm UTC](https://discourse.processing.org/t/how-do-i-get-my-pdf-to-render-properly/37349/4 "2022-06-06T12:12:23Z")

</div>

Yeah im not to sure why it needed it in the function either after seeing it in draw, may be something to do with the begin record and end record, i just tried a bunch of things until it worked lol, glad to help

---

<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: [June 6, 2022, 5:58pm UTC](https://discourse.processing.org/t/how-do-i-get-my-pdf-to-render-properly/37349/5 "2022-06-06T17:58:08Z")

</div>

Hello @jakebeamish,

I have come across such issues in the past…

I generally put all code including attributes as as _stroke()_ and _fill()_ inside the beginning and end of any renderer.

References:  
[https://processing.org/tutorials/rendering](https://processing.org/tutorials/rendering)  
[https://processing.org/reference/libraries/pdf/index.html](https://processing.org/reference/libraries/pdf/index.html)

`:)`
