Select to view content in your preferred language

Printing graphics and dynamic layers

1022
11
06-24-2013 06:47 AM
PramodHarithsa1
Frequent Contributor
Hi all,
I am working with this sample https://developers.arcgis.com/en/javascript/jssamples/widget_print.html
But unable to get the print widget working when i add graphics(I am trying to present the search results as a graphic layer)
or the operational layers to the map.
it works only if arcgisonline services are being used.


Code sample: http://jsfiddle.net/AtrBj/
Whats the tweak i am missing here?
0 Kudos
11 Replies
JohnGravois
Deactivated User
adding graphics quickly increases the size of the request because each geometry must be articulated to ArcGIS Server.

this means, that you'll have to follow the pattern in the original published sample and reference a working proxy so that it can be utilized in scenarios when the size of the request requires that it be POSTed across domains.

esri.config.defaults.io.proxyUrl = "/location/proxy.ashx";
0 Kudos
ShaikhRizuan
Regular Contributor
i have added the proxy page(configured to local map service) in code (i.e.  esri.config.defaults.io.proxyUrl = "http://localhost/proxy/proxy.ashx";) and used the local map service, the print button itself not working but it shows map with graphics in chrome without adding the proxy page, I hope it is not the issue with the proxyUrl.

Thanks
Shaikh Rizuan
0 Kudos
JohnGravois
Deactivated User
the proxy is not needed to display the graphics in the client application in chrome, so if the print button doesn't appear, its likely either that you have referenced the proxy incorrectly, or that the proxy is not functioning.

i recommend inspecting the web traffic generated by your app using something like fiddler, firebug, or chrome developer tools to try and find the request which attempts to use the proxy, along with testing the proxy directly in the browser to make sure its working.

a url similar to the following will display the REST services directory in your browser if the proxy is up and running.
http://webserver/proxy/proxy.ashx?http://arcgisserver/arcgis/rest/services
0 Kudos
melissaGomez
Occasional Contributor
Hi,

I am trying to follow the previous notes on this page for help in getting my "print" to work, but I am still stuck.

I have so far attached the following into my code:

// add print dijit
        printer = new esri.dijit.Print({
          map: map,
          url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%2..."
        }, dojo.byId("printButton"));
        printer.startup();
esri.config.defaults.io.proxyUrl = "proxy.jsp";
//end printer dijit

Then I have downloaded the proxy.jsp into my wwwroot folder for my web application as well as attaching my url, but there is still no printing involved:

String[] serverUrls = {
  "http://[mybox]/MyStuff/index6.html",
  "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%2...",
  "http://webserver/proxy/proxy.jsp?http://arcgisserver/arcgis/rest/services"
//NOTE - no comma after the last item
};

I am not sure that all these "http's" need to be added to my string of server URLs?
😞 Any advise?
0 Kudos
JohnGravois
Deactivated User
what web server are you using?  IIS or something else?
0 Kudos
melissaGomez
Occasional Contributor
I am using IIS and I have set up my proxy service on my localhost. I am getting an error message of code 400?
0 Kudos
JohnGravois
Deactivated User
since you are using IIS, i would recommend utilizing our ASP.NET proxy.  you should be able to simply unzip the contents of the ZIP file and using IIS Manager to 'convert to application'.

the included proxy.config file has a global mustMatch tag which could be set to 'false' to allow any page to be retrieved, but in a production environment it would be more secure to explicitly add resources to the list (and keep the global mustMatch tag set to 'true') to avoid malicious usage.
0 Kudos
melissaGomez
Occasional Contributor
okay, I did go back and utilizing the ASP.NET proxy, as well as unzipped the contents ...

I have my musMatch to true.

I also attached the following server to my proxy.config text editor:
<serverUrl url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/"
               matchAll="true"></serverUrl>

Here is where i've attached my local host script, see below:
function init() {
        map = new esri.Map("map", {
    basemap: "streets",
          center: [-98.49946448681641, 29.42057087899471],
          zoom: 11,
    sliderStyle:"big"
   });
  esri.config.defaults.io.proxyUrl = "/localhost/proxy/proxy.ashx";

I am still however, receiving an error message 😞
0 Kudos
JohnGravois
Deactivated User
what is the error message?
did you use IIS manager to convert the folder the proxy is in to an application (as mentioned in my last post and install instructions)?
what happens when you try to use the proxy to display the rest services directory on sampleserver6 directly in the browser?

ie:
http://[yourwebserver]/proxyfolder/proxy.ashx?http://sampleserver6.arcgisonline.com/arcgis/rest/services
0 Kudos