Try writing the pdf to some temp folder before sending it to $FFout$. Like this for instance to the folder C:/Temp/
with open("C:/Temp/" + os.path.basename(sys.argv), 'wb') as f:
shutil.move("C:/Temp/" + os.path.basename(sys.argv), sys.argv)
Please see modified script.
thanks for your input and for taking the time to look at this.
I tested the changed script and with the 'move' line I don't get any file moved to my 'out' folder, it's generated inside C:\Temp and then disappears.
If I comment (#) the 'move' line in the script the PDF stays inside C:\Temp, but it's the same as I had gotten before, it's an exact copy of the original file (no BW pages in the file).
Could it be that the variable for the pages are not evaluated properly for some reason? Try adding print('color') or print('bw') inside the if/else statement like this:
for i in range(infile_color.getNumPages()):
if j in colorpages:
p = infile_color.getPage(i)
j = j + 1
p = infile_gray.getPage(i)
j = j + 1
Then check stdout for what has been written. If only 'color' has been printed then
colorpages = ast.literal_eval(sys.argv)
is not working for some reason.
Also comment out the lines
os.remove('C:/Out/' + sys.argv + '.pdf')
os.remove('C:/Out/' + sys.argv + '_gray.pdf')
to check what has been saved and that a conversion to grayscale actually has been done.
after tossing and turning, I got it working.
Apparently was the configuration of the BW conversion in the Manage Color component that wasn't the best.
I had noticed before that page 1 of my example file wasn't being converted from color to BW in the 'grey' document, but all the others were, so I didn't mind it much up until now, because I saw that in fact the newly inserted 'print' commands were logging the correct color/BW page mapping in stdout.
After correcting the Manage Color component and getting the 'grey' document fully converted to BW, the workflow started performing as expected.
Once again, thank you so much for your help and sorry for being such a python-rookie bugger. You rule!