Select to view content in your preferred language

adding metadata with ArcPy using export does not appear to work

286
2
a month 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
2 Replies
Robert_LeClair
Esri Esteemed Contributor

In your Python script, do you have a line that says:

pdf.includeAccessibilityTags = True

IncludeAccessibilityTags Property—ArcGIS Pro - it defaults to FALSE so perhaps this is why you're not seeing the tags?

Also - another workflow - Solved: Automatically add PDF metadata for accessibility a... - Esri Community

0 Kudos
DeanAnderson2
Frequent Contributor

Thanks for looking at this.  Sorry for delays, but the data extension for us to meet accessibility requirements has made this less of a priority. 

To answer your question... Yes, I included the pdf.includeAccessibilityTags = True and I still have the problem.  In the other solution you referenced it appears that they had the same problem and used PikePdf instead of pypdf to fix the problem.  The workaround is create the pdf and then use another python library to add missing accessibility such as title and  language.   

I have done more testing with several alternatives using just ArcPro tools with Python and I have NOT been able to get the metadata that exists in the layout and language to be transferred from the ArcPro environment to the PDF .  I will continue to use an external library and update the PDF after it is created in ArcPro.