2014-12-18 2 views
0

jspdf를 사용하여 pdf.Its 작업을 생성하고 있지만이 파일은 "다운로드"folder.but로 다운로드됩니다.이 같은 특정 폴더 ("localhost/ccs/ccs/인보이스 ") 폴더 경로를 생성 코드를 변경하려면 pdf.how를 생성합니다. 내 예제 코드는Jspdf 파일을 특정 폴더에 저장하는 방법

<div class="invoice" id="customers" ng-repeat="aim in input"> 
<div align="right"><h1 align="right"><b>INVOICE</b> </h1></div> 
<table> 
    <tr> 
     <td> 
      Hello 
     </td> 
     <td> 
      Hi 
     </td> 
    </tr> 
</table> 
</div> 
<button onclick="javascript:demoFromHTML();">PDF</button> 

내 스크립트 코드가

<script> 
function demoFromHTML() { 
    var pdf = new jsPDF('p', 'pt', 'letter'); 
    // source can be HTML-formatted string, or a reference 
    // to an actual DOM element from which the text will be scraped.  
    source = $('#customers')[0]; 

    // we support special element handlers. Register them with jQuery-style 
    // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.) 
    // There is no support for any other type of selectors 
    // (class, of compound) at this time. 
    specialElementHandlers = { 
     // element with id of "bypass" - jQuery style selector 
     '#bypassme': function (element, renderer) { 
      // true = "handled elsewhere, bypass text extraction" 
      return true 
     } 
    }; 

    margins = { 
     top: 80, 
     bottom: 60, 
     left: 40, 
     width: 522 
    }; 
    // all coords and widths are in jsPDF instance's declared units 
    // 'inches' in this case 
    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('Invoice.pdf'); 
    }, margins); 
} 
</script> 
<script type="text/javascript" src="http://mrrio.github.io/jsPDF/dist/jspdf.debug.js"> </script> 

감사합니다입니다.

+0

가능한 중복 [파일 다운로드에 대한 새 폴더를 만들려면 방법] (http://stackoverflow.com/questions/22335988/how-to-create-a-new-folder-for-downloading- 파일) – mvuajua

답변

0

jspdf.js와 함께 'FileSaver.js'를 사용할 수 있으므로 원하는 폴더에 PDF를 저장할 수 있습니다.

var pdf = new jsPDF(); 

// your code here to write something in to pdf. 

pdf.save(fileName); 
관련 문제