Ghostscript wipes the PDF metadata like author, title, subject etc. How can I tell ghostscript not to touch the metadata? I invoke it as follows:gs \  -dBATCH                    \  -dNOPAUSE                  \  -sOutputFile=<output_file> \  -sDEVICE=pdfwrite          \  -dPDFSETTINGS=/ebook       \  <input_file>
How to make ghostscript not wipe PDF metadata
pdf;ghostscript
Apparently it's not possible to keep the PDF metadata when usingghostscript. Here is a workaround which first saves the metadata toa file using pdftk, then compresses the file with ghostscriptand finally writes back the metadata also using pdftk.INPUTPDF=<input_file>OUTPUTPDF=<output_file>TMPPDF=$(mktemp)METADATA=$(mktemp)# save metadatapdftk $INPUTPDF dump_data_utf8 > $METADATA# compressgs                       \  -q                     \  -sOutputFile=$TMPPDF \  -sDEVICE=pdfwrite      \  -dNOPAUSE              \  -dBATCH                \  -dPDFSETTINGS=/ebook   \  $INPUTPDF# restore metadatapdftk $TMPPDF update_info_utf8 $METADATA output $OUTPUTPDF# clean uprm -f $TMPPDF $METADATAEdit: This is a bug in ghostscript, see Bug report and the confirmation that this is not supposed to happen.