喜上输入的,我期待创造一个按钮,将捕获的PDF格式的用户数据。这一操作将需要被保存并通过电子邮件发送(附加图像是需要被包括在该PDF文件上的内容的示例)
我此刻的代码是用HTML &的JavaScript
喜上输入的,我期待创造一个按钮,将捕获的PDF格式的用户数据。这一操作将需要被保存并通过电子邮件发送(附加图像是需要被包括在该PDF文件上的内容的示例)
我此刻的代码是用HTML &的JavaScript
有很多的选项。
您可以使用jsPDF,phantomJS jsPDF
的例小提琴
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 = $('#customers')[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);
}
我很抱歉,我不能尚未置评。我发现了另一个堆栈溢出上使用JavaScript创建PDF虽然generating a PDF with JS
对于事后通过电子邮件发送它,我相信你可以使用JavaScript的mailto JavaScript mailto function,我相信这是一个“&附件”参数。 对于发送电子邮件,虽然它可能会更好地通过像nodejs这样的服务器来实现,该节点具有nodemailer模块。
尝试在答案中包含一些外部链接的内容,以防链接失效。 –