title: Value cannot be null. Parameter name: elementId in PDFsharp
body: <p>I am working on Export to PDF funtionality using C# and PDFSharp. I am getting this error:</p>
  
  <pre><code>Value cannot be null.
  Parameter name: elementId
  </code></pre>
  
  <p>The error is on this line : 
  <code>PdfDocument document = PdfGenerator.GeneratePdf(htmlcontenttbl.ToString(), PdfSharp.PageSize.A4, 30);</code></p>
  
  <p>Here's the whole method:</p>
  
  <pre><code>public bool ExportPdf(string htmlcontenttbl)
      {
          Response.ClearContent();
          Response.ClearHeaders();
  
          Response.Buffer = true;
          Response.ContentType = "application/octet-stream";
          Response.AddHeader("Content-Disposition", "attachment;filename=Myfile.pdf");
          //Response.AddHeader("Content-Disposition", "inline;filename=file.pdf");
          //Response.AppendHeader("Content-Disposition", "attachment; filename=Myfile.pdf");
          Response.Charset = "";
          StringWriter sw = new StringWriter();
          HtmlTextWriter htw = new HtmlTextWriter(sw);
  
          PdfDocument document = PdfGenerator.GeneratePdf(htmlcontenttbl.ToString(), PdfSharp.PageSize.A4, 30);
          var config = new PdfGenerateConfig();
          config.PageOrientation = PageOrientation.Landscape;
          config.PageSize = PageSize.A4;
          config.MarginBottom = 30;
          config.MarginTop = 30;
          //PdfDocument document = PdfGenerator.GeneratePdf(htmlcontenttbl, config);
  
          byte[] bytes = null;
          using (MemoryStream stream = new MemoryStream())
          {
              document.Save(stream, true);
              bytes = stream.ToArray();
          }
  
          //var path1 = Server.MapPath("~/Images/" + DateTime.Now.TimeOfDay.Ticks + "result.pdf");
          //System.IO.File.WriteAllBytes(path1, bytes);
          //Response.TransmitFile(path1, 0, bytes.Length);
          //Response.OutputStream.Write(bytes, 0, bytes.Length);
  
          Response.BinaryWrite(bytes);
          Response.Flush();
          Response.End();
  
          return true;
      }
  </code></pre>