Saving canvas in PDF

Here is a minimal example that is not working:

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;
  }
}

<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:


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.

Thanks for help.