Hi,
I am using .ArcGIS Runtime for .Net v100.2 in a WPF app and I would like to have a function to print the map. I can't found any code samples in the documentation or in the guide. How to do this ? Could you provide exemple or link to demonstrate this ?
Thanks!
jcb
Any update in printing map in 2025? I want to print a specific area of the map view, not all current view, and with higher resolution, not just screen's resolution?
I have the same issue where an empty bitmap is generated with only text "Powered by ESRI" in the right-bottom corner. Where you ever able to resolve this ?
Anything planned for the future for exporting/printing? To me that's one of the drawbacks of using Runtime SDK vs. ArcGIS Engine. Thanks!
> Is there another method to print high resolution bitmap in 100.3
At this time no. The map only renders at the resolution of your device. High-quality printing is in our backlog, and mostly a Pro/ArcMap thing at the moment.
This is most likely due to a performance improvement in the rendering pipeline where the map is rendered on a separate UI Thread, and your print function isn't able to "see" that.
Instead use the mapView.ExportImageAsync() to get a bitmap of the map to print.
I confirm the analyze of Waldemar. In the runtime 100.3 code like this :
PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() == true) { printDialog.PrintVisual(mapView, "Carte Poseis"); }
don't work (print an empty image) but it was okay in the previous version!
It will be great to have a Print function on the map to avoid this kind of regression.
Regards
The example given by Morten using
ExportImageAsync
works. However, it creates bitmap with the resolution of the screen. This is too low to be printed on 600 DPI printer and it cannot be zoomed. I tried to use Joe's example which looks to regard higher resolution but it generates empty bitmap (with only text "Powered by ESRI" in the right-bottom corner):
bitmap<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;">Render</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN>mapView<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">;</SPAN>
I tried also
printDialog.PrintVisual(MyMapView, "A Simple Drawing");
and it also generates empty bitmap.
Am I doing something wrong? Is there another method to print high resolution bitmap in 100.3?
Regards,
Waldek
What would be the easiest way to play around with scales (say if you wanted smaller scale for higher detail)?
Here's a slightly simpler way:
var img = await mapView.ExportImageAsync();var pngImg = await img.GetEncodedBufferAsync();
RenderTargetBitmap bitmap <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">RenderTargetBitmap</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">int</SPAN><SPAN class="punctuation token">)</SPAN>mapView<SPAN class="punctuation token">.</SPAN>ActualWidth<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">int</SPAN><SPAN class="punctuation token">)</SPAN>mapView<SPAN class="punctuation token">.</SPAN>ActualHeight<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">96</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">96</SPAN><SPAN class="punctuation token">,</SPAN> PixelFormats<SPAN class="punctuation token">.</SPAN>Pbgra32<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> bitmap<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Render</SPAN><SPAN class="punctuation token">(</SPAN>mapView<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">using</SPAN> <SPAN class="punctuation token">(</SPAN>Stream s <SPAN class="operator token">=</SPAN> File<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Create</SPAN><SPAN class="punctuation token">(</SPAN>outputfile<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> BitmapEncoder encoder <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">PngBitmapEncoder</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> encoder<SPAN class="punctuation token">.</SPAN>Frames<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Add</SPAN><SPAN class="punctuation token">(</SPAN>BitmapFrame<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Create</SPAN><SPAN class="punctuation token">(</SPAN>bitmap<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> encoder<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Save</SPAN><SPAN class="punctuation token">(</SPAN>s<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The server-side print service is not available in 100.x. AFAIK there's no plans to implement it either. In my own honest opinion it was a bit of a hack with lots and lots of limitations, and I'm hoping we can provide something much better that runs client-side which ensures the print out looks exactly like what you see on the screen, which the print service was never able to do. Currently by using the client-side print APIs in WPF, you can actually get that.
Thank you for your answer. Because I am trying to migrate from the previous release 10.2.7 to 100.2, I would like to re-use server printing like this https://developers.arcgis.com/net/10-2/sample-code/ServerPrinting/
Do you know how to reach this using 100.2 API ?
You would just use the WPF APIs for this. You also have the ability to call mapView.ExportImageAsync() to get a screenshot of the map, that you can then use to compose a custom print document layout.
A quick google for "Printing in WPF" gives you lots of examples how to do it, where the simples is to use the PrintDialog.PrintVisual to just print any XAML element.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.