admin管理员组文章数量:1025494
I have been using jquery datatable and jsPDF, for exporting html table to pdf using codes like
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
}
Is there a javascript library to export the html table to word document(preferred) or editable pdf?
I have been using jquery datatable and jsPDF, for exporting html table to pdf using codes like
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
}
Is there a javascript library to export the html table to word document(preferred) or editable pdf?
Share Improve this question asked May 2, 2016 at 13:42 Vignesh SubramanianVignesh Subramanian 7,30914 gold badges96 silver badges158 bronze badges 5- 1 The author of jsPdf made github./MrRio/DOCX.js or could you do it serverside? – pce Commented May 2, 2016 at 13:48
- thanks for the lead, I am looking for a client side solution for document generation – Vignesh Subramanian Commented May 2, 2016 at 13:53
- 1 github./MrRio/DOCX.js is client side – pce Commented May 2, 2016 at 13:54
- sure, checking it now :) – Vignesh Subramanian Commented May 2, 2016 at 13:56
- @pce Can you post it as answer, so that I can accept it as answer? I used DOCX generator and its working fine – Vignesh Subramanian Commented May 20, 2016 at 8:51
1 Answer
Reset to default 3The author of jsPdf made a document generator for Microsoft Word documents in Pure client-side JavaScript called DOCX.js and remends the usage of Stephen Hardy's DOCX.js.
DOCX.js depends on JSZip and supports the writing of bold, italic, underline, strikethrough, subscript, superscript, font sizes, font color, highlights, and horizontal alignment. For reading, it supports all of the above plus embedded PNGs. Support for tables and lists (bulleted and numbered) will likely e in the future, but is not currently present.
Demo-Usage of ZerdaH's Fork:
var docDOM = document.getElementById('example');
var docObject = docx.export(docDOM, // required DOM Object
{
creator: "Creator", // optional String
lastModifiedBy: "Last person to modify", // optional String
created: new Date(), // optional Date Object
modified: new Date() // optional Date Object
});
var link = document.createElement('a');
link.appendChild(document.createTextNode("Download Link Text"));
link.title = "Download Title";
link.download = "FilenameHere.docx";
link.href = docObject.href();
document.getElementById("example").appendChild(link);
I have been using jquery datatable and jsPDF, for exporting html table to pdf using codes like
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
}
Is there a javascript library to export the html table to word document(preferred) or editable pdf?
I have been using jquery datatable and jsPDF, for exporting html table to pdf using codes like
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
}
Is there a javascript library to export the html table to word document(preferred) or editable pdf?
Share Improve this question asked May 2, 2016 at 13:42 Vignesh SubramanianVignesh Subramanian 7,30914 gold badges96 silver badges158 bronze badges 5- 1 The author of jsPdf made github./MrRio/DOCX.js or could you do it serverside? – pce Commented May 2, 2016 at 13:48
- thanks for the lead, I am looking for a client side solution for document generation – Vignesh Subramanian Commented May 2, 2016 at 13:53
- 1 github./MrRio/DOCX.js is client side – pce Commented May 2, 2016 at 13:54
- sure, checking it now :) – Vignesh Subramanian Commented May 2, 2016 at 13:56
- @pce Can you post it as answer, so that I can accept it as answer? I used DOCX generator and its working fine – Vignesh Subramanian Commented May 20, 2016 at 8:51
1 Answer
Reset to default 3The author of jsPdf made a document generator for Microsoft Word documents in Pure client-side JavaScript called DOCX.js and remends the usage of Stephen Hardy's DOCX.js.
DOCX.js depends on JSZip and supports the writing of bold, italic, underline, strikethrough, subscript, superscript, font sizes, font color, highlights, and horizontal alignment. For reading, it supports all of the above plus embedded PNGs. Support for tables and lists (bulleted and numbered) will likely e in the future, but is not currently present.
Demo-Usage of ZerdaH's Fork:
var docDOM = document.getElementById('example');
var docObject = docx.export(docDOM, // required DOM Object
{
creator: "Creator", // optional String
lastModifiedBy: "Last person to modify", // optional String
created: new Date(), // optional Date Object
modified: new Date() // optional Date Object
});
var link = document.createElement('a');
link.appendChild(document.createTextNode("Download Link Text"));
link.title = "Download Title";
link.download = "FilenameHere.docx";
link.href = docObject.href();
document.getElementById("example").appendChild(link);
本文标签: javascriptconvert html table to word document or editable pdfStack Overflow
版权声明:本文标题:javascript - convert html table to word document or editable pdf - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745630744a2160149.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论