Solved! Go to Solution.
var time = new Date();
dojo.place('<div style="padding-bottom:2px;border-bottom:1px solid #B5BCC7;margin-bottom:4px;"><a href="' + result.url + '?time=' + time.getTime() + '" target="_blank">' + title + '</a><br /><span style="font-size:10px;color:#444;">' + time.toLocaleString() + '</span></div>', 'tasks-print-result', 'last');
//functions for printing
function openPrint () {
clearTextInput('txtTitle');
var fp = dijit.byId('floater_print');
if ((fp.style =="visibility: hidden;") || (fp.style="VISIBILITY:hidden;")) {
fp.style.visibility="visible";
fp.show();
}
}
function setupPrinting(){ //called from my init function
var layouts = [{
"layoutName": "FMDC_Landscape",
"label": "Landscape - PDF",
"format": "PDF",
"options": {
"legendLayers": [], // empty array means no legend
"scalebarUnit": "Miles",
"titleText": "",
"customTextElements": [{
"legalDescriptionText": ""
}, {
"subTitleText": ""
}]
}
}, {
"layoutName": "FMDC_Portrait",
"label": "Portrait - PDF",
"format": "PDF",
"options": {
"legendLayers": [], // empty array means no legend
"scalebarUnit": "Miles",
"titleText": "",
"customTextElements": [{
"legalDescriptionText": ""
}, {
"subTitleText": ""
}]
}
}];
// create the print templates, could also use dojo.map
dojo.forEach(layouts, function(lo){
var t = new esri.tasks.PrintTemplate();
t.layout = lo.layoutName;
t.label = lo.label;
t.format = lo.format;
t.layoutOptions = lo.options;
templates.push(t);
});
var printer = new esri.dijit.Print({
"map": map,
"templates": templates,
url: printUrl
}, dojo.byId("PrintDiv2"));
printer.startup();
dojo.connect(printer, "onPrintStart", function(){
var printTitle = dojo.byId("txtTitle").value;
if (printTitle.length < 1) {
printTitle = currentCountyName + " County";
}
var customElementString;
var checkName = "";
if (printName.length > 5) {
checkName = 'Owner: ' + printName;
}
if (printDeed.length < 16) { //feature has deed book and page information
customElementString = [
{"legalDescriptionText": checkName+'\r\n Description :' + fullLegalString},
{ "subTitleText": print_subTitle}
];
}else{
customElementString = [
{"legalDescriptionText": checkName+'\r\n Description :' + fullLegalString + '\r\n' + printDeed},
{ "subTitleText": print_subTitle}
];
}
// console.log("fullLegalString = "+fullLegalString + "<br> subTitleText = " + print_subTitle);
for (var i = 0; i < templates.length; i++) {
this.templates.layoutOptions.titleText = printTitle;
this.templates.layoutOptions.customTextElements = customElementString;
}
dojo.connect(printer, "onError", function(err){
console.log("Printer Error: " + err);
});
dojo.connect(printer, 'onPrintComplete', function(value){
console.log('The url to the print image is : ' + value.url);
});
});
}
<div id="floater_print" dojoType="dojox.layout.FloatingPane" title='Create Print Page' dockTo="dock_print" style="visibility:hidden; height:260px" closable="false" resizable="true" dockable="true">
<div id="info">
<div id="note">
<ol>
<li> Enter a Title
<input id="txtTitle" style="width:250px" type="text" value="Enter a map title" class="textBox"
onclick="clearTextInput('txtTitle');" />
</li>
<li> Click the dropdown arrow on the Print button to choose Landscape or Portrait. </li>
<li> The 'Printing' prompt indicates your page is being generated. </li>
<li> When the printout is ready, the print button will change to a link Printout.</li>
<li>Click Printout to view your PDF.</li>
</ol>
</div>
<div id="PrintDiv2" > </div>
</div>
</div>
dojo.connect(printer, 'onPrintComplete', function(value){
var time = new Date();
var url = value.url + '?time=' + time;
console.log('The url to the print image is : ' + url);
});