Aspx 转 pdf jsPDF

Aspx to pdf jsPDF

我想使用 jsPDF 将我的表单 (Sharepoint) 转换为 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 创建图像 pdf 但我需要转换为本机格式。

谢谢

我之前的回答被删除了,所以如果有人觉得这有用:

jspdf 不支持 css,因此很难获得正确的格式。如果添加 html 作为图像对您不起作用 (),那么如果您选择使用这个特定的库,则单独添加文本部分似乎是唯一的方法。

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