parser for proseMirror to pdfmake. It formats the proseMirror json to a pdfMake json structure.
// viewData is the data that comes from proseMirror
// prosePdf.parser(data, defaultFontSize), defaultFontSize is optional and it defaults to 10
var data = data.state.doc.toJSON();
var pdfMakeJson = prosePdf.parser(data);
// in pdfmake playground: http://pdfmake.org/playground.html
var dd = { content: pdfMakeJson }
It takes all marks and creates a "style" for each. In pdfmake you need to create a styles object that corresponds to the marks in proseMirror ie: for bold, if you use have a b: {bold:true}, if you use , have b:{bold true} etc. See what options you have in pdfmake decorations and expand your styles object as needed.
styles: {
b: {
bold: true
},
i: {
italics: true
},
u: {
decoration: 'underline'
},
a: {
color: "blue",
decoration: 'underline'
},
mark: {
background: "yellow",
},
- plain text
- formated text with bold, italic, underline, mark etc
- links
- horizontal lines
- headings
- parse tables
- parse lists
- parse columns
- parse images (they need to be tranformed to base64 in order to work with pdfmake)