title: Create PDF file from HTML text React
body: <p>I am beginner in react-redux.</p>
  
  <p>I trying create a function like exporting a html text to pdf with Javascript and it works with html, but when I apply it to react component, it doesn't work.</p>
  
  <p>This is my code:</p>
  
  <pre><code>import React from 'react';
  
  class App extends React.Component {
    constructor(props){
      super(props);
      this.pdfToHTML=this.pdfToHTML.bind(this);
    }
  
    pdfToHTML(){
      var pdf = new jsPDF('p', 'pt', 'letter');
      var source = $('#HTMLtoPDF')[0];
      var specialElementHandlers = {
        '#bypassme': function(element, renderer) {
          return true
        }
      };
  
      var margins = {
        top: 50,
        left: 60,
        width: 545
      };
  
      pdf.fromHTML (
        source // HTML string or DOM elem ref.
        , margins.left // x coord
        , margins.top // y coord
        , {
            'width': margins.width // max width of content on PDF
            , 'elementHandlers': specialElementHandlers
          },
        function (dispose) {
          // dispose: object with X, Y of the last line add to the PDF
          // this allow the insertion of new lines after html
          pdf.save('html2pdf.pdf');
        }
      )
    }
  
    render() {
      return (
        &lt;div&gt;
          &lt;div classID="HTMLtoPDF"&gt;
            &lt;center&gt;
              &lt;h2&gt;HTML to PDF&lt;/h2&gt;
             &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing &lt;/p&gt;
            &lt;/center&gt;
          &lt;/div&gt;
          &lt;button onClick={this.pdfToHTML}&gt;Download PDF&lt;/button&gt;
        &lt;/div&gt;
      );
    } 
  }
  
  export default App;
  </code></pre>
  
  <p>Javascript with HTML: <a href="https://www.youtube.com/watch?v=HVuHr-Q7HEs" rel="nofollow noreferrer">https://www.youtube.com/watch?v=HVuHr-Q7HEs</a></p>