arcpy convert pdf to jpg

5948
4
Jump to solution
12-30-2014 01:52 PM
SteveLong
New Contributor III

Hello,

I have a task of grabbing a page from a pdf document and save it as an image file, jpeg would be fine.

I can get a page of a pdf using:

pdfDoc = arcpy.mapping.PDFDocumentOpen(output_pdfPath)

pdfDoc.deletePages(pagesToDelete)

pdfDoc.saveAndClose()

Does anyone know how to take that newly saved pdfDoc and export it as a jpeg?

Thanks,

0 Kudos
1 Solution

Accepted Solutions
SteveLong
New Contributor III

So, we settled on using Ghostscript and shelling out in some fashion via python running and external process to convert from the .pdf to a .tif. Hope this helps someone.

View solution in original post

0 Kudos
4 Replies
XanderBakker
Esri Esteemed Contributor

There are some blogs and post outside of GeoNet that threat this topic:

Ned Batchelder: Extracting JPGs from PDFs

Converting a PDF to a series of images with Python - Stack Overflow 

0 Kudos
BondHarper
Occasional Contributor II

You could use Image Magick (ImageMagick: Convert, Edit, Or Compose Bitmap Images ) which can be called from Python via a few different interfaces (such as PythonMagick).

0 Kudos
SteveLong
New Contributor III

Yes, I've seen those two posts. The Ned Batchelder post doesn't work at all. I am attaching the .jpg it produced. It seems to have only extracted the water mark and not the map.

The problem with ImageMagick is that I'd have to install it on the user's machine, an undesirable side effect.

Is there any other way to get this done?

Stevejpg0.jpg

0 Kudos
SteveLong
New Contributor III

So, we settled on using Ghostscript and shelling out in some fashion via python running and external process to convert from the .pdf to a .tif. Hope this helps someone.

0 Kudos