1

What the cases where you need to clone LayoutListElements such as text elements, map surround elements, and graphic elements?

I am currently working on a one-page map document that I only need to print a one-page pdf by exporting a web map to pdf.

Here is a picture of the layout. The example that I am following in option 2 looks like it is generating a map and followed by a table. Printing Popup Example Blog from ESRI

Here is the map document that I am working with: Map Document

I don't need to generate a table. I just need to print text some dynamic text elements and a mapsurround element. In addition, the blog post example for their python script looks like they remove cloned elements when they export the map through their delElements() function.

Here is the delElement() and export() function for reference:

# the function takes a map and an array
# it export the map to a pdf and add the pdf's path in the array
def export(map, pdfPaths):
    delElements()
    s = generateUniqueFileName()
    print s
    arcpy.mapping.ExportToPDF(map, s)
    pdfPaths.append(s)

# removing the elements stored in the original mxd 
# that are already cloned
def delElements():
    global line_sep, line_sep_feat, txtLyrNm, txtFldNm, txtFldVal
    if (line_sep != None):
        line_sep.delete()
        line_sep_feat.delete()
        txtLyrNm.delete()
        txtFldNm.delete()
        txtFldVal.delete()

Is this a requirement every time you generate a pdf?

Would this be necessary if I am only printing one page with dynamic text in order for new values to be passed onto the map document? For example, would you need to delete text element labelled WLA (its wild card name is called district_name) and update that value?

1

There is no such requirement to delete elements before publishing/exporting but from the code what I gather is that it is a simple cleaning up stage. In fact the code deletes the template elements not the cloned ones. If you open the Popup.mxd in the zipped archive, you will see these template elements at the top of the map just to draw and populate a table which imitates the popup items of the webmap. The process has two parts, (1) create/publish the map, (2) populate pop-up content in a table and publish. The author does a trick in the second part, Popup.mxd part, which has an empty dataframe mapping nothing, this is just a layout to keep tabular information. It uses the same logic as mentioned in this post, which is borrowed from ESRI's help page. The main issue here is that if you do not have access to ArcGIS Production extension, creating dynamic tables requires such tricks.

If you are not going to need the popup part, you can modify the python code a bit to avoid interacting with Popup.mxd. On a quick look at the code, the lines between 218 and 261 triggers the popup part but did not test it, so I cannot say whether it works.

  • This is a helpful response to my question. – Demon Sep 13 '18 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.