Select to view content in your preferred language

Printing with ImageBlender

832
2
02-11-2011 01:42 AM
simonmiles
Emerging Contributor
I was wondering if anyone out there was using ImageBlender for printing maps.

I can get the sample to work and create a print but I'm having a number of problems

1) Integrating the sample code into my existing web app
2) Styling the image output with a logo, copyright etc

If there is anyone out there that could help I would be very grateful.

Regards

Simon
0 Kudos
2 Replies
KristerVikström
Occasional Contributor
Hi!

I'm trying to do the same thing but can't even get the sample to work 😞

How did you get the saple running??
0 Kudos
CliftonAbbott
Emerging Contributor
I just finished trying to use ImageBlender to allow my maps to print. My situation was that my website that uses the maps inline is on a unix-apache box while my gis server is on win-iis box. So I could not run the asp code from my apache server and the server is controlled by an admin group, so I could not tinker with trying to get apache to execute asp. So I was left with running imageblender from my gis server and somehow get the created image back to my public website. I did not (still do not) know a lot about asp(.net) so I was going at it blindly. This is what I did and it seems to work. I thought maybe it could be useful to someone else.

To start with, I followed the instructions with imageblender and got it working on my gis server.

  • created a folder in my wwwroot called imageblender and placed the imageblender code there

  • in IIS created a virtual directory named imageblender pointing to the folder I just created

  • in wwwroot\imageblender\AppCode\SimpleService.cs I edited the following lines:

  • [INDENT]      [WebService(Namespace = "http://yourserver/")]
          imageBlender.OutputPath = "C:\\arcgisserver\\arcgisoutput\\";
          imageBlender.OutputUrl = "http://yourserver/arcgisoutput/";
    [/INDENT]
  • Then opened a browser to http://yourserver/imageblender/ and it worked.

Once that is working, I created a file named blendIt.aspx and placed it in wwwroot\imageblender with the following contents:
[INDENT]<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
[/INDENT]

Next, edit Default.aspx.cs to add the following to the Page_Load:
[INDENT]SimpleService ss = new SimpleService();
string res = ss.BlendImageList(Page.Request.Form["il"]);
Response.Write(res);
[/INDENT]
"il" is just a post var and can be changed. I'll note where it is sent later.

I think that is all of the changes there. Now to your website. A couple things that you will need. First is the proxy.php that is for the javascript api. You can get this from ESRI. Then you will need a js file that will house a function that will make a post ajax call to the blendIt.aspx that we created.

proxy.php changes: (I do not have the magic_quotes_gpc turned off like it says)
[INDENT]ServerURLS
[INDENT]$serverUrls = array(
    array( 'url' => 'http://yourserver/imageblender/blendIt.aspx', 'matchAll' => true, 'token' => '' )
  );
[/INDENT]
Right after $postData = file_get_contents... add the follwing line:
[INDENT]$postData = "il=".urlencode(substr($postData,3));[/INDENT]
The "il" is the post var that I mentioned. This is already in $postdata but it can't be encoded. So I take it out and add it back. You can clean this part up if you like.
[/INDENT]

In your js file for your ajax call:
function getExportMapImage(lyrinfo,emap,busyimg)
{
   ... set your ajax call using var xttp ...

   // here is the post var "li". It can be changed here as well as the other two place noted.
   var params = "il="+lyrinfo;
   var url="proxy.php?http://yourserver/imageblender/blendIt.aspx";
   xttp.open("POST",url,false);
   xttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   xttp.setRequestHeader("Content-length", params.length);
   xttp.setRequestHeader("Connection", "close");
   xttp.send(params);

   if(xttp.status == 200)
   {
      // This is the last step of the process. ImageBlender creates the image on the gis server
      // and returns the image link here. I'm replacing my map with the image. You may decide to 
      // do something different.

      var res = xttp.responseText;

      // emap is your map div. You will see where I get it from calling map.id
      document.getElementById(emap).innerHTML = "<img src=\""+res+"\">";

      // busyimg is a small image that sits on top of the map showing a busy status
      esri.hide(busyimg);
    }
} 


ExportMapImage.js
[INDENT]This is a little long so I have attached it. This sets up at js class called exportMap. It takes your map and your busy image as arguments.[/INDENT]

Now your map.
[INDENT]When all of your layers are loaded, have the following line:
[INDENT]new exportMap(map, loading);[/INDENT]
map is your actual map from esri.Map. Loading is your busy image.[/INDENT]

That is it. You should be done. To summarize all of this, the code is executed after all of the layers in your map is loaded. The js class takes one dynamic layer at a time and then any graphics created on top of your map. Then the js ajax function is called which sends the export string to blendIt.aspx through the proxy.php. A image address is returned and your map is replaced with the image. You may need to do something different, but maybe this will give you a starting place. As far as a logo, I'm not sure. You might can place your logo in a transparent image to match your map size on your gis server and add that as an additional image to blend. Have fun.
0 Kudos