将Aspx转换为pdf jsPDF [英] Aspx to pdf jsPDF

查看:131
本文介绍了将Aspx转换为pdf jsPDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用jsPDF将表单(Sharepoint)转换为pdf,但是我有问题...

I want to convert my form (Sharepoint) to pdf with jsPDF but i have a problem ...

结果:

你能帮我吗?

我的代码:

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,但是我需要转换为本机格式.

Before i used spform to convert my form but spform create image pdf but i need convert to native format.

谢谢

推荐答案

我之前的答案已删除,因此以防万一有人觉得有用:

My previous answer was deleted, so in case someone finds this useful:

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

jspdf don't support css, so it can be hard to get the right format. If adding html as an image doesn't work for you (https://stackoverflow.com/a/43064789/7751910), then adding text parts separately seems the only way if you choose to work with this particular library.

doc.text('我的文本',287.64,415,'居中');

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

这篇关于将Aspx转换为pdf jsPDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆