15 lines
460 B
Python
15 lines
460 B
Python
from docx.shared import Pt, Inches, Emu, RGBColor
|
|
|
|
|
|
def pt(points: float):
|
|
"""Convert points to a python-docx Length (used for font sizes, spacing, picture dimensions)."""
|
|
return Pt(points)
|
|
|
|
|
|
def rgb(hex_str: str) -> RGBColor:
|
|
"""Convert a 6-char hex string to RGBColor."""
|
|
h = (hex_str or '000000').lstrip('#').upper()
|
|
if len(h) != 6:
|
|
return RGBColor(0, 0, 0)
|
|
return RGBColor(int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16))
|