# Saving canvas in PDF

**URL:** <https://discourse.processing.org/t/saving-canvas-in-pdf/3025>\
**Category:** Libraries\
**Created:** [August 27, 2018, 4:12pm UTC](https://discourse.processing.org/t/saving-canvas-in-pdf/3025 "2018-08-27T16:12:06Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![HEX0x6C](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hex0x6c/32/1251_2.png) [@HEX0x6C](https://discourse.processing.org/u/HEX0x6C)\
**Post date:** [August 28, 2018, 6:24am UTC](https://discourse.processing.org/t/saving-canvas-in-pdf/3025/10 "2018-08-28T06:24:05Z")

</div>

Here is a _minimal_ example that is **not** working:

```auto
var sign = true;

function setup() {
  var myCanvas = createCanvas(400, 400, SVG);
  myCanvas.parent("myContainer");
  pdf = createPDF();
  pdf.beginRecord();
}

function draw() {
  fill(0, 0, 255);
  ellipse(width/2, height/2, width/2, height/2);
  if (sign) {
    pdf.save( {
    filename: 
      "ethercoil.pdf"
    }
    );
    sign = false;
  }
}

```

```auto

<html>
  <head>
  <meta charset="UTF-8">

  <!-- PLEASE NO CHANGES BELOW THIS LINE (UNTIL I SAY SO) -->
  <script language="javascript" type="text/javascript" src="libraries/p5.js"></script>
  <script language="javascript" type="text/javascript" src="libraries/p5.pdf.js"></script>
  <script language="javascript" type="text/javascript" src="libraries/p5.svg.js"></script>
  <script language="javascript" type="text/javascript" src="EtherCoilTest.js"></script>
  <!-- OK, YOU CAN MAKE CHANGES BELOW THIS LINE AGAIN -->
  <title>EtherCoil</title>  

  </head>

  <body>
  <h1>EtherCoil</h1>

  <div style = "text-align: center;" id="myContainer"></div>

  </body>
</html>

```

Error is:

```auto

Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
    at RendererSVG.p5.Element.parent (p5.js:10984)
    at setup (EtherCoilTest.js:5)
    at p5.<anonymous> (p5.js:9111)
    at p5.<anonymous> (p5.js:9041)
    at new p5 (p5.js:9323)
    at _globalInit (p5.js:5602)

```

I am using PDE in P5 mode. I adapted the code from [this](http://zenozeng.github.io/p5.js-pdf/examples/#vector).

Thanks for help.

---

_[View the full topic](https://discourse.processing.org/t/saving-canvas-in-pdf/3025)._
