I have done something like this with arcObjects.
void DrawNormalOnPolyline(IPolyline polyline)
{
IActiveView activeView = ArcMap.Document.ActiveView;
double length = polyline.Length;
ILine normalLine;
normalLine = GetNormalOnPolylineFromStartPointToSpecificDistance(polyline, 0);//perpendicular line at start
DrawLine(normalLine);
normalLine = GetNormalOnPolylineFromStartPointToSpecificDistance(polyline, length);//perpendicular line at end
DrawLine(normalLine);
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
ILine GetNormalOnPolylineFromStartPointToSpecificDistance(IPolyline polyline, double distance)
{
double normalLineLength = 0.01;
ILine normal = new Line();
ICurve curve = polyline;
curve.QueryNormal(esriSegmentExtension.esriNoExtension, distance, false, normalLineLength, normal);
return normal;
}
void DrawLine (ILine normalLine)
{
IElement element = null;
IGraphicsContainer graphicsContainer = (IGraphicsContainer)ArcMap.Document.FocusMap;
ILineElement lineElement = new LineElementClass();
lineElement.Symbol = GetLineStyle();
element = (IElement)lineElement;
if (!(element == null))
{
element.Geometry = GetLineGeometry(normalLine);
graphicsContainer.AddElement(element, 0);
}
}