Aspx到pdf jsPDF

我想用jsPDF将我的表单(Sharepoint)转换为pdf,但我有一个问题……

表单页面

结果:

PDF

你能帮助我吗 ?

我的代码:

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 = $('.JsPDF tbody')[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: 10, width: 700 }; // 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); 

}

在我使用spform转换我的表单但spform create image pdf但我需要转换为本机格式之前。

谢谢

我的上一个答案已被删除,以防有人发现这个有用:

jspdf不支持css,因此很难获得正确的格式。 如果添加html作为图像不适合您( https://stackoverflow.com/a/43064789/7751910 ),那么如果您选择使用此特定库,则单独添加文本部分似乎是唯一的方法。

doc.text(’my text’,287.64,415,’center’);