【问题标题】:Aspx to pdf jsPDFaspx 到 pdf jsPDF
【发布时间】:2017-12-17 00:50:21
【问题描述】:

我想使用 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 但我需要转换为本机格式之前。

谢谢

【问题讨论】:

    标签: jquery sharepoint jspdf


    【解决方案1】:

    我之前的回答已被删除,万一有人觉得这很有用:

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

    doc.text('我的文字', 287.64, 415, 'center');

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-04
      • 2016-08-27
      • 2013-01-04
      • 1970-01-01
      相关资源
      最近更新 更多