This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# @date 18/08/2015 | |
# @author Cindy Williams | |
# | |
# Converts a range of pages from a pdf to separate tiff | |
# files using the PDF to TIFF tool added at ArcGIS 10.3. | |
# For very basic conversion, with minimal error handling. | |
# | |
# For use as a standalone script. | |
# | |
import arcpy | |
import os | |
def convertPDFtoTIFF(in_pdf, out_folder, out_tiff, start_page=1, end_page=1): | |
if start_page > end_page: | |
print("The start page number cannot exceed the end page number.") | |
else: | |
for i in range(start_page, end_page + 1): | |
out_tiff_name = os.path.join(out_folder, out_tiff + str(i) + ".tif) | |
arcpy.conversion.PDFtoTIFF(in_pdf, out_tiff_name, pdf_page_number=i) | |
print("Processed page " + str(i)) | |
pdf_in = r"C:\Some\Arb\Folder\test.pdf" | |
tif_folder = r"C:\Some\Arb\Folder\tiffs" | |
convertPDFtoTIFF(pdf_in,tif_folder, "Page_", 2,9) | |
print("Script complete.") |
A new tool was added to ArcGIS 10.3 to convert a page in a PDF to TIFF. This is especially useful for the asset management work I do, as I often get pdf drawings or maps which need to be georeferenced. I created a function to wrap around the ArcGIS one to enable the conversion of more than one page in the pdf at a time.
By default, the function will only convert the first page. Specifying a start and/or end page will override the defaults. Link to the code is here.