LineFormat, LineFillFormat — Aspose.Slides FOSS for Python API Reference

LineFormat controls the appearance of a shape’s border or an explicit line / connector stroke. Access it via shape.line_format or through cell-border properties such as cell_format.border_left.

Package: aspose.slides_foss


LineFormat

Properties

Basic stroke

PropertyTypeAccessDescription
fill_formatLineFillFormatReadFill of the line (colour, gradient). Usually set via fill_format.fill_type = FillType.SOLID and fill_format.solid_fill_color.color = ....
widthfloatRead/WriteLine width in points. Default is 0.75.
is_format_not_definedboolReadTrue if no <a:ln> element exists and the line is using inherited defaults.

Dash and cap

PropertyTypeDescription
dash_styleLineDashStylePreset dash pattern: SOLID, DOT, DASH, LARGE_DASH, DASH_DOT, LARGE_DASH_DOT, LARGE_DASH_DOT_DOT, SYSTEM_DASH, SYSTEM_DOT, SYSTEM_DASH_DOT, SYSTEM_DASH_DOT_DOT, CUSTOM, NOT_DEFINED.
custom_dash_patternlist[float]Read/Write
cap_styleLineCapStyleCap style applied to line ends: ROUND, SQUARE, FLAT, NOT_DEFINED.

Compound style and alignment

PropertyTypeDescription
styleLineStyleCompound line style: SINGLE, THIN_THIN, THICK_THIN, THIN_THICK, THICK_BETWEEN_THIN, NOT_DEFINED.
alignmentLineAlignmentAlignment relative to the shape border: CENTER, INSET, NOT_DEFINED.

Join style

PropertyTypeDescription
join_styleLineJoinStyleCorner join style: ROUND, BEVEL, MITER, NOT_DEFINED.
miter_limitfloatMiter limit ratio. Only meaningful when join_style = MITER.

Arrowheads (begin)

PropertyTypeDescription
begin_arrowhead_styleLineArrowheadStyleArrow type at the start: NONE, TRIANGLE, STEALTH, DIAMOND, OVAL, OPEN, NOT_DEFINED.
begin_arrowhead_widthLineArrowheadWidthArrow width: NARROW, MEDIUM, WIDE, NOT_DEFINED.
begin_arrowhead_lengthLineArrowheadLengthArrow length: SHORT, MEDIUM, LONG, NOT_DEFINED.

Arrowheads (end)

PropertyTypeDescription
end_arrowhead_styleLineArrowheadStyleSame values as begin_arrowhead_style.
end_arrowhead_widthLineArrowheadWidthSame values as begin_arrowhead_width.
end_arrowhead_lengthLineArrowheadLengthSame values as begin_arrowhead_length.

LineFillFormat

Access via line_format.fill_format. Controls the colour and texture of the line stroke.

PropertyTypeDescription
fill_typeFillTypeNO_FILL, SOLID, GRADIENT, PATTERN.
solid_fill_colorColorFormatSolid colour when fill_type = SOLID.
gradient_fill_formatGradientFillFormatGradient settings when fill_type = GRADIENT.
pattern_fill_formatPatternFillFormatPattern settings when fill_type = PATTERN.

Usage Example

Dashed red border with round caps and an arrow

import aspose.slides_foss as slides
from aspose.slides_foss import (
    ShapeType, FillType,
    LineDashStyle, LineCapStyle,
    LineArrowheadStyle, LineArrowheadLength,
    LineJoinStyle,
)
from aspose.slides_foss.drawing import Color
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    slide = prs.slides[0]
    shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 80, 80, 400, 200)

    lf = shape.line_format
    lf.fill_format.fill_type = FillType.SOLID
    lf.fill_format.solid_fill_color.color = Color.from_argb(255, 200, 0, 0)
    lf.width = 2.5
    lf.dash_style = LineDashStyle.DASH_DOT
    lf.cap_style = LineCapStyle.ROUND
    lf.join_style = LineJoinStyle.ROUND

    prs.save("line-format-demo.pptx", SaveFormat.PPTX)

Arrow connector

import aspose.slides_foss as slides
from aspose.slides_foss import (
    ShapeType, FillType,
    LineArrowheadStyle, LineArrowheadWidth, LineArrowheadLength,
)
from aspose.slides_foss.drawing import Color
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    slide = prs.slides[0]
    connector = slide.shapes.add_connector(ShapeType.STRAIGHT_CONNECTOR1, 50, 150, 200, 1)

    lf = connector.line_format
    lf.fill_format.fill_type = FillType.SOLID
    lf.fill_format.solid_fill_color.color = Color.from_argb(255, 0, 70, 127)
    lf.width = 1.5
    lf.end_arrowhead_style = LineArrowheadStyle.TRIANGLE
    lf.end_arrowhead_width = LineArrowheadWidth.MEDIUM
    lf.end_arrowhead_length = LineArrowheadLength.MEDIUM

    prs.save("connector-arrow.pptx", SaveFormat.PPTX)

See Also