Is it possible to use ASObjC to remove images from a PDF but to otherwise leave the formatting unchanged? Right now I use a commandline utility called cpdf, but I’d prefer to use ASObjC. A Google search and a review of the PDFDocument documentation didn’t disclose anything that would appear to do the job. Thanks.
As you’ve figured out, there is only the PDFDocument class available to us, which is part of the PDFKit Framework.
But having used it a lot in the past, I can’t remember they’re being anyway of remove images from the documents.
It’s a good a option for combining or merging documents, or for reordering and editing text in the pages, but falls short of abilities to manipulate images.
I believe there are a few powerful command line tools for working with PDF Documents, maybe it’s worth building an AppleScript front end for controlling these command line tools through “do shell script”, or the NSTask class.
Regards Mark
Thanks Mark. I suspected that was the case but occasionally I’m surprised at the stuff ASObjC can do.
BTW, I had no knowledge of NSTask and did a little research. Just to get the basics down, I wrote and timed the following, which took 0.003 second to run:
set theTool to "/usr/bin/say"
set theTask to current application's NSTask's new()
theTask's setLaunchPath:theTool
theTask's setArguments:{"OK"}
theTask's |launch|()
I then tested the do shell script, which took 0.664 second to run:
do shell script "say ok"
Thanks Fredrik71 for the ideas. Right now I use the cpdf command-line utility to remove bitmap images from PDF’s and that works OK. I’ve converted all but two of my PDF scripts to use ASObjC and thought I might reduce that number to one but won’t be able to do that.