在角应用程序中将页面导出为pdf

时间:2015-05-31 18:59:00

标签: javascript angularjs pdf export

我正在寻找一个很好的选择,可以使用angular在我的每个应用页面上导出pdf功能。有没有人对角度模块有任何建议可以实现这一点,因为我找不到任何基于角度的模块。

1 个答案:

答案 0 :(得分:0)

您应该使用此angular-save-html-to-pdf

   //Here goes your script in html file
   <script src="../bower_components/angular/angular.js"></script>
   <script src="../bower_components/jquery/dist/jquery.min.js"></script>
   <script src="https://cdn.rawgit.com/niklasvh/html2canvas/0.5.0-alpha2/dist/html2canvas.min.js"></script>
   <script src="../bower_components/jsPDF/dist/jspdf.debug.js"></script>
   <script src="../dist/saveHtmlToPdf.min.js"></script>

    //Add this module to your angular app :
    var app = angular.module('app' , ['htmlToPdfSave']) ;

     //This is your html file
    <button pdf-save-button="idOneGraph" pdf-name="hello.pdf" class="btn">Hello World</button>

     <!-- below block will be saved as pdf -->

     <div pdf-save-content="idOneGraph" >
              Hello World
         </div>