If you do not want to deal with Shortcuts, I have just revised some attributed AppleScript/Objective-C code that allows you to select the PDF with a file chooser, and the rest is automatic. It is configured to do the following:
- Select the PDF
- Create an output folder for the split PDF images using the basename of the PDF as the output folder
- Split the PDF into 300 DPI (configurable) sequentially numbered JPG images into the folder from [2]
Copy/Paste the following code into an open Apple Script Editor, click the hammer icon to compile it, and then click the run button. The rest is automatic.
-- pdf2image.applescript
-- this is the PDF to JPG version
-- attribution: https://www.macscripter.net/t/pdf-to-tiff-script/74847
use framework "Cocoa"
use framework "PDFKit"
use AppleScript version "2.4" -- Yosemite or later
use scripting additions
property ca : current application
property resolution : 300.0
set thePDF to POSIX path of (choose file of type "com.adobe.pdf" default location (path to desktop)) as text
my pdf2jpg(thePDF, resolution)
return
on pdf2jpg(apdf, aresolution)
set pdfURL to ca's NSURL's fileURLWithPath:apdf
set pdf to ca's PDFDocument's alloc()'s initWithURL:pdfURL
set pdfFolder to pdfURL's URLByDeletingLastPathComponent
set pdfFileName to (pdfURL's URLByDeletingPathExtension())'s lastPathComponent()
set newFolder to pdfFolder's URLByAppendingPathComponent:pdfFileName
repeat with i from 1 to pdf's pageCount()
set aPage to (pdf's pageAtIndex:(i - 1))
set pageSize to (aPage's boundsForBox:(ca's kPDFDisplayBoxMediaBox))
set pageWidth to ca's NSWidth(pageSize)
set pageHeight to ca's NSHeight(pageSize)
set pixelWidth to (pageWidth * aresolution / 72) div 1
set pixelHeight to (pageHeight * aresolution / 72) div 1
set theImageRep to (ca's NSPDFImageRep's imageRepWithData:(aPage's dataRepresentation()))
set newImageRep to (ca's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:pixelWidth pixelsHigh:pixelHeight bitsPerSample:8 samplesPerPixel:4 hasAlpha:yes isPlanar:false colorSpaceName:(current application's NSDeviceRGBColorSpace) bytesPerRow:0 bitsPerPixel:32)
ca's NSGraphicsContext's saveGraphicsState()
(ca's NSGraphicsContext's setCurrentContext:(ca's NSGraphicsContext's graphicsContextWithBitmapImageRep:newImageRep))
ca's NSColor's whiteColor()'s |set|()
ca's NSRectFill({origin:{x:0, y:0}, |size|:{width:pixelWidth, height:pixelHeight}})
(theImageRep's drawInRect:{origin:{x:0, y:0}, |size|:{width:pixelWidth, height:pixelHeight}} fromRect:(ca's NSZeroRect) operation:(ca's NSCompositeSourceOver) fraction:1.0 respectFlipped:false hints:(missing value))
ca's NSGraphicsContext's restoreGraphicsState()
-- make 300 dpi pages instead of 72 dpi default if this is commented
(newImageRep's setSize:{pageWidth, pageHeight}) -- if desired
-- zero pad counter to three digits
set paddedSequence to (ca's NSString's stringWithFormat:("_%02d" & i))
set imageFileName to (pdfFileName's stringByAppendingString:paddedSequence)
set theData to (newImageRep's representationUsingType:(ca's NSBitmapImageFileTypeJPEG) |properties|:{NSImageCompressionFactor:0.8}) -- 0.0 is maximum compresssion and 1.0 is no compression
set fileMgr to ca's NSFileManager's defaultManager()
-- use the base filename as the folder to create at the current path
-- will return true if folder already exists
set {done, theError} to (fileMgr's createDirectoryAtURL:newFolder withIntermediateDirectories:true attributes:(missing value) |error|:(reference))
if done as boolean then
set theImage to ((newFolder's URLByAppendingPathComponent:imageFileName)'s URLByAppendingPathExtension:"jpg")
(theData's writeToURL:theImage atomically:true)
end if
end repeat
return
end pdf2jpg