I create a graphic on the map (not layout) using ArcObjects. It is a polygon with a gray cross-hatch fill. When I export the layout to pdf manually or through code, the graphic exports as a solid gray polygon. (I'm using the AddGraphicToMap snippet to create the graphic and the ExportActiveView sample to export to pdf).
If I manually select the graphic on the map, go to its properties and set the symbol to the 10% Crosshatch symbol in the symbol selector and then export to pdf, the graphic exports correctly.
I've found a few suggestions to do things like set the default printer page size to a larger size before exporting, but nothing I've found in my searches has had any effect on the ability to export this graphic correctly. Can anyone help me with this?
Thanks.
Solved! Go to Solution.
I figured it out today.
I finally noticed that when I manually set the graphic to the 10% crosshatch and then examined the symbol properties deeper, the symbol type was a Line Fill Symbol. On the other hand, the Add Graphic To Map snippet uses a Simple Fill Symbol. I had modified the snippet code to set the SimpleFillStyle to crosshatch (again, this displayed in ArcMap fine - the problem was that when exporting the map to a pdf or printing the map, the crosshatch pattern didn't come through and instead the polygon had a solid fill).
I then found Create Line Fill Symbol snippet and changed the Add Graphic To Map snippet to use a LineFillSymbol instead a SimpleFillSymbol for my graphic.
My original code created a graphic polygon with a crosshatch - the modified code creates a graphic polygon with a single diagonal line, but that's good enough to test if this fixes the problem, and IT DOES!
Code is shown below .
Public Sub AddGraphicToMap(ByVal map As ESRI.ArcGIS.Carto.IMap, ByVal geometry As ESRI.ArcGIS.Geometry.IGeometry, ByVal rgbColor As ESRI.ArcGIS.Display.IRgbColor, ByVal outlineRgbColor As ESRI.ArcGIS.Display.IRgbColor)
Dim graphicsContainer As ESRI.ArcGIS.Carto.IGraphicsContainer = CType(Map, ESRI.ArcGIS.Carto.IGraphicsContainer)
Dim element As ESRI.ArcGIS.Carto.IElement = Nothing
If (geometry.GeometryType) = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint Then
' Marker symbols
Dim simpleMarkerSymbol As ESRI.ArcGIS.Display.ISimpleMarkerSymbol = New ESRI.ArcGIS.Display.SimpleMarkerSymbolClass()
simpleMarkerSymbol.Color = rgbColor
simpleMarkerSymbol.Outline = True
simpleMarkerSymbol.OutlineColor = outlineRgbColor
simpleMarkerSymbol.Size = 15
simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle
Dim markerElement As ESRI.ArcGIS.Carto.IMarkerElement = New ESRI.ArcGIS.Carto.MarkerElementClass()
markerElement.Symbol = simpleMarkerSymbol
element = CType(markerElement, ESRI.ArcGIS.Carto.IElement)
ElseIf (geometry.GeometryType) = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline Then
' Line elements
Dim simpleLineSymbol As ESRI.ArcGIS.Display.ISimpleLineSymbol = New ESRI.ArcGIS.Display.SimpleLineSymbolClass()
simpleLineSymbol.Color = rgbColor
simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid
simpleLineSymbol.Width = 5
Dim lineElement As ESRI.ArcGIS.Carto.ILineElement = New ESRI.ArcGIS.Carto.LineElementClass()
lineElement.Symbol = simpleLineSymbol
element = CType(lineElement, ESRI.ArcGIS.Carto.IElement)
ElseIf (geometry.GeometryType) = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon Then
''ORIGINAL AddGrahpicToMap code
'' Polygon elements
'Dim simpleFillSymbol As ESRI.ArcGIS.Display.ISimpleFillSymbol = New ESRI.ArcGIS.Display.SimpleFillSymbolClass()
'simpleFillSymbol.Color = rgbColor
'simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSDiagonalCross
'Dim fillShapeElement As ESRI.ArcGIS.Carto.IFillShapeElement = New ESRI.ArcGIS.Carto.PolygonElementClass()
'fillShapeElement.Symbol = simpleFillSymbol
'element = CType(fillShapeElement, ESRI.ArcGIS.Carto.IElement)
''MODIFIED to use LineFillSymbol instead of SimpleFillSymbol
' Create the Line Symbol to be used
Dim cartographicLineSymbol As ESRI.ArcGIS.Display.ICartographicLineSymbol = New ESRI.ArcGIS.Display.CartographicLineSymbolClass
With cartographicLineSymbol
.Cap = ESRI.ArcGIS.Display.esriLineCapStyle.esriLCSButt
.Join = ESRI.ArcGIS.Display.esriLineJoinStyle.esriLJSMitre
.Color = rgbColor
.Width = 0.5
End With
' Create the LineFillSymbol
Dim lineFillSymbol As ESRI.ArcGIS.Display.ILineFillSymbol = New ESRI.ArcGIS.Display.LineFillSymbolClass
With lineFillSymbol
.Angle = 45
.Separation = 10
.Offset = 5
End With
lineFillSymbol.LineSymbol = cartographicLineSymbol
Dim fillShapeElement As ESRI.ArcGIS.Carto.IFillShapeElement = New ESRI.ArcGIS.Carto.PolygonElementClass()
fillShapeElement.Symbol = lineFillSymbol
element = CType(fillShapeElement, ESRI.ArcGIS.Carto.IElement)
End If
If Not (element Is Nothing) Then
element.Geometry = geometry
graphicsContainer.AddElement(element, 0)
End If
End Sub
I figured it out today.
I finally noticed that when I manually set the graphic to the 10% crosshatch and then examined the symbol properties deeper, the symbol type was a Line Fill Symbol. On the other hand, the Add Graphic To Map snippet uses a Simple Fill Symbol. I had modified the snippet code to set the SimpleFillStyle to crosshatch (again, this displayed in ArcMap fine - the problem was that when exporting the map to a pdf or printing the map, the crosshatch pattern didn't come through and instead the polygon had a solid fill).
I then found Create Line Fill Symbol snippet and changed the Add Graphic To Map snippet to use a LineFillSymbol instead a SimpleFillSymbol for my graphic.
My original code created a graphic polygon with a crosshatch - the modified code creates a graphic polygon with a single diagonal line, but that's good enough to test if this fixes the problem, and IT DOES!
Code is shown below .
Public Sub AddGraphicToMap(ByVal map As ESRI.ArcGIS.Carto.IMap, ByVal geometry As ESRI.ArcGIS.Geometry.IGeometry, ByVal rgbColor As ESRI.ArcGIS.Display.IRgbColor, ByVal outlineRgbColor As ESRI.ArcGIS.Display.IRgbColor)
Dim graphicsContainer As ESRI.ArcGIS.Carto.IGraphicsContainer = CType(Map, ESRI.ArcGIS.Carto.IGraphicsContainer)
Dim element As ESRI.ArcGIS.Carto.IElement = Nothing
If (geometry.GeometryType) = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint Then
' Marker symbols
Dim simpleMarkerSymbol As ESRI.ArcGIS.Display.ISimpleMarkerSymbol = New ESRI.ArcGIS.Display.SimpleMarkerSymbolClass()
simpleMarkerSymbol.Color = rgbColor
simpleMarkerSymbol.Outline = True
simpleMarkerSymbol.OutlineColor = outlineRgbColor
simpleMarkerSymbol.Size = 15
simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle
Dim markerElement As ESRI.ArcGIS.Carto.IMarkerElement = New ESRI.ArcGIS.Carto.MarkerElementClass()
markerElement.Symbol = simpleMarkerSymbol
element = CType(markerElement, ESRI.ArcGIS.Carto.IElement)
ElseIf (geometry.GeometryType) = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline Then
' Line elements
Dim simpleLineSymbol As ESRI.ArcGIS.Display.ISimpleLineSymbol = New ESRI.ArcGIS.Display.SimpleLineSymbolClass()
simpleLineSymbol.Color = rgbColor
simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid
simpleLineSymbol.Width = 5
Dim lineElement As ESRI.ArcGIS.Carto.ILineElement = New ESRI.ArcGIS.Carto.LineElementClass()
lineElement.Symbol = simpleLineSymbol
element = CType(lineElement, ESRI.ArcGIS.Carto.IElement)
ElseIf (geometry.GeometryType) = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon Then
''ORIGINAL AddGrahpicToMap code
'' Polygon elements
'Dim simpleFillSymbol As ESRI.ArcGIS.Display.ISimpleFillSymbol = New ESRI.ArcGIS.Display.SimpleFillSymbolClass()
'simpleFillSymbol.Color = rgbColor
'simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSDiagonalCross
'Dim fillShapeElement As ESRI.ArcGIS.Carto.IFillShapeElement = New ESRI.ArcGIS.Carto.PolygonElementClass()
'fillShapeElement.Symbol = simpleFillSymbol
'element = CType(fillShapeElement, ESRI.ArcGIS.Carto.IElement)
''MODIFIED to use LineFillSymbol instead of SimpleFillSymbol
' Create the Line Symbol to be used
Dim cartographicLineSymbol As ESRI.ArcGIS.Display.ICartographicLineSymbol = New ESRI.ArcGIS.Display.CartographicLineSymbolClass
With cartographicLineSymbol
.Cap = ESRI.ArcGIS.Display.esriLineCapStyle.esriLCSButt
.Join = ESRI.ArcGIS.Display.esriLineJoinStyle.esriLJSMitre
.Color = rgbColor
.Width = 0.5
End With
' Create the LineFillSymbol
Dim lineFillSymbol As ESRI.ArcGIS.Display.ILineFillSymbol = New ESRI.ArcGIS.Display.LineFillSymbolClass
With lineFillSymbol
.Angle = 45
.Separation = 10
.Offset = 5
End With
lineFillSymbol.LineSymbol = cartographicLineSymbol
Dim fillShapeElement As ESRI.ArcGIS.Carto.IFillShapeElement = New ESRI.ArcGIS.Carto.PolygonElementClass()
fillShapeElement.Symbol = lineFillSymbol
element = CType(fillShapeElement, ESRI.ArcGIS.Carto.IElement)
End If
If Not (element Is Nothing) Then
element.Geometry = geometry
graphicsContainer.AddElement(element, 0)
End If
End Sub
just wanted to drop a line that this helped me solve an issue with printing from the javascript templates after adding in a draw toolbar. thanks for the insight, Terese Rowekamp