title: to apply word wrap for the long dynamic text
body: <p>I am working on angularjs application with jsPDF API to export the content to the PDF file. I have a issue when the text is long to show in the PDF, when the text is long complete sentence is not shown in the generated PDF as seen in the demo link below. I want to apply word wrap so that all the content is displayed in the PDF file.</p>
  
  <p>Check the online demo here : <a href="https://plnkr.co/edit/w7fZsdFbbRYctK5tWv5u?p=preview" rel="nofollow noreferrer">https://plnkr.co/edit/w7fZsdFbbRYctK5tWv5u?p=preview</a></p>
  
  <p>Code demo:</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> var app = angular.module("app", []);
  
   app.controller("myController", ["$scope",
     function($scope) {
     
     $scope.export = function() {
  
         // var pdf = new jsPDF('landscape');
         var pdf = new jsPDF('p','pt','a4');
          var pdfName = 'test.pdf';
  
          var options = {   pagesplit: true};
  
          var $divs = $('.myDivClass')                
          var totalDiv = $divs.length -1;     
          var currentRecursion=0;
  
          function recursiveAddHtmlAndSave(currentRecursion, totalRecursions){
              //Once we have done all the divs save the pdf
              if(currentRecursion==totalRecursions){
                  pdf.save(pdfName);
              }else{
                  currentRecursion++;
                  pdf.addPage();
                  pdf.fromHTML($('.myDivClass')[currentRecursion], 15, 20, options, function(){
                      recursiveAddHtmlAndSave(currentRecursion, totalRecursions)
                  });
              }
          }
  
          pdf.fromHTML($('.myDivClass')[currentRecursion], 15, 20, options, function(){
              recursiveAddHtmlAndSave(currentRecursion, totalDiv);
          });
      }
     }
   ]);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html ng-app="app"&gt;
  
  &lt;head&gt;
  &lt;link data-require="bootstrap-css@3.2.0" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" /&gt;
      &lt;link rel="stylesheet" href="style.css" /&gt;
       
  &lt;script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.33/vfs_fonts.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.min.js"&gt;&lt;/script&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div ng-controller="myController"&gt;
          &lt;button ng-click="export()"&gt;Export&lt;/button&gt;
  
     &lt;div class="myDivClass" style="background-color:white"&gt;
  
  The identity of the longest word in English depends upon the definition of what constitutes a word in the English language, as well as how length should be compared. In addition to words derived naturally from the language's roots (without any known intentional invention), English allows new words to be formed by coinage and construction; place names may be considered words; technical terms may be arbitrarily long. Length may be understood in terms of orthography and number of written letters, or (less commonly) 
  
    &lt;/div&gt;&lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have checked the API, and there is splitTextToSize(..) as shown here <a href="https://stackoverflow.com/questions/24272058/word-wrap-in-generated-pdf-using-jspdf">Word wrap in generated PDF (using jsPDF)?</a> but confused to apply the same in my existing code, as if you see my js code shown above <code>$scope.export</code> i'm iterating the div's to get the dynamic data and then called  <code>pdf.save(pdfName)</code>. Can anyone provide the solution, Online demo link is also shared.</p>
  
  <p>PS:I may have text, images,and any other html tags in my div(myDivClass).</p>