Printing Maps to printer or pdf

Hello everybody,

in my current application in MS-Access/vba I use a quite spartan dialog to print a snapshot to a MS-Word document by using the SnapShot3 function. This works but is far from being comfortable.
Now that it is finally time to move to C# I’d like to implement a new printout functionality which should:

  • be more comfortable (i.e. give a print-preview, let the user move the print area, select the scale, etc)
  • and either print directly to the printer or to an pdf-file.
    Now I wonder, if anyone has developed a routineaccomplish something similar and would be willing to share his/her knowledge and provide some example code?

Thanks in advance

By the way - if anybody was interested in my vba-code I would be glad to share.

MapWindow5 has a print option.
It’s in a separate plug-in. You can look at its code for inspiration: MapWindow5/src/Plugins/MW5.Printing at develop · MapWindow/MapWindow5 · GitHub

Hello @dimpflmoser

In c#, you can use the SnapShot method to capture the current map extents into an image, something like:

    MapWinGIS.Image mwImage = axMap1.SnapShot(axMap1.Extents);

What I have done in the past is to then use the Image.Save method to save the file to a temporary directory, then use the Windows standard Print dialog to preview and print the file.

Regards,
Jerry.

Hello @jerryfaust
Could you be more specific?
Could you provide the code to save?
I would appreciate your contribution!

There’s a Save method on the Image class. See the documentation here.

Jerry.

1 Like