How can I get a screenshot without using the print server?

1133
11
12-18-2018 11:07 AM
MattStayner
Occasional Contributor II

I would like to get a screenshot of a map (basemap with layers on top) without using the print server. Is that possible?

Thanks!

Tags (1)
0 Kudos
11 Replies
LucasDanzinger
Esri Frequent Contributor

No need to use the Print Server. We have the ability to take a screenshot directly on the GeoView via exportImage().

Here are the QML and C++ samples for this

arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Maps/TakeScreenshot at master · Esri/arcgis-...  

arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_CppSamples/Maps/TakeScreenshot at master · Esri/arcgis-...  

0 Kudos
MattStayner
Occasional Contributor II

Lucas,

Yes, those examples look perfect. Thanks!

I'm having a hard time running the examples. I tried following the directions on this page, but when I attempt to open the .pro file I get an error, "No valid kits found". When I click on the options link it takes me to the following Settings page. It looks like I need to set a compiler. How do I do that?

Thanks,

Matt

Qt Kits Screenshot

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Are you using AppStudio? Or are you using the Runtime SDK and Qt installed standalone? If using the Runtime & Qt directly, did you follow the install and setup guide? Sounds like you are missing the Visual C++ Compiler Install and set up on Windows—ArcGIS Runtime SDK for Qt | ArcGIS for Developers  

0 Kudos
MattStayner
Occasional Contributor II

I'm using AppStudio. How can I run the example in AppStudio? There is no is not .qmlproject file.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Got it. AppStudio builds and runs the samples differently without having the actual compilers installed on the machine. These sample projects themselves are not setup with AppStudio .qmlproject files. However, the code itself is the same and will still work. I'd suggest creating a new app in AppStudio and then copying the following code into it:

arcgis-runtime-samples-qt/TakeScreenshot.qml at master · Esri/arcgis-runtime-samples-qt · GitHub 

0 Kudos
MattStayner
Occasional Contributor II

Lucas,

Thanks for all your help and the quick responses today!

I did as you said and copied the code into the new blank project. I'm running into (hopefully) one last issue. Now I'm getting an error: module "Esri.ArcGISExtras" is not installed. What do I need to do to make that work?

Thanks again!

Matt

0 Kudos
LucasDanzinger
Esri Frequent Contributor

delete that import along with the scalefactor line, and all references to scalefactor. it isn't really needed anymore and our new update of the sample removes it

0 Kudos
MattStayner
Occasional Contributor II

That did the trick! The sample works great for me now. Thanks for walking me through that.

I'm curious about not needing the scalefactor anymore. When was that removed? Is there a blog post or something that talks about it? I have an existing app that relies heavily on System.displayScaleFactor. That would be great if I could remove ArcGISExtras and the scalefactor reference. Would you recommend that?

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Matt-

Qt introduced automatic scaling a few releases back. It requires you to set a value in C++ - QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

More details on that here - High DPI Displays | Qt 5.12 

I'd suggest posing this question in the AppStudio space. They likely have enabled high DPI scaling for you in some way without needing to set anything in C++.

0 Kudos