EDIT: It turns out that Lua is not needed. Since I call my TeX from script, the necessary investigation can be done directly, using
findstr in Windows batch, or the equivalent in BASH. But that's using script prior to running the TeX file. The answers provided below will do it within the TeX file.
I use only LuaLaTeX, Windows and Linux. For cross-platform compatibility, and for non-admin users, I cannot invoke
sed or most other shell-escape programs from within TeX, even if it is available. I can invoke from outside TeX with a non-admin batch or BASH script.
My document class produces PDF/X-1a. Thus, any included image must be DeviceGray or DeviceCMYK. Currently, I avoid potential problems by severely limiting TeX commands that include images or other PDF. I would like to lift the limitations, if possible.
Thanks to this very helpful answer of a related question, I can block using
\includepdf if the included file has fonts in it. Now, I would like to block using
\includepdf unless the file has
DeviceCMYK written into it.
In all cases, the included PDF is just one page, one image.
If I open a suitable PDF in a hex editor, I see something like this:
10 0 obj /DeviceCMYK endobj
The actual image follows as another object (with FlateDecode).
So, to rephrase my question: Is there any way LuaLaTeX can screen a PDF file, perhaps using methods similar to
grep, and provide a yes/no answer as to whether string
I myself can simply use Adobe Acrobat Pro, or perhaps ImageMagick. This is for the benefit of more general users, without having to step outside of LuaLaTeX.