Custom graphics on the page.
[Visual Basic 6.0] Property CustomGraphics As IGraphicElements
[Visual Basic .NET] Public Property CustomGraphics As IGraphicElements
[C#] public IGraphicElements CustomGraphics {get; set;}
[Java] public IGraphicElements getCustomGraphics() throws IOException, AutomationException
[Java] public void setCustomGraphics( IGraphicElements pGraphicElements ) throws IOException, AutomationException
[C++] HRESULT get_CustomGraphics( IGraphicElements** Elements );
[C++] HRESULT put_CustomGraphics( IGraphicElements* Elements);
Parameters
Elements [out, retval]
Elements is a parameter of type IGraphicElements
Elements [in]
Elements is a parameter of type IGraphicElements
Use CustomGraphics to add dynamic text or graphics to the exported layout. One common use of CustomGraphics is to add a customizable, dynamic title to each result of an ExportLayout request.
The following sample code shows how to add custom text to your layout. It assumes that you already have a valid PageDescription object and that you are not working with a server context. However, if you are developing an ArcGIS Server application using a server context, you should not use New to create local ArcObjects, but you should always create objects within the server by calling CreateObject on IServerContext.
IPageDescription pageDesc;
// Create text symbol
ITextSymbol textSymbol = new TextSymbolClass();
// Set Color
IRgbColor color = new RgbColorClass();
color.Blue = 255;
color.UseWindowsDithering = true;
textSymbol.Color = color;
// Set Font
IFontDisp font = (IFontDisp)new stdole.StdFont();
font.Name = "Verdana";
font.Size = 20;
textSymbol.Font = font;
// Create text element
ITextElement textElement = new TextElementClass();
textElement.Text = "Custom Text";
textElement.Symbol = textSymbol;
// Set position
IPoint point = new PointClass();
point.X = 2.5;
point.Y = 1.5;
IElement element = (IElement)textElement;
element.Geometry = point;
// Create custom graphics
IGraphicElements custGraphics = new GraphicElementsClass();
custGraphics.Add((IGraphicElement)textElement);
// Add custom graphics to PageDescription
pageDesc.CustomGraphics = custGraphics;
The following sample code shows how to add custom text to your layout. It assumes that you already have a valid PageDescription object and that you are not working with a server context. However, if you are developing an ArcGIS Server application using a server context, you should not use New to create local ArcObjects, but you should always create objects within the server by calling CreateObject on IServerContext.
Dim pPageDesc As IPageDescription
'Create text symbol
Dim pTextSymbol As ITextSymbol
Set pTextSymbol = New TextSymbol
'Set color
Dim pColor As IRgbColor
Set pColor = New RgbColor
pColor.Blue = 255
pColor.UseWindowsDithering = True
pTextSymbol.Color = pColor
'Set font
Dim pFont As IFontDisp
Set pFont = New stdole.StdFont
pFont.Name = "Verdana"
pFont.Size = 20
pTextSymbol.Font = pFont
'Create text element
Dim pTextElement As ITextElement
Set pTextElement = New TextElement
pTextElement.Text = "Custom text"
pTextElement.Symbol = pTextSymbol
'Set position
Dim pPoint As IPoint
Set pPoint = New Point
pPoint.x = 2.5
pPoint.y = 1.5
Dim pElement As IElement
Set pElement = pTextElement
pElement.Geometry = pPoint
'Create custom graphics
Dim pCustGraphics As IGraphicElements
Set pCustGraphics = New GraphicElements
pCustGraphics.Add pTextElement
'Add custom graphics to PageDescription
pPageDesc.CustomGraphics = pCustGraphics