First off, are customTextElements even supported in API 3.29? I have a Print dijit set up (code below) but I can't seem to get the customTextElements to show up on my layout. The customTextElements come directly from the Get Layout Templates Info Execute task. I would really like to be able to pass an array that is defined in PHP but the print keeps timing out. I swapped the arrays to just the letter "t" to see if that would work and again, it's timing out. I see that customTextElements are listed under the layoutOptions but you can't pass DynamicText? I am looking to display attribute information for the feature that is being printed by a URL parameter (ID) on the layout template.
// print dijit
var printer = new Print({
map: theMap,
url: "<server>",
templates: [{
label: "Map",
format: "PDF",
layout: "TREATMENTS",
layoutOptions: {
customTextElements: [
{"Target": "t"},
{"Date": "t"},
{"EPA": "t"},
{"Chemical": "t"},
{"Weather": "t"},
{"Title": "t"},
{"Year": "t"}
]
},
exportOptions: {
width: 772,
height: 772,
dpi: 200
}
}]
}, dom.byId("printButton"));
printer.startup();
Claire,
Sure they absolutely work for me in 3.29.
var templates = [{
label: "jpg with info",
format: "jpg",
showAttribution: true,
layout: "Letter ANSI A Landscape",
exportOptions: {
"dpi": 96
},
layoutOptions: {
copyrightText: "",
customTextElements: [{
StreetAdd: "Street Address: 123 lone st"
},{
ParcelNum: "Parcel Num: 121345698"
},{
PPIN: "PPIN: 1234"
},{
OwnerName: "Owners Name: Me"
}]
}
}];
// print dijit
app.printer = new Print({
"map": app.map,
"templates": templates,
url: "my custom print service url"
}, dojo.byId("printButton"));
app.printer.startup();
Robert Scheitlin, GISP - do you have to 'hard code' the text for the customTextElements or can you pass variables or certain attributes from the feature being printed?
I am using variables in my code.
Robert Scheitlin, GISP I'm still a bit of a novice with this so forgive me. How are you passing the variables to the text boxes on your layout?
Using the code I provided above instead of :
StreetAdd: "Street Address: 123 lone st"
I just substitute the "Blah Blah" with some variable.
Robert Scheitlin, GISP Ah okay - I was under the assumption that this text was hard coded so that is why I was a bit confused. I've seen examples using the customTextElements but I don't believe I have seen any with variables being called.
Can you use something like $array[0] if you have everything defined or does it have to be formatted a certain way?
Claire,
Are you saying that you do not know what the customTextElements are to begin with? You have me a little confused here. It seems you might be over complicating this.
Robert Scheitlin, GISP Sorry to confuse you, that is certainly not my intention. More than likely that is exactly what I am doing - I have been at this for 3, almost 4 weeks so I have been reading a lot of material and probably confusing myself.
So what I have is a custom print service that I published. Below is a screen shot with a few elements removed. It has a some text boxes (where it says empty) that I would like to have only certain attribute information appear on the printout. I do not have data driven pages enabled because there are no layers in this template (just wanted to create something nice for the printout). I currently have the attribute information working as a PHP array where it captures the information I need from the ID in the URL and prints it into an html div but I have not been able to figure out how to get that same information and place it on this layout.
Claire,
So when I go to my custom print service and execute "get layout Template Info" Task I get results like this:
{ "results": [ { "paramName": "Output_JSON", "dataType": "GPString", "value": [ { "layoutOptions": { "hasAuthorText": false, "hasCopyrightText": false, "hasTitleText": false, "hasLegend": false, "customTextElements": [{ "StreetAdd": " " }, { "ParcelNum": " " }, { "PPIN": " " }, { "OwnerName": " " }] }, "pageSize": [ 11.0, 8.5 ], "layoutTemplate": "Letter ANSI A Landscape", "activeDataFrameSize": [ 10.0, 6.25 ] }, ...
So then I use the code I originally posted to populate those customTextEelements.