I'm usually creating maps for (different aspects of) reports of large infrastructure projects. Layers and attributes tend to change back and forth as time goes by, and I'm forced to create new versions of these maps regularly.

The problem is that in each project I have some 50-60 mxd files, some with very small changes. What makes it even more complicated, all of the produced maps should have the same date (and an overall very strict layout) according to that specific project's end date. Even with a very thought-through naming convention, it can sometimes be a real pain to find out which mxd belongs to a certain map that I am tasked to update.

Is there a way to automatically write the path of the mxd (and preferably the date of export) to a pdf and/or a png file somewhere in the metadata when exporting from ArcMap?

The information should not be visible when printed, nor could the file name be used for this (since it will change multiple times), but should also not be too complicated to find when looking for it. The process of exporting a pdf/png in this way should be reasonably fast, since I'll be doing it several times a day.

Does such metadata exist within pdf files and/or png files, and how can I access it?

  • You can insert the document path and date saved (among other parameters) as dynamic text. Maybe it would be an idea to write this as white text on a white background? This way you wouldn't see it when printed, but you could still make it visible when opening a pdf. I don't think it's possible to write any metadata to a pdf when exporting from ArcMap. However it is possible to write some metadata to a pdf when using the arcpy mapping module: help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/…
    – Menno
    Commented Nov 11, 2014 at 9:27
  • White text is very convenient, haven't thought about that :) However, a lot (most) of these maps will become official government documents and some will even be published online. I also make maps that will appear in court, for different kinds of permits etc. So I'm not very comfortable with adding "visible" hidden text in those files. I should take a good look at the mapping module and see what I can use it for, though.
    – Martin
    Commented Nov 11, 2014 at 13:39
  • I don't know if you're able to, but whenever I can't fix something within ArcMap I try to do a quick search whether it is possible using Python. There have been more people looking to write metadata to pdf: stackoverflow.com/questions/4003935/… There are quite a few tools out there (also non-scripting tools), although many seem to require payment.
    – Menno
    Commented Nov 11, 2014 at 15:15
  • 1
    @Martin, have you solved this? If you are using arcpy for export of .pdf documents, there is a method updateDocProperties() desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/… which you can use to set .pdf file metadata such as subject (which can contain the titile of mxd you are exporting). If your workflow is based on external pdf generation library (I use reportlab a lot) such as pypdf, then you can also set metadata in Python code when constructing pdf document objects. Commented Mar 1, 2017 at 6:21
  • @AlexTereshenkov Thanks for the tip! Usually I go with the built-in pdf printer in Arcmap, but it could be worth doing it in python instead. For now, I either use plain, visible text, or white text. Feel free to convert your comment into an answer :)
    – Martin
    Commented Mar 1, 2017 at 7:02

1 Answer 1


I had a similar problem with this question: Creating bookmarked PDF from export script

The following script will export an MXD to PDF, and modify the PDFs properties (via output.addMetadata) using the PyPDF2 module.

import sys
sys.path.insert(0, r"H:\NetworkShared_PythonModules")
import PyPDF2, os, arcpy

mxdPath = r"C:\temp\MyMap.mxd"
mxd = arcpy.mapping.MapDocument(mxdPath)
PDFPath = r"C:\temp\MyPDF.pdf"
arcpy.mapping.ExportToPDF(mxd, PDFPath)

output = PyPDF2.PdfFileMerger()

bookMarkText = "Insert BookMark Text Here"
inputPage = PyPDF2.PdfFileReader(open(PDFPath, 'rb'))
output.addMetadata({u'/Keywords': u'Path to MXD' + mxdPath, u'/Author': u'UserName'})              
output.append(inputPage, bookMarkText)

outputStream = file(PDFPath, "wb")
del outputStream, output, mxd, inputPage

I haven't tried, but I'm sure this could be done in a loop with several MXDs.


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.