Write Modify Page Footer Borders
The ooodev.format.writer.modify.page.footer.borders.Sides
, ooodev.format.writer.modify.page.footer.borders.Padding
, and ooodev.format.writer.modify.page.footer.borders.Shadow
classes are used to modify the border values seen in Fig. 1161 of a character border style.
Default Page Footer Borders Style Dialog
Setup
General function used to run these examples.
Note that in order to apply a style, the document footer must be turned on as seen in Write Modify Page Footer.
from ooodev.format.writer.modify.page.footer import Footer, WriterStylePageKind
from ooodev.format.writer.modify.page.footer.borders import Padding, Shadow, Sides
from ooodev.format.writer.modify.page.footer.borders import BorderLineKind, LineSize, Side
from ooodev.format import Styler
from ooodev.office.write import Write
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
from ooodev.utils.color import StandardColor
def main() -> int:
with Lo.Loader(Lo.ConnectPipe()):
doc = Write.create_doc()
GUI.set_visible(doc=doc)
Lo.delay(300)
GUI.zoom(GUI.ZoomEnum.ENTIRE_PAGE)
footer_style = Footer(
on=True,
shared_first=True,
shared=True,
height=10.0,
spacing=3.0,
spacing_dyn=True,
margin_left=1.5,
margin_right=2.0,
style_name=WriterStylePageKind.STANDARD,
)
side = Side(line=BorderLineKind.DOUBLE, color=StandardColor.RED, width=LineSize.MEDIUM)
sides_style = Sides(all=side, style_name=WriterStylePageKind.STANDARD)
Styler.apply(doc, footer_style, sides_style)
style_obj = Sides.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Lo.delay(1_000)
Lo.close_doc(doc)
return 0
if __name__ == "__main__":
SystemExit(main())
Border Sides
Setting Border Sides
# ... other code
side = Side(line=BorderLineKind.DOUBLE, color=StandardColor.RED, width=LineSize.MEDIUM)
sides_style = Sides(all=side, style_name=WriterStylePageKind.STANDARD)
Styler.apply(doc, footer_style, sides_style)
Style results.
Getting border sides from a style
# ... other code
style_obj = Sides.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Border Padding
Setting Border Padding
# ... other code
padding_style = Padding(
left=5, right=5, top=3, bottom=3, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, footer_style, padding_style)
Style results.
Getting border padding from a style
We can get the border padding from the document.
# ... other code
style_obj = Padding.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Border Shadow
Setting Border Shadow
# ... other code
shadow_style = Shadow(
color=StandardColor.BLUE_DARK2, width=1.5, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, footer_style, shadow_style)
Style results.
Getting border shadow from a style
We can get the border shadow from the document.
# ... other code
style_obj = Shadow.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Related Topics
See also