title: How to make pdf inclueded chart in spring framework? (report email)
body: <p>using skill : spring, chart.js, jsp, html2pdf</p>
  <p>I want to send a pdf with charts by report email.</p>
  <p><strong>current situation</strong></p>
  <ol>
  <li>I rendered html to pdf containing a chart(changed to image) made with chart.js in frontend(jsp).</li>
  <li>When the url is accessed, the pdf is sent to the server (spring) with the ajax declared in onload().</li>
  <li>I make an email with pdf attached in spring method.</li>
  </ol>
  <p>(ex)
  url '/chart' access -&gt; rendering html (included chart.js) -&gt; ajax() url : /test.js (return pdf to base64)</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>window.onload = function() {
      var chart0 = new Chart(document.getElementById("myChart0"), {
          // The type of chart we want to create
          type : 'line',
          // The data for our dataset
          data : {
              labels : [ 'January', 'Februggary', 'ggMarch', 'Aggpril', 'May',
                      'June', 'July' ],
              datasets : [ {
                  label : 'My First dataset',
                  backgroundColor : 'rgb(255, 99, 132)',
                  borderColor : 'rgb(255, 99, 132)',
                  data : [ 0, 10, 5, 2, 20, 30, 45 ]
              } ]
          },
  
          options : {
              animation : {
                  duration : 0
              }
          }
      });
      
      for ( var id in Chart.instances) {
          Chart.instances[id].resize();
          Chart.instances[id].draw('1s');
          Chart.instances[id].render('1s');
          document.getElementById("img" + id).src = Chart.instances[id]
                  .toBase64Image();
      }
  
      var element = document.getElementById('element-to-print');
      html2pdf().from(element).set({
          type:'png',
          margin: [50,0,50,0],
          filename : 'test.pdf',
          pagebreak : {
              mode : [ "css" ],
              after : [ ".break" ]
          },
          jsPDF: {
              unit: 'pt',
              format: 'a4', 
              orientation: 'portrait'
          }
      }).outputPdf().then(function(pdf) {
          // Convert to base 64
          var newpdf = btoa(pdf);
          console.log(pdf);
  
          $.ajax({
              url : 'test.json', // make email using pdf
              type : 'post',
              traditional : true,
              data : {newpdf:newpdf},
              success : function (data) {
                  if (data.result) {
                      alert("success");
                  } else {
                      alert("fail");
                  }
              }
          });
      });
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#element-to-print {
      width: 21cm;
      min-height: 29.7cm;
      padding: 1.5cm 1.5cm 2cm 1.5cm;
      /* margin: auto; */
  }
  
  #chartContainer {
      width: 80%;/* 
      margin: auto; */
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.8.1/html2pdf.bundle.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;script src="../resources/js/Chart.bundle.js"&gt;&lt;/script&gt;
  &lt;script src="../resources/js/jquery-3.5.1.min.js"&gt;&lt;/script&gt;
  &lt;script src="../resources/js/test.js"&gt;&lt;/script&gt;
  &lt;script src="../resources/js/html2pdf.bundle.min.js"&gt;&lt;/script&gt;
  &lt;link href="../resources/css/test.css" rel="stylesheet" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="element-to-print"&gt;
          &lt;div id="chartContainer"&gt;
              &lt;div&gt;
                  testtesttesttest
                  &lt;canvas id="myChart0" style="display: None"&gt;&lt;/canvas&gt;
                  test
              &lt;/div&gt;
              &lt;div class="break"&gt;
                  testtest
                  &lt;img id="img0" src="" /&gt;
          test test
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  <p><strong>question here</strong>
  I need to access the url with spring scheduler. how to access?
  OR
  Is there another way to create a pdf containing charts made with chart.js on the spring server or import it from the frontend?</p>