# PGraphics not exporting to PDF

**URL:** <https://discourse.processing.org/t/pgraphics-not-exporting-to-pdf/42081>\
**Category:** Libraries\
**Created:** [May 26, 2023, 5:54pm UTC](https://discourse.processing.org/t/pgraphics-not-exporting-to-pdf/42081 "2023-05-26T17:54:24Z")\
**Posts on this page:** 1\
**Showing post:** 11

<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:** [May 28, 2023, 11:41pm UTC](https://discourse.processing.org/t/pgraphics-not-exporting-to-pdf/42081/11 "2023-05-28T23:41:02Z")

</div>

Hello @travis.stdenis ,

> [@travis.stdenis](#):
>
> adding the beginDraw() and endDraw() along with the addition of P2D as a parameter to the createGraphics() call.

Both of the _createGraphics()_ calls. `:)`

> [@svan](#):
>
> it changed the background color to pure white instead of the off colored yellow of the original code.

@svan,

The background should be applied between record calls to apply to final PDF (also to SVG):

```auto
void draw() 
  {
  //background(bg);
  beginRecord(PDF,"test.pdf");
  
  background(bg); //Background should be here to apply to PDF
  for(Cell c : voronCells)
    {
    c.render();
    }
  endRecord();
  }

```

> [@travis.stdenis](#):
>
> I have a sketch that I am trying to export to PDF so it can be plotted. I can export to SVG, but it doesn’t preserve any of the underlying vectors graphics, only exports embedded images so it isn’t much use for this application.

Check this out:

> [@Processing Geometry Suite](https://discourse.processing.org/t/processing-geometry-suite/29924):
>
> Processing Geometry Suite Hi everyone. I’m pleased to share something I’ve been working on the past few months – a 2D computational geometry that I’ve called Processing Geometry Suite. The focus of the library is on visualisation rather than providing underlying data structures and so all methods in the library are static and most of them take in and return PShapes or PVectors. I’ve made a real effort to make it easy to pick up – it’s well [documented](https://micycle1.github.io/PGS/micycle/pgs/package-summary.html), the Github is replete with gifs illust…

There may be something in there that will allow you to generate your shapes and create a PDF or SVG with [vector graphics](https://en.wikipedia.org/wiki/Vector_graphics) instead of [raster graphics](https://en.wikipedia.org/wiki/Raster_graphics).

I was able to export PDFs (with vector graphics) for one of the examples:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/b/eb78a401dceefcdd9cc02e88369a95a9a0e7b1dc.jpeg)

`:)`

---

_[View the full topic](https://discourse.processing.org/t/pgraphics-not-exporting-to-pdf/42081)._
