title: How to save / export a XPlot Plotly or Google Chart to PDF / image (F#)?
body: <p>when I create a chart in XPlot (F#) with Plotly (or Google Charts) like this</p>
  
  <pre><code>let trace =
      Scatter(
          x = [1; 2; 3; 4],
          y = [10; 15; 13; 17]
      )
  let chart = Chart.Plot trace
  Chart.Show chart
  </code></pre>
  
  <p>How can I export the chart as PDF or image file?</p>
  
  <p>Thanks very much!</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I can get the HTML string and export it as follows</p>
  
  <pre><code>let chartHtml = chart.GetHtml()
  System.IO.File.WriteAllText("C:/temp/chart.html", chartHtml)
  </code></pre>
  
  <p>Next I need to figure out how to transform the HTML into a PNG or a PDF. Any ideas?</p>
  
  <p><strong>2nd update:</strong></p>
  
  <p>I tried using several HTML-to-PDF converter libraries, including</p>
  
  <ul>
  <li><p><a href="https://www.nuget.org/packages/OpenHtmlToPdf/" rel="nofollow noreferrer">OpenHtmlToPdf</a></p></li>
  <li><p><a href="https://www.nuget.org/packages/Select.HtmlToPdf/" rel="nofollow noreferrer">Select.HtmlToPdf</a> (see suggestion by @Jeff_hk below)</p></li>
  </ul>
  
  <p>Unfortunately, those don't do the job. I guess that the support for JavaScript is limited. The HTML output from XPlot imports the Plotly library (JS).</p>
  
  <p>For now I'm using <a href="https://fslab.org/FSharp.Charting/" rel="nofollow noreferrer">FSharp.Charting</a> that comes with its own export methods, but is less versatile.</p>
  
  <p>Any other suggestions are still welcome! Thanks</p>