I am currently using PHPWord to generate my documents, but I want to add an horizontal line in the document. Just like an
Does anybody have more information about this feature?
Thank you!
I decompressed the '.docx' file, found closest xml tag is 'w:pBdr'.
<w:pBdr><w:bottom w:val="single" w:sz="6" w:space="0" w:color="auto"/></w:pBdr>
So, I insert a horizontal line by ParagraphStyle.
$section->addText('', [], ['borderBottomSize' => 6]);
It's also possible to add a horizontal line to a section, instead of adding a border:
$section->addLine(['weight' => 1, 'width' => 600, 'height' => 0]);
Note that the width is in pixels, which is the main disadvantage of this method. You need to know what the width of your page (minus the margins) is in pixels. If you set it to some large number then the line will just continue through to the right side of your page, ignoring the margin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With