我正在使用jspdf生成pdf.Its正常工作,但文件下载到"下载" folder.but我想下载这样的特定文件夹(" localhost / ccs / ccs / invoice")文件夹路径,以保存生成的pdf.how以解决我的代码中的更改。我的示例代码是
<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 :(得分:0)
您可以使用&#39; FileSaver.js&#39;与jspdf.js一起,它将帮助您将pdf保存在您喜欢的特定文件夹中。
var pdf = new jsPDF();
// your code here to write something in to pdf.
pdf.save(fileName);