Modifying the Print dijit's  Hyperlink

846
4
11-07-2013 10:08 AM
DavidMarquardt
New Contributor III
Hello,

I'm working with the Print widget tool.  I'm trying to access and modify the Print Image Hyperlink.  This link appears after the print job is done, allowing the user to open a new window with the resulting image. 
While I can access the styling aspects of this hyperlink in css with .esriPrintout, I haven't found a similar parameter to use for scripting. 
Ideally, I want to bypass the hyperlink:  having the new window with the image open automatically.  If this isn't possible, I???d like to have the hyperlink positioned on the side of the print button, rather than replace it. 

My questions are???
Is there a parameter in scripting that deals with this hyperlink?
Should I be working with PrintTask, instead of with just the Print dijit?
Anyone seen an esri print sample that doesn't use the hyperlink?
 
David
0 Kudos
4 Replies
YvanBérard
Occasional Contributor
If my understanding of your problem is right, you might be able to use jQuery to edit the action/style of the hyperlink of the print dijit.

Here is my function that create my print dijit.

function createPrintDijit(printTitle)
 {
  var map = getMap();
  var layoutTemplate, templateNames, mapOnlyIndex, templates;
  
  // create an array of objects that will be used to create print templates
  var layouts = [
  {
  "name": "print_layout_cadrin_letter_us",
  "label": "8.5x11 portrait (PDF)",
  "format": "pdf",
  "options": {
  "legendLayers": [], // empty array means no legend
  "titleText": ""
  }
  }];
  
  // create the print templates, could also use dojo.map
  var templates = [];
  dojo.forEach(layouts, function(lo)
  {
   var t = new esri.tasks.PrintTemplate();
   t.layout = lo.name;
   t.label = lo.label;
   t.format = lo.format;
   t.layoutOptions = lo.options;
   templates.push(t);
  });
  
  printer = new esri.dijit.Print({
   "map": map,
   "templates": templates,
   url : "http://"+cartotest+"/arcgis/rest/services/ExportWebMap/GPServer/Export%20Web%20Map"
  }, dojo.byId("print_button"));
  
  printer.startup();
  printer.on('print-complete',function(evt){
   console.log('Job completed'); // Here you can try to edit the hyperlink or add a new action with jQuery
  });
  printer.on('error',function(){
   console.log('PRINT TIME-OUT ERROR');
  });
  printer.on('print-start',function(){
   console.log('The job is starting.');
  });
 }
0 Kudos
DavidMarquardt
New Contributor III
Thanks.  The code is great.   I appreciate the example too.  I've been using 'print-complete' quite a bit.  I've been trying to see if I can access the url value associated with print complete.  So far, no luck.  I've tried using the example from ESRI below, but that returns and undefined object.  Has anyone else had luck getting the url value?

David

require([
...
], function( ... ) {
  printer.on('print-complete',function(evt){
    console.log('The url to the print image is : ' + evt.value.url);
  });
  ...
});
0 Kudos
NhuMai
by
New Contributor II

Hi David,

Did you ever figure how to get the output url? I'm trying to avoid taking on the print task if possible, as the print dijit basically gets me where I need except for this detail..

0 Kudos
JohnGravois
Frequent Contributor
no harm in hacking on the widget, but i just wanted to throw it out there that PrintTask is the object in API for developers who want to get more fine grained control of their UI.
0 Kudos