pdfmake - how do you make labels?
We have an online webapp, which we use pdfmake for reports. However we also want to do labels. We do have the label data going to a report size pdf right now. How can that be reduced to make a label? Or what is the best way to do this? I am very new to pdfmake, so please take that into consideration when answering. :)
+1
If I correctly understand, you want to adjust the page size of your PDF? see http://pdfmake.org/#/gettingstarted at the bottom of the page If your need is to make a page with many labels on it, you should consider the columns property : for example, something like {columns : [{text : 'mylabel1'},{text : 'mylabel2'},{text : 'mylabel2'}]} would put 3 labels on a line. Hope it helps...
@bhericher So for labels (single) the recommended way of doing that is something like
pageSize: { width: 2.4 * 72, height: 1.8 * 72 }
And if you want to run multiple labels would the page size just be a full sheet? If so what else is needed to get {text : 'mylabel1'} put into the label one position and {text : 'mylabel2'} in the second position. The reason I ask this is because label vary in width (and height).
Also What is the measurement in when you are doing the 2.4 or 1.8 like above? I'm not sure what pdfmake uses as their measurement
For multiple labels can be used table.
After this being closed, I would assume that pdfmake can't make a full sheet of labels because you can't set a column property for the various sizes?
Example with table:
var dd = {
content: [
{
table: {
widths: [150, 100, 120],
body: [
[{text : 'mylabel1'}, {text : 'mylabel2'}, {text : 'mylabel3'}],
[{text : 'mylabel4'}, {text : 'mylabel5'}, {text : 'mylabel6'}],
]
}
},
]
}
Width of columns can be set by using widths property; and height is by content.
Thank you so much, just what we needed 👍 here at nickysoft
Hello liborm85, i Know that is an old question. But i need help to make labels dynamically, the labels suppose to be horizontal 5 by row My Code: `static label(tob: any[]) {
return {
content: [
{
table: {
headerRows: 0,
heights: [50],
widths: [100, 100, 100, 100, 100, 100],
body: [
...tob.map(
(sp) => {
return [
{
height: 150,
width: 50,
fillColor: '#bada55',
// pageBreak: 'after',
text: [
{
text: sp.name + '\n'
},
{
text: sp.product + '\n'
},
{
text: sp.pp + '\n'
},
{
// text: sp.saleDate + '\n'
text: 'sp.saleDate' + '\n'
},
]
}
];
}),
]
}
},
]
};
}` and what I'm experting in red
