I highlight some features with a semi transparent color via an ILayerExtensionDraw. When I print the ActiveView of the PageLayoutControl with IPrintAndExport the highlightning is not on the printout.

In the print method I get the printers HDc and save it to a static variable which the LayerExtension reads from.

  System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
  System.Windows.Forms.DialogResult res = printDialog.ShowDialog();
  if (res == System.Windows.Forms.DialogResult.Cancel)
    return false;

  // ... assigning printer settings here...

  System.Drawing.Graphics graphics = printDialog.PrinterSettings.CreateMeasurementGraphics();
  MyLayerExtension.CurrentPrinterHdc = graphics.GetHdc();

  PrintAndExport.Print(docActiveView, docPrinter, _pageLayoutControl.PageLayout.Page, 1, iResampleRatio, null);

  MyLayerExtension.CurrentPrinterHdc = IntPtr.Zero;

The LayerExtension reads the IntPtr and uses it to draw the highlightning to the printer, but it is not shown on the print out.

SimpleFillSymbol fillSymbol = new SimpleFillSymbol();
fillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
fillSymbol.Outline = new ESRI.ArcGIS.Display.SimpleLineSymbol();
fillSymbol.Color = Utilities.CreateColor(System.Drawing.Color.Khaki);
pDisplay.Filter = new TransparencyDisplayFilterClass { Transparency = 127 }; 
pDisplay.StartDrawing(pDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache);
if (CurrentPrinterHdc != IntPtr.Zero)
  pDisplay.StartDrawing(CurrentPrinterHdc.ToInt32(), (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache);

The LayerExtension does get called on printing.

What did I miss?

As far as I understand the HDc now the drawing on the printers handle would only work, if I use the HDc to print later on again, which is not a real option.

Is there any other way to get the transparent (!) highlightning printed?

1 Answer 1


You saved a device context identifier, but ArcGIS creates and uses a different device context to print on afterwards. This means that what you draw in the layer extension is not visible in the output document.

You cannot use IPrintAndExport in your case because it does not allow you to reach the device context used when printing and exporting. You will need to use the old-fashioned method of printing which was traditionally used before IPrintAndExport was introduced, i.e. the IPrinter.StartPrinting method (or IExport.StartExporting). These methods return the actual device context which you pass to IActiveView.Draw, but you can also leverage it in your scenario such as drawing any additional content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.