code: def compress_pdf(pdf_fpath, output_fname=None):
      
      import utool as ut
      ut.assertpath(pdf_fpath)
      suffix = '_' + ut.get_datestamp(False) + '_compressed'
      print('pdf_fpath = %r' % (pdf_fpath,))
      output_pdf_fpath = ut.augpath(pdf_fpath, suffix, newfname=output_fname)
      print('output_pdf_fpath = %r' % (output_pdf_fpath,))
      gs_exe = find_ghostscript_exe()
      cmd_list = (
          gs_exe,
          '-sDEVICE=pdfwrite',
          '-dCompatibilityLevel=1.4',
          '-dNOPAUSE',
          '-dQUIET',
          '-dBATCH',
          '-sOutputFile=' + output_pdf_fpath,
          pdf_fpath
      )
      ut.cmd(*cmd_list)
      return output_pdf_fpath
docs: uses ghostscript to write a pdf