0
Ich versuche, meine HTML-Datei als pdf zum Herunterladen und i enthalten diese:nicht in der Lage mit jspdf html pdf zu exportieren
<script src="http://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.js" ></script>
und das ist mein js:
<script type="text/javascript">
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 = $('#content')[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('Test.pdf');
}, margins);
}
und das ist meine html-taste:
<div class="page-container container"><button id="cmd">generate PDF</button>
</div>
ich versuche zu exportieren, was auch immer es in der in pdf ist - aber meine Schaltfläche tut eigentlich nichts. meine Konsole gibt mir diesen Fehler:
parall.ax/products/jspdf/dist/jspdf.debug.js:1 Uncaught SyntaxError: Unexpected token <
parall.ax/products/jspdf/dist/jspdf.debug.js:1 Uncaught SyntaxError: Unexpected token <
Ich habe so viele Beispielcodes versucht, aber keiner von ihnen funktioniert.
es nicht dort zu – user6485186
http://www.techumber.com/2015/04/html-to-pdf-conversion-using-javascript.html – Ranjan
I \t techumber.com/ heruntergeladen Arbeits 2015/04/code und ich starte es auf localhost, das funktioniert auch nicht in chrom oder mozilla! – user6485186