PDF object structure: Documentation unclear
The reference for this is separated out into dev, examples and the readme. It's very difficult to find simple things. Here's maybe a better way to do this (this is what I've collected so far). Please put this somewhere where someone can find it, or direct me to a more concise documentation for the properties of the PDF object:
PROPERTIES FOR PDF OBJECT
content: [
'string' (implicitly creates text with no styling)
{
any of the style properties
text: 'string'
table: {
headerRows: number, (number of rows to be treated as a header [and repeated across pages])s
dontBreakRows: boolean,
widths: ['*'|'number%'|number, ...] (one for each column, column count must match)
body: [[column_1, column_2, ..., column_n], ...],
layout: {
hLineWidth: function(i, node) { return number; },
vLineWidth: function(i, node) { return number; },
hLineColor: function(i, node) { return 'colorName'; },
vLineColor: function(i, node) { return 'colorName'; },
padding[Left|Right|Top|Bottom]: function(i, node) { return number; }
} | 'noBorders' (may be more)
}
stack: [anything under content] (this is used to group elements so they can be styled together)
ul: [item_1, item_2, ..., item_n] (item can be anything under content)
ol: [item_1, item_2, ..., item_n] (item can be anything under content)
width: number|'number%'|'*'(all available space)
height: number
absolutePosition: { x: number, y: number }
pageBreak: 'after'|'before' (may be more)
decoration (for text): 'underline'|'lineThrough'|'overline'
decorationStyle (for text): 'dashed'|'dotted'|'double'|'wavy'
decorationColor (for text): 'colorName'
background (for text): 'colorName'
fillColor (for text, stack): 'colorName'
canvas: [{
type: 'rect'|'polyline'|'line'|'ellipse',
properties differ for drawing (https://github.com/bpampuch/pdfmake/blob/master/examples/vectors.js)
}]
}
]
styles: {
'styleName': {
fontSize: number
italics: boolean
bold: boolean
alignment: 'left'|'right'|'center'|'justify' (may be more)
margin: [number (left), number (top), number (right), number (bottom)]
color: 'colorName'
noWrap: boolean
}
}
images: {
imageName: 'URI'
}
*/
From my understanding, content is an array of objects that host child objects that handle properties. So, the implicit layout is necessary for converting to a formatted PDF. What exactly are you trying to make though? The situation depends on the format.
I'm just saying that knowing the possible property names and the properties of those properties is very difficult just looking at the code. There's no central place where there's a PDFObject definition like what I have above, that describes its structure. If you were looking for an HTML reference it wouldn't be spread across several tens of examples.
I'll just give up.
+1 KthProg is right, from my point of view
+1
Un-giving up due to some support lol
I agree with the idea, this could be much more clear. I can look into expanding the documentation, I just don't have much time at the moment.
@KthProg Thanks already for this much needed list. I learned quite a bit from your list and don't know any other features (yet...)
Will be included in the new documentation. Issue: https://github.com/bpampuch/pdfmake/issues/1238
columns and relativePosition also belong within the content Array.
Thanks god I found this Uri.... was wasting hours looking at the documentation to produce a decent summary of all the properties and combinations.
Just reach this doing a search on goole about 'pdfmake object structure' Cannot bealive how magic the plugin is and the lack of instructions about the Main object.
As a side note.. a good explanation on how to add images from local folders or external links is also missing... It says... in case you use virtual file system provided by pdfmake... but that provided virtual file system is not exposed in a single line of the docs.
I feel you had summarized all pretty well.... In fact this must be the landing page at the top of the docs with hyperlinks for each part and pointing to the examples that´s already documented there.
I also found a super interesting example that should be included directly in the pdfmake website.
How does pdfmake work with dynamic data?
Thanks for the work KthProg!!
Thanks for this summary, @KthProg The new documentation is nice, but you need a quick reference summary like this as well.