0
Я пытаюсь загрузить мой HTML файл в формате PDF и я включил этот:не удалось экспортировать HTML в PDF с jspdf
<script src="http://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.js" ></script>
и это мой ЯШ:
<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);
}
и это моя кнопка html:
<div class="page-container container"><button id="cmd">generate PDF</button>
</div>
Я пытаюсь экспортировать все, что находится в в pdf, но моя кнопка фактически ничего не делает. моя консоль дает мне эту ошибку:
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 <
Я пробовал столько образцов кода, но ни один из них не работает.
он не работает там слишком – user6485186
http://www.techumber.com/2015/04/html-to-pdf-conversion-using-javascript.html – Ranjan
Я скачал \t techumber.com/ 2015/04/code и я запускаю его на localhost, это также не работает ни в хром, ни в мозилле! – user6485186