I am attempting to start a project where I can easily edit the DocDefinitions for pdfmake. I have the initial code shared on GitHub if anyone is interested in having a look: https://github.com/unluckynelson/pdfmake-generator
Here is a demo of what I have: http://powerprop.co.za/pdfmake-generator/
The idea is basically to give the user the ability to edit a TinyMCE textarea and display the results of the generated pdf on the same page, thus making visual edits very easy to do and update.
My question is: Is there any way of parsing the HTML? (generated from TinyMCE) into a Javascript object, for example a simple table would look like this:
HTML text
<html>
<table class="table table-condensed">
<tr>
<td>Some text
<div>Nested Div</div>
</td>
<td></td>
</tr>
</table>
</html>
Parsed as a JS object:
var obj = {
html: {
table: {
classes: ["table", "table-condensed"],
styles: [],
tr: [
{
td: {
classes: [],
styles: [],
text: [{"Some text "}, {
div: {
classes: [],
styles: [],
text: "Nested Div"
}
}]
}
},
{
td: {
classes: [],
styles: [],
text: []
}
}
]
}
}
}