Skip to content Skip to sidebar Skip to footer

Convert Html Table To Word Document 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 coo

Solution 1:

The author of jsPdf made a document generator for Microsoft Word documents in Pure client-side JavaScript called DOCX.js and recommends 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 come 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 StringlastModifiedBy: "Last person to modify", // optional Stringcreated: newDate(), // optional Date Objectmodified: newDate() // 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);

Post a Comment for "Convert Html Table To Word Document Or Editable Pdf"