Select to view content in your preferred language

adding metadata with ArcPy using export does not appear to work

223
0
3 weeks ago
DeanAnderson2
Frequent Contributor

Oregon Counties are required to produce PDF's of property taxmaps.  We use a tool/python script to produce these pdfs and now must meet CAG 2.1 Level AA accessibility requirements.  Using ArcPro 3.6.2, when I use the export tool from the Share Ribbon and add accessibility properties I can create a document that meets accessibility  requirements when tested with AdobeAcrobatPro (has PDF metadata).  But, when I use python as called from a tool and set the document metadata within the python script  it does not give me an error but does not  add the metadata to the document.

pdf.title = "Accessor Map" # The accessibility title
pdf.author = "Klamath County GIS"
pdf.subject = "Asessor Map"
pdf.keywords = "Assessor, Klamath, Map, 2026, Taxlots"


However, it appears that other properties such as  pdf.includeAccessibilityTags = True work.  Am I doing something wrong or is this not available at this time????

Our work around has been to use the pypdf library  to meet this requirement as follows (abbreviated code as a function - it works) : 

def updatePDFDOC(PDFDoc,MapToPrint):
    arcpy.AddMessage("pdatePDFDOC")
    reader = PdfReader(PDFDoc)
    writer = PdfWriter(clone_from=reader)
    writer.root_object.update({NameObject("/Lang"): TextStringObject("en-US")})
    title = 'Assessor Map ' + MapToPrint
    writer.add_metadata({"/Title": title,
           "/Author": "Klamath County Assessor's Office",
           "/Subject": "Assessment and Taxation",
           "/Keywords": "Klamath County; Assessor's Office; Property Taxes",
           "/Lang": "en-US",})

writer.write(PDFDoc)
 
 
I would rather use the ESRI tools to get this done.  But don't want to waste a lot of time if this capability  is not available.    

 

 

 

Tags (4)
0 Kudos
0 Replies