Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
42
rated 0 times [  44] [ 2]  / answers: 1 / hits: 19875  / 9 Years ago, wed, april 29, 2015, 12:00:00

I'm generating pdf via pdfmake.



Let's say i have content of the pdf like this



var docDefinition = {
content: [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a pharetra odio.',
'Vestibulum erat mauris, sodales et consequat sit amet, ultricies vitae erat. Etiam feugiat orci justo, ultrices malesuada dui ornare ac.',
]
};


Is it possible to add border arround one of the paragraphs or do I have to use tables for this?


More From » pdf

 Answers
9

I have not gotten apply borders to a paragraph. I think the only option you have is to use tables.



Below this lines I have attached a simple code that you can paste directly at pdfmake playground in order to try it.



var dd = {
content: [
{
style: 'tableExample',
color: '#555',
table: {
body: [
[
{
text : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a pharetra odio.nnVestibulum erat mauris, sodales et consequat sit amet, ultricies vitae erat. Etiam feugiat orci justo, ultrices malesuada dui ornare ac.'
}
],
[
{
text : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a pharetra odio.nnVestibulum erat mauris, sodales et consequat sit amet, ultricies vitae erat. Etiam feugiat orci justo, ultrices malesuada dui ornare ac.'
}
],
[
{
text : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a pharetra odio.nnVestibulum erat mauris, sodales et consequat sit amet, ultricies vitae erat. Etiam feugiat orci justo, ultrices malesuada dui ornare ac.'
}
],
]
},
layout: {
//hLineWidth: function(i, node) {
// return (i === 0 || i === node.table.body.length) ? 2 : 1;
//},
//vLineWidth: function(i, node) {
// return (i === 0 || i === node.table.widths.length) ? 2 : 1;
//},
hLineColor: function(i, node) {
return (i === 0 || i === node.table.body.length) ? 'red' : 'blue';
},
vLineColor: function(i, node) {
return (i === 0 || i === node.table.widths.length) ? 'red' : 'blue';
},
paddingLeft: function(i, node) { return 40; },
paddingRight: function(i, node) { return 40; },
paddingTop: function(i, node) { return 20; },
paddingBottom: function(i, node) { return 20; }
}
}
],

defaultStyle: {
alignment: 'justify'
}

}

[#66835] Tuesday, April 28, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jennie

Total Points: 593
Total Questions: 102
Total Answers: 106

Location: Federated States of Micronesia
Member since Fri, Sep 16, 2022
2 Years ago
jennie questions
;