3

I have a map document which contains several text elements that I have grouped and am able to programmatically update. These groups represent a page of data.

Now I'd like to export this data as a two-page PDF. Where Group 1 = page1 and Group 2 = page 2. I've been looking to data driven pages but can't get my head round if this is even possible.

I understand how to use Data Driven pages for changing map extents (Data Driven Pages and exporting PDF using Python) etc.. but not this specific issue of moving text element groups to and from the layout page, taking a snap-shot as the next page, and exporting as a map book.

Does anyone have experience with this making multi-page PDFs by moving text elements across the layout page? - I hope the image below indicates what I'm trying to do in ArcMap 10.2

enter image description here

2 Answers 2

3

You can list text and other graphic elements with arcpy.ListLayoutElements(). This will even give you the option of returning only text elements, graphic elements, mapsurround elements (like north arrow, scale bar). For each of these elements you can set its location by setting the X and Y properties e.g. element.elementPositionX = 12.5.

This allows you as well to move certain elements (temporarily) off the page, by setting coordinates which are outside your page sheet.

Be sure to always refresh the view by using arcpy.RefreshActiveView() or your layout won't be updated.

More info on text elements: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/TextElement/00s30000000m000000/


In reply to your comment: yes it is possible to perform operations on group elements as well. They are listed as GRAPHIC_ELEMENT. You can make it easier to identify them in your list of layout elements when you give the elements names when viewing the properties in arcmap (tab 'size and position'). I was able to move a whole group of elements by accessing the group element through the list and then do element.elementPositionX += 20.

Also, I said before you should use arcpy.RefreshActiveView(), it should be mxd.save() where mxd is your MapDocument object.

2
  • Hi Menno have you managed to group your text elements together and move them all at once? My ArcMap session fails to recognise the group existing! Think I will heed PolyGeo's advise and do my process via two mxd's rather than moving text elements...
    – spk578
    Oct 14, 2014 at 13:36
  • Please see my edited answer.
    – Menno
    Oct 15, 2014 at 14:19
1

I think I understand what you are trying to do, but correct me if I am wrong.

If I have understood the use case I would not involve Data Driven Pages to do this.

I think you are saying that you want to:

  1. Export to PDF your layout which has Group 1 elements on it - let's call it Group1.pdf
  2. You get hold of Group 1 and move it off the page
  3. You get hold of Group 2 and move it onto the page
  4. Export to PDF your layout which now has Group 2 elements on it - let's call it Group2.pdf
  5. Use something like the code below to combine the two single page PDFs into a single multi-page PDF

I'm assuming that you already know the code to do steps 1-4 above.


import arcpy
finalPDF = arcpy.mapping.PDFDocumentCreate("Final.pdf")
finalPDF.appendPages("Group1.pdf")
finalPDF.appendPages("Group2.pdf")
del finalPDF

As an aside you could avoid having to move the grouped elements on/off the page if you used two different MXDs - one for the first page and the other for the second.

Your Answer

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

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