DocRaptor Home
PDF Code Examples

Code Example: Google Charts Pie Chart

Here's a functioning code example of how to make a PDF that uses a Google Chart Pie Chart:

    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Work',     11],
          ['Eat',      2],
          ['Commute',  2],
          ['Watch TV', 2],
          ['Sleep',    7]

        var options = {
          title: 'My Daily Activities'

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        chart.draw(data, options);
    <script type="text/javascript">
      var didWait = false;
      // DocRaptor polls docraptorJavaScriptFinished until it is true
      docraptorJavaScriptFinished = function() {
        if (! didWait) {
            didWait = true;
          }, 10000);
          return false;
        document.body.appendChild(document.createTextNode("JavaScript inserted this text."));
        return true;
    This is an example Google Charts Pie Chart.
    <div id="piechart" style="width: 900px; height: 500px;"></div>

Ready to get started? Try DocRaptor for free with unlimited test documents.