Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a border setting for paragraph #406

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions examples/word/make_docx.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ pObj.addText('Those two lines are in the same paragraph,')
pObj.addLineBreak()
pObj.addText('but they are separated by a line break.')

pObj = docx.createP({border:{
bottom:{
color: '000088',
val: 'dashed',
space: "8",
sz : '4'
}
},})
pObj.addText('This is a paragraph with a bottom border, and the blue dotted lines are spaced 8. You can also extend the border in other directions.')
pObj = docx.createP({border:{
left:{},
right:{},
top:{},
bottom:{}
},})
pObj.addText('This is a paragraph with a border around it,top right bottom left')

docx.putPageBreak()

pObj = docx.createP()
Expand Down
21 changes: 20 additions & 1 deletion lib/docx/gendocx.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,26 @@ function makeDocx(genobj, new_type, options, gen_private, type_info) {
objs_list[i].options.backline +
'" w:fill="auto"/></w:pPr>'
} // Endif.

if (objs_list[i].options.border) {
pPrData +='<w:pBdr>'
var directions = ['top','bottom','left','right']
var szDef = 4
var spaceDef = 8
var valDef = 'single'
var colorDef = '000000'
for (var direction of directions) {
if(objs_list[i].options.border[direction]){
var borderSetting = objs_list[i].options.border[direction]
var val = borderSetting.val ||valDef
var sz = borderSetting.sz ||szDef
var space = borderSetting.space ||spaceDef
var color = borderSetting.color ||colorDef
pPrData += '<w:' + direction + ' w:val="' + val + '" w:sz="' + sz + '" w:space="'+space
+ '" w:color="' + color + '"/>'
}
}
pPrData += '</w:pBdr>'
}
if (objs_list[i].options.spacing) {
var pSpacing = objs_list[i].options.spacing
if (typeof pSpacing === 'object') {
Expand Down