Print Task API3 AGS 10.1 Layout Option CustomTextElements

6770
12
07-15-2012 11:52 PM
SchoppMatthieu
New Contributor III
Hello,

I'd like to know how to handle the "customTextElements" property of the LayoutOptions (PrintTask) back in the template.mxd
"title" and "author" use standard "dynamic text" - (e.g. <dyn type="document" property="title"/>)

What about customTextElements ?

Can we send other objects like an overview map to the printing-geoprocessing service ?

Can I find somewhere some documentation about how to extend the printing geoprocessing tool ?

Cheers,
Tags (2)
0 Kudos
12 Replies
DasaPaddock
Esri Regular Contributor
0 Kudos
SchoppMatthieu
New Contributor III
Thank you very much for your answer, 😄

I've read the documentation.
The only reference to "customTextElements" I can find is in the "Export Web Map Specification" Chapiter:
http://resources.arcgis.com/en/help/main/10.1/index.html#//0154000004w8000000

It is said :
Page layout elements include title, copyright text, scale bar, author name, and custom text elements.

customTextElements (optional): This is an array of name-value pairs. You need to use this if you want to update text of a text element (that is not dynamic text) on the page layout. Values must be strings.

The JSON looks like this:

"customTextElements" : [
  {"<textElementName1>" : "<value1>"},
  {"<textElementName2>" : "<value2>"}
],


However I couldn't find any info about how to handle customTextElements in the mxd itself. :confused:
The fact that it is not using "dynamic text" is disturbing, the answer must be really simple but I don't have a clue and I can't find anything on internet.

My goal is to get a "Description" text element on the printed map that the user can fill out on the client side.

Has anyone used "customTextElements" already ?

Cheers
0 Kudos
DasaPaddock
Esri Regular Contributor
Try this in ArcMap:

1.       In the layout template, switch to �??Layout View�?�
2.       Go to Insert menu and then select �??Text�?� element. A new text element is added to the layout.
3.       Right click on the text element and select �??Properties�?�.
4.       Go to �??Size and Position�?� tab
5.       Give the text element a unique identifier in �??Element Name�?� text box.
0 Kudos
SchoppMatthieu
New Contributor III
Thank you again for your help but it didn't work.

Which name am I suppose to give to the text element ? the name of the parameter I sent "customTextElements" ?
Which text then am I supposed to give to my text element as it doesn't accept an empty caption.

Does anyone has used "customTextElements" before ? please help !
0 Kudos
DasaPaddock
Esri Regular Contributor
Yes, the name you choose would then be the property name for the value in the customTextElements Object.

See:
http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/tasks/supportClasses/LayoutOptions....

I'd suggest contacting Tech Support if you need further assistance with this.
http://support.esri.com/
0 Kudos
JayHalligan
New Contributor III
I am trying to accomplish the same thing, any luck? What does you mxml file look like?
0 Kudos
ValentinaBoycheva
New Contributor III
I made this work directly from the markup, with a bit of ActionScript thrown in the mix. Assuming that the custom template contains a text element named "myCustomTextElement" and the template has been registered with AGS:


[Bindable] private var customcontent:String ='This is line one.\nThis is line two.';
[Bindable] private var customTextElems:Object;

private function init():void{
 customTextElems = new Object;

 customTextElems.myCustomTextElement = customcontent;
  this.printParameters.layoutOptions.customTextElements = customTextElems;

   printTask.getServiceInfo();
}

<esri:PrintParameters id="printParameters"
    format="PDF"
    layoutTemplate="MyCustomTemplate"
    <esri:layoutOptions>
        <esri:LayoutOptions author="Author: ArcGIS for Flex Team"
            copyright="Copyright: © ArcGIS for Server"
            title="My Map">  
        </esri:LayoutOptions>
    </esri:layoutOptions>
</esri:PrintParameters>



For the record, I tried to implement everything in the markup but the Flex compiler did not allow me to bind a fx:String element. This is strange, as Adobe documentation has an example for string binding. Anyway, if the fx:String value is hard-coded, then the code works.


<esri:PrintParameters id="printParameters"

    format="PDF"                                      
   layoutTemplate="MyCustomTemplate"
    map="{map}" >


<esri:layoutOptions>[INDENT]<esri:LayoutOptions author="Author: ArcGIS for Flex Team"
[/INDENT]
[INDENT]            copyright="Copyright: © ArcGIS for Server"
[/INDENT]
[INDENT]            title="My Map"> 
[/INDENT]
 [INDENT=2]<esri:customTextElements>
[/INDENT]
[INDENT=3]<fx:Object>
[/INDENT]
[INDENT=4]<fx:myCustomTextElement>
[/INDENT]
[INDENT=5]<fx:String id="actualText">{customcontent}</fx:String> (error raised �??Data binding expression not allowed here�?�)
[/INDENT]
[INDENT=4]</fx:myCustomTextElement>
[/INDENT]
[INDENT=3]</fx:Object>
[/INDENT]
[INDENT=2]</esri:customTextElements>
[/INDENT]
 [INDENT]</esri:LayoutOptions>
[/INDENT]
 </esri:layoutOptions>


</esri:PrintParameters>

0 Kudos
DasaPaddock
Esri Regular Contributor
You can also create the object like this:

<fx:Object myCustomTextElement="{customcontent}"/>
0 Kudos
ValentinaBoycheva
New Contributor III
You can also create the object like this:

<fx:Object myCustomTextElement="{customcontent}"/>


Thanks for the suggestion. Unfortunately, that did not work for me - no errors thrown, but the custom text element displayed the default value defined in the template mxd. For some reason the object binding just won't work from the markup. I have to force-feed the value during component initialization.

FB 4, all updates installed.
0 Kudos