is it possible to check if pdf is password protected using ghostscript?

checkuserpasswdPDF.sh: #!/bin/sh GS=~/gs/bin/gs output=`$GS -dBATCH -sNODISPLAY “$1” 2>&1` gsexit=$? if [ “$gsexit” == “0” ]; then echo “Not user-password protected” exit 0; else found=`echo “$output” |grep -o “This file requires a password”` if [ -z “$found” ]; then echo “Failed to invoke gs” exit $gsexit else echo “Protected” exit 0; fi fi Checks for user-password … Read more

How to merge two postscript files together?

Here is an example Ghostscript commandline, which would convert and merge the two (or more) PostScript files into one PDF in a one go: gswin32c.exe ^ -o c:/path/to/output.pdf ^ -sDEVICE=pdfwrite ^ -dPDFSettings=/Screen ^ […more desired parameters (optional)…] ^ /path/to/first.ps ^ /path/to/second.ps ^ /path/to/third.pdf Edit: my first shot had falsely assumed PDF input files. It works … Read more

Script (or some other means) to convert RGB to CMYK in PDF?

This answer is not for Illustrator, but for ‘some other tool’, namely Ghostscript (download gs871w32.exe or gs871w64.exe). Ghostscript allows you to ‘re-distill’ PDFs (without an intermediate conversion to PostScript, the dreaded ‘refrying’ detour). Try this command: gswin32c.exe ^ -o c:/path/to/output-cmyk.pdf ^ -sDEVICE=pdfwrite ^ -dUseCIEColor ^ -sProcessColorModel=DeviceCMYK ^ -sColorConversionStrategy=CMYK ^ -sColorConversionStrategyForImages=CMYK ^ input-rgb.pdf And if you … Read more

Converting PDF to CMYK (with identify recognizing CMYK)

sdaau, the command you used for trying to convert your PDF to CMYK was not correct. Try this one instead: gs \ -o test-cmyk.pdf \ -sDEVICE=pdfwrite \ -sProcessColorModel=DeviceCMYK \ -sColorConversionStrategy=CMYK \ -sColorConversionStrategyForImages=CMYK \ test.pdf Update If color conversion does not work as desired and if you see a message like “Unable to convert color space … Read more

Using GhostScript to get page size

Unfortunately it doesn’t seem quite easy to get the (possibly different) page sizes (or *Boxes for that matter) inside a PDF with the help of Ghostscript. But since you asked for other possibilities as well: a rather reliable way to determine the media sizes for each page (and even each one of the embedded {Trim,Media,Crop,Bleed}Boxes) … Read more

How can I remove all images from a PDF?

Meanwhile the latest Ghostscript releases have a much nicer and easier to use method of removing all images from a PDF. The parameter to add to the command line is -dFILTERIMAGE gs -o noimages.pdf -sDEVICE=pdfwrite -dFILTERIMAGE input.pdf Even better, you can also remove all text or all vector drawing elements from a PDF by specifying … Read more