Write Direct Character Borders Class

The ooodev.format.writer.direct.char.borders.Borders class gives you the same options as Writer’s Borders Dialog, but without the dialog. as seen in Fig. 910.

Writer dialog Character Borders

Fig. 910 Writer dialog Character Borders

Setting the character borders

from ooodev.format.writer.direct.char.borders import Borders, Side
from ooodev.format.writer.direct.char.borders import Padding
from ooodev.format.writer.direct.char.borders import Shadow
from ooodev.format import StandardColor
from ooodev.office.write import Write
from ooodev.gui import GUI
from ooodev.loader.lo import Lo

def main() -> int:
    with Lo.Loader(Lo.ConnectPipe()):
        doc = Write.create_doc()
        GUI.set_visible(doc=doc)
        Lo.delay(300)
        GUI.zoom(GUI.ZoomEnum.ZOOM_150_PERCENT)
        cursor = Write.get_cursor(doc)

        Write.append(cursor, "Hello ")

        side = Side(color=StandardColor.GREEN_LIGHT2)
        border_style = Borders(all=side)

        Write.append(cursor, "World", styles=[border_style])
        Write.end_paragraph(cursor)

        Lo.delay(1_000)
        Lo.close_doc(doc)
    return 0

if __name__ == "__main__":
    sys.exit(main())

Running the above code will produce the following output in Fig. 911.

Character Borders

Fig. 911 Character Borders

Setting the character borders With padding

# ... other code
cursor = Write.get_cursor(doc)

Write.append(cursor, "Hello ")

side = Side(color=StandardColor.GREEN_LIGHT2)
border_style = Borders(all=side)
# create a padding of 3 mm on all sides
padding_style = Padding(all=3)
Write.append(cursor, "World", styles=[border_style, padding_style])
Write.end_paragraph(cursor)

Running the above code will produce the following output in Fig. 912.

Character Borders with shadow

Fig. 912 Character Borders with shadow

Setting the character borders With Shadow

# ... other code
cursor = Write.get_cursor(doc)

side = Side(color=StandardColor.GREEN_LIGHT2)
border_style = Borders(all=side)

Write.append(cursor, "Hello ")
# create shadow
shadow_style = Shadow(color=StandardColor.GREEN_DARK2, width=1.0)
Write.append(cursor, "World", styles=[border_style, shadow_style])
Write.end_paragraph(cursor)

Running the above code will produce the following output in Fig. 913.

Character Borders with shadow

Fig. 913 Character Borders with shadow