PDF-ShellTools > Ideas/Suggestions

Script to count how many colour pages in PDF?

<< < (4/4)

nightslayer23:

--- Quote from: RTT on July 19, 2017, 03:56:14 AM ---
--- Quote from: nightslayer23 on July 19, 2017, 12:29:43 AM ---Is there a way for the file to be flattened first before doing this conversion? Some work perfectly, but others come out at a really high percentage when they aren't technically going to print that way. I figured it was looking at other layers or some other hidden info and converting that to bw too.

--- End quote ---
Are these trouble PDF layers set to be visible in the PDF reader (screen mode) and hidden when printed? If that's the case, edit the file delegates.xml, where you have ImageMagick installed, and change the line "<delegate decode="ps:alpha" stealth="True" command="&quot;@PSDelegate@&quot; -q -dQUIET -..." to include the -dPrinted parameter.


--- Quote ---So would i be possible in code to first flatten layers before running the check?

--- End quote ---
When the ImageMagick tool calls the Ghostscript to convert each of the PDF pages to an image, that then uses to run the color check, is effectively flattening the PDF. If the issue is not the mentioned above (these layers are set to be hidden only when the PDF is printed) and even hidden layers are being rendered too, then that's an issue with Ghostscript.
If you have Acrobat, I suppose the script can automate it to flatten the PDF layers to a temporary PDF file and then run the check on that PDF.


--- Quote ---I actually batch flattened layers in acrobat and it didn't solve the issue.. I had to batch flatten AND convert everything to CMYK to get it to work.

--- End quote ---
Can't opine without a sample file.


--- Quote ---In the optimizer tool, can CMYK and RGB colour spaces be added somehow?

--- End quote ---
I'm not understanding your question. Please explain this better.

--- End quote ---

They view hidden as well. but I'm assuming that's why they come out saying an extremely high percentage.. because once I render the file, goes from saying 75% & 99% to 12% and 22% for example - which is how they view as well.

RTT:
Did you tested with the -dPrinted parameter I suggested in my previous reply?

You can easily verify if indeed the hidden layers are being erroneously rendered. From a command prompt, run (change the file paths to your system specifics):
"C:\Program Files (x86)\ImageMagick-7.0.5-Q16\magick.exe" convert "Path\To\The\PDF.pdf" "Path\Where\To\Put\The\Page\Renders\Image.png"

You can also check what image is being generated in the script, to quantify the ink utilization:
"C:\Program Files (x86)\ImageMagick-7.0.5-Q16\magick.exe" convert "Path\To\The\PDF.pdf" -colorspace gray -auto-level -threshold 99% "Path\Where\To\Put\The\Page\Renders\Image.png"

Navigation

[0] Message Index

[*] Previous page

Reply

Go to full version