Export to JPEG or PDF using esri.layers.ImageParameters ( constructor )

Discussion created by dashton on Jul 1, 2010
Latest reply on Jul 1, 2010 by apfister-esristaff
I'm trying to utilize the esri.layers.ImageParameters - constructor and the mapservice.exportMapImage but I'm having trouble figuring out where my image is saving and how I can grab it.  Can someone take a look at my code and let me know what I'm doing wrong or possibly what I need to add.  I think I'm close.

Here's my code in my JavaScript that is doing the work
function createpdf1() {

//Show progress bar page while waiting
 pdfresultframe.document.location.href = "progressbar.html"  

//making the <div...> or framelayer active/visible: functionpdf3

//populate figsize value in pdform in map.asp file
 pagesize = document.pdfform.figsize.value     

//populate orientation value in pdform in map.asp file
 orientation = document.pdfform.orientation.value
//populate resolution value in pdform in map.asp file
 resolution = document.pdfform.resolution.value 

//populate printoption value in pdform in map.asp file 
 printoption = document.pdfform.printoption.value 

//populate layoutstyle value in pdform in map.asp file
 layoutstyle = document.pdfform.layoutstyle.value 

//Class hierarchy = esri.layers.ImageParameters - constructor
 //Creates a new ImageParameters object. The constructor takes no parameters
figuresettings = new esri.layers.ImageParameters() 

//Set image formate property could be png | png8 | png24 | jpg | pdf | bmp | gif | svg 
 figuresettings.format = "jpg" 
//set width property Requested image width in pixels
 figuresettings.width = width * resolution  
 //set height property Requested image width in pixels 
 figuresettings.height = height * resolution  
//set Dots per inch setting for an ArcGISDynamicMapServiceLayers
 figuresettings.dpi = resolution    

if (printoption == "honorscale") {
  theOriginalWidth = map.width/96
  theOriginalHeight = map.height/96
  if ((width/height) > (theOriginalWidth/theOriginalHeight)) {
   theFactor = height/theOriginalHeight
  else {
   theFactor = width/theOriginalWidth
  theOriginalExtent = map.extent
  theNewExtent = theOriginalExtent.expand(theFactor)
  figuresettings.bbox = theNewExtent

//exportMapImage - IMapImage exportMapImage(IMapDescription mapDesc,IImageDescription imageDesc)
// Use ExportMapImage to retrieve a file (image or vector format) of the map.
//ExportMapImage to generate an image of the map.The input parameter MapDescription  
//contains properties 


//Use IMapImage to access properties of an ExportMapImage  result. 

function createpdf2(mapImage) {  
 document.pdfform.mapimagehref.value = mapImage.href    //URL to returned image.
 document.pdfform.printscale.value = mapImage.scale    ///Scale of requested dynamic map.
 document.pdfform.submit()  // Javascript to submit form / submit call


In my map.asp page I'm populating a form, here is where I will send my values
<form name="pdfform" method="post" action="createpdf.asp" target="pdfresultframe">   <!--declaring form name and asp action-->
  <input type="hidden" name="mapImagehref"   value="">
  <input type="hidden" name="printscale"   value="">

I guess my question is: is do I actually set the mapimage.href URL and the mapImage.scale info or is this defaulted somehow.  I feel like I'm so close but I'm so confused.

David Ashton