1

There are plenty of questions related to printing using ESRI's JS API, however, I am looking for a way to utilize a printer icon to automatically fire the task.

The samples show a print tool that uses a button with an arrow on one side to deliver a drop down of print templates to choose from. When you choose a template it then replaces the button with the word "Printout" that is a link to the print.

I would like something similar to the ArcGIS Online Web Map that has an icon that is clicked and a new window automatically pops up showing the print.

Any ideas?

asked Aug 21, 2013 at 12:51

1 Answer 1

4

I use this function in my website. I have a button labeled Print that calls this function.

function printMap(){
 var printMap = new esri.tasks.PrintTask("yourprintserverurl");
 var params = new esri.tasks.PrintParameters();
 var template = new esri.tasks.PrintTemplate();
 template.exportOptions = { dpi: 96};
 template.layout = "Letter ANSI A Portrait";
 template.preserveScale = true;
 template.showAttribution = false;
 template.layoutOptions = {
 legendLayers: [], // empty array means no legend
 scalebarUnit: "Feet",
 titleText: "PIN " + parcelPin,
 customTextElements: [
 {"physAddress" : printAddress},
 {"ownerOne" : ownerOne},
 {"ownerTwo" : ownerTwo},
 {"mailAddress" : mailAddress},
 {"mailCity" : mailCity},
 {"mailState" : mailState},
 {"mailZip" : mailZip},
 {"propReal" : propReal},
 {"calcAcre" : calcAcre},
 {"landVal" : landVal},
 {"buildVal" : buildVal},
 {"assessVal" : assessVal},
 {"marketVal" : marketVal}
 ]
 };
 params.map = map;
 params.template = template;
 printMap.execute(params, printResult);
 function printResult(result){
 console.log(result.url);
 window.open(result.url);
 };
};

I'm also passing values into my print template to display on the layout. The default output is png, but you can set the output type in the template parameters. Here is the API reference

answered Aug 21, 2013 at 13:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.