<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Exporting multiple projects through python to PDF in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374859#M77950</link>
    <description>&lt;P&gt;I am trying to create an external python program that, as a scheduled, automated job, could reach multiple ArcPRO projects in one folder and export their layouts to another folder. I haven't been able to find a satisfactory answer online, so I'm trying from scratch right now, I'm at:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os, sys
from arcpy import env

#Set workspace directory
workspace = r"\\ProjectsFolder"
env.workspace = workspace

#Output Location
PDFoutputLoc = r"\\OutputFolder"


#Open/reach into project
commall = workspace.listLayouts()
for layout in commall:
pdf_out = pdf_output + layout.name + ".pdf"
layout.exportToPDF(pdf_out)

#Export all layouts to PDF
#Close and repeat&lt;/LI-CODE&gt;&lt;P&gt;and the error I'm hitting my head on a wall right now is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;line 17, in &amp;lt;module&amp;gt;
commall = workspace.listLayouts()
AttributeError: 'str' object has no attribute 'listLayouts'&lt;/LI-CODE&gt;&lt;P&gt;What I think I'm interpreting from this is that it is saying the Layouts are not something that can't be listed. But that doesn't make sense.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jan 2024 15:53:38 GMT</pubDate>
    <dc:creator>EricDorman</dc:creator>
    <dc:date>2024-01-26T15:53:38Z</dc:date>
    <item>
      <title>Exporting multiple projects through python to PDF</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374859#M77950</link>
      <description>&lt;P&gt;I am trying to create an external python program that, as a scheduled, automated job, could reach multiple ArcPRO projects in one folder and export their layouts to another folder. I haven't been able to find a satisfactory answer online, so I'm trying from scratch right now, I'm at:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os, sys
from arcpy import env

#Set workspace directory
workspace = r"\\ProjectsFolder"
env.workspace = workspace

#Output Location
PDFoutputLoc = r"\\OutputFolder"


#Open/reach into project
commall = workspace.listLayouts()
for layout in commall:
pdf_out = pdf_output + layout.name + ".pdf"
layout.exportToPDF(pdf_out)

#Export all layouts to PDF
#Close and repeat&lt;/LI-CODE&gt;&lt;P&gt;and the error I'm hitting my head on a wall right now is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;line 17, in &amp;lt;module&amp;gt;
commall = workspace.listLayouts()
AttributeError: 'str' object has no attribute 'listLayouts'&lt;/LI-CODE&gt;&lt;P&gt;What I think I'm interpreting from this is that it is saying the Layouts are not something that can't be listed. But that doesn't make sense.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 15:53:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374859#M77950</guid>
      <dc:creator>EricDorman</dc:creator>
      <dc:date>2024-01-26T15:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple projects through python to PDF</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374864#M77952</link>
      <description>&lt;P&gt;to provide line numbers and proper formatting&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and it is the project class that uses the listLayouts method&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm" target="_blank"&gt;ArcGISProject—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 15:51:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374864#M77952</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-01-26T15:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple projects through python to PDF</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374868#M77953</link>
      <description>&lt;P&gt;You might also want to check lines 9 &amp;amp; 15.&lt;/P&gt;&lt;P&gt;If I'm following the intent of your code, it looks like your folder name was originally in the "PDFoutputLoc" variable, but in line 15, you're looking for a "pdf_output" variable that doesn't exist.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 16:11:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374868#M77953</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2024-01-26T16:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple projects through python to PDF</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374879#M77955</link>
      <description>&lt;P&gt;This seems like the sort of fun problem I enjoy coding, so here's a shot at it.&amp;nbsp; Caveat, I'm rusty on a couple of these calls, and don't have the opportunity to test it right this second, so grain of salt:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os, pathlib

project_folder = r'D:\PROJ'
# Your directory that contains project files goes here.
# Also, if you're doing a raw string with r'', you shouldn't
# need to double-escape your backslash unless you actually
# WANT two backslashes.  Also, this could be run on a folder
# that contains multiple subfolders each containing a project
# file, if you so desire. os.walk will go all the way down
# the rabbit hole looking for APRX files.

for dirpath, dirnames, filenames in os.walk(project_folder):
    print(dirpath)
    for filename in filenames:
        # If it's not an APRX file, then we don't care, and can skip it.
        if pathlib.Path(filename).suffix != '.aprx':
            continue

        # Pull the filename and its location as your mp object
        print(f'Found Project:  {filename}')
        project_object = arcpy.mp.ArcGISProject(os.path.join(dirpath, filename))

        for layout in project_object.listLayouts():
            print(f'  Found Layout: {layout.name}')

            # Get the name from the Project Name (minus .aprx),
            # the Layout Name, and of course a .pdf extension
            pdf_name = os.path.join(pathlib.Path(filename).stem, layout.name, '.pdf')

            layout.exportToPDF(pdf_name)
print('Complete.')  # Nearly all IDEs will be clear when the script is finished,
                    # but I still do this out of habit for the handful that aren't.&lt;/LI-CODE&gt;&lt;P&gt;The print commands aren't necessary, of course, but they'll let you keep track of what your script has found and where it is in the process.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 16:42:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374879#M77955</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2024-01-26T16:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple projects through python to PDF</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374899#M77959</link>
      <description>&lt;P&gt;The variable &lt;STRONG&gt;workspace&lt;/STRONG&gt;&amp;nbsp;is a &lt;STRONG&gt;string&lt;/STRONG&gt; and you are trying to call &lt;STRONG&gt;listLayouts()&lt;/STRONG&gt;&amp;nbsp;method on a string object. Correct me if I am wrong but &lt;STRONG&gt;listLayouts()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;method is a method of the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;arcpy.mp.ArcGISProject&lt;/STRONG&gt;. Maybe try this:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;&lt;EM&gt;project_path = os.path.join(workspace, "projectname.aprx") # Name of the project that you have created&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993366"&gt;&lt;EM&gt;aprx = arcpy.mp.ArcGISProject(project_path)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993366"&gt;&lt;EM&gt;pdf_output_loc = '\\OutputFolder'&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993366"&gt;&lt;EM&gt;for layout in aprx.listLayouts():&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993366"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; pdf_out = os.path.join(pdf_output_loc, layout.name + ".pdf")&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993366"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; layout.exportToPDF(pdf_out)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993366"&gt;&lt;EM&gt;del aprx&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Not sure if it will work but maybe give it a try?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 17:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1374899#M77959</guid>
      <dc:creator>Murtaza_Mir</dc:creator>
      <dc:date>2024-01-26T17:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple projects through python to PDF</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1375425#M78022</link>
      <description>&lt;P&gt;I think this is pointing me in the right direction. The code managed to reach into the first project folder, find the .aprx, and find the first layout within it. On the last for loop though it gives me an OSError&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
  File "W:\Websites\GISHomepage\MapGallery\ProProjects\ExportPrototype.py", line 21, in &amp;lt;module&amp;gt;
    layout.exportToPDF(pdf_name)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_
    return fn(*args, **kw)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 2567, in exportToPDF
    return convertArcObjectToPythonObject(self._arc_object.exportToPDF(*gp_fixargs((out_pdf, resolution, image_quality,
OSError: 6MileFireInsurance_Large\6MileFireInsurance_All_Large\.pdf&lt;/LI-CODE&gt;&lt;P&gt;Is it treating the .pdf as something within the Layout?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 15:18:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/exporting-multiple-projects-through-python-to-pdf/m-p/1375425#M78022</guid>
      <dc:creator>EricDorman</dc:creator>
      <dc:date>2024-01-29T15:18:03Z</dc:date>
    </item>
  </channel>
</rss>

