# Problem with duplicate objects when exporting to PDF

**URL:** https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364
**Category:** Coding Questions
**Created:** [June 6, 2022, 3:25pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364 "2022-06-06T15:25:04Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![S0r0ka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@S0r0ka](https://discourse.processing.org/u/S0r0ka)
#### Post date: [June 6, 2022, 3:25pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/1 "2022-06-06T15:25:04Z")

</div>

Could someone help me figure out how to upload to PDF? I draw a simple circle and export the result to PDF. When I open the file in a vector program, I see that two objects have been unloaded at the same place. One object is invisible because it has no outline. The second object with an outline. And both without filling, although in the code I used fill(0). How can I get rid of this double upload? When there are a lot of objects, and their number doubles in this way, this becomes a problem.

```auto
import processing.pdf.*;
size(400, 400);
noStroke();
fill(0);
beginRecord(PDF, fileName);
background(255);
circle(100, 100, 10);
endRecord();

```

And the second question, can I set the file size when uploading to PDF? My default is always A4, and I would like to be able to change this, but I can’t find how.

---

<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, 4:45pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/2 "2022-06-06T16:45:42Z")

</div>

Hello @S0r0ka,

There is a _PDF Export Library_ reference here:

> **[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.

Example:

```auto
import processing.pdf.*;
size(400, 400);

beginRecord(PDF, "test.pdf");
// Put code here between *begenRecord()* and *EndRecord()*
noStroke();
fill(0);
// And so on...
endRecord();

```

The code example you provided does not run; you need to have a fimeName which is a String such as _“test.pdf”_

Please follow these instructions if you are posting code:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

`:)`

---

<div class="post-metadata">

### Author: ![S0r0ka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@S0r0ka](https://discourse.processing.org/u/S0r0ka)
#### Post date: [June 6, 2022, 5:31pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/3 "2022-06-06T17:31:12Z")

</div>

Thank you for your answer. I understand that vector graphics is scaled, but if I need some special proportions it’s not convenient to use other program to change file’s format. Do you mean I need to use createGraphics for this? I’m gonna try, thank you!

My code runs. This example is simplified, of course I use full path name in this string. It’s not a problem. Problem there is in finishing file.

---

<div class="post-metadata">

### Author: ![S0r0ka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@S0r0ka](https://discourse.processing.org/u/S0r0ka)
#### Post date: [June 6, 2022, 5:44pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/4 "2022-06-06T17:44:22Z")

</div>

Yes, this works! I was able to change file’s dimentions, thank you again!  
So I still need to solve the first problem with duplicating)

---

<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:49pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/5 "2022-06-06T17:49:15Z")

</div>

> [@S0r0ka](#):
>
> So I still need to solve the first problem with duplicating

Can you provide a simple example of the problem?

This is often called and MCVE:

> **[How to create a Minimal, Reproducible Example - Help Center](https://stackoverflow.com/help/minimal-reproducible-example)**
>
> Stack Overflow | The World’s Largest Online Community for Developers

`:)`

---

<div class="post-metadata">

### Author: ![S0r0ka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@S0r0ka](https://discourse.processing.org/u/S0r0ka)
#### Post date: [June 6, 2022, 6:20pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/6 "2022-06-06T18:20:14Z")

</div>

This is my code example:

```auto
import processing.pdf.*;

String fileName;

void setup()
{
  size(400, 400);
  noStroke();
  fill(0);
  fileName = "output/" + day()+hour()+minute() + "-###.pdf";
  beginRecord(PDF, fileName);
  background(255);
  circle(200, 200, 50);
}

void draw()
{
}

void keyPressed()
{
  if (key == 'P' || key == 'p')
  {
    endRecord();
  }
}

```

---

<div class="post-metadata">

### Author: ![S0r0ka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@S0r0ka](https://discourse.processing.org/u/S0r0ka)
#### Post date: [June 6, 2022, 6:20pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/7 "2022-06-06T18:20:49Z")

</div>

This is what I see at processing screen:  
 ![_Proc](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/c/0/c09ba7c2aced52e00c899cc2d46098d013d63fee.png)

---

<div class="post-metadata">

### Author: ![S0r0ka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@S0r0ka](https://discourse.processing.org/u/S0r0ka)
#### Post date: [June 6, 2022, 6:21pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/8 "2022-06-06T18:21:59Z")

</div>

This is what I have in pdf file:

 ![_pdf](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/6/56d36731fc49ae64faabe4efcfd9f05cc9f11621.png)

---

<div class="post-metadata">

### Author: ![S0r0ka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@S0r0ka](https://discourse.processing.org/u/S0r0ka)
#### Post date: [June 6, 2022, 6:22pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/9 "2022-06-06T18:22:34Z")

</div>

This is what is in vector program when I open pdf file - two objects, one is invisible (I move second to the right to show it here):

 ![_vector](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/4/24e7ca24a87aa7589016984567a791947cfb6e5d.png)

So I have two curves in my unloading.

---

<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, 6:30pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/10 "2022-06-06T18:30:42Z")

</div>

Hello,

A related topic:  
[https://discourse.processing.org/t/how-do-i-get-my-pdf-to-render-properly/37349/5](https://discourse.processing.org/t/how-do-i-get-my-pdf-to-render-properly/37349/5)

Try this:

```auto
import processing.pdf.*;

String fileName;

void setup()
  {
  size(400, 400);

  fileName = "output/" + day()+hour()+minute() + "-###.pdf";
  //noStroke();
  //fill(0);
  beginRecord(PDF, fileName);
  noStroke(); // Moved to here
  fill(0); // Moved to here
  background(255);
  circle(200, 200, 50);
  endRecord();
  }

```

`:)`

---

<div class="post-metadata">

### Author: ![S0r0ka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@S0r0ka](https://discourse.processing.org/u/S0r0ka)
#### Post date: [June 6, 2022, 6:37pm UTC](https://discourse.processing.org/t/problem-with-duplicate-objects-when-exporting-to-pdf/37364/11 "2022-06-06T18:37:47Z")

</div>

omg, it works! how simple))) thank you so much, you save me a lot of time!
