Skip to content

Instantly share code, notes, and snippets.

@phretor
Created September 27, 2013 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phretor/6726953 to your computer and use it in GitHub Desktop.
Save phretor/6726953 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
import sys
import argparse
import subprocess
import shlex
def main():
parser = argparse.ArgumentParser(
description='Takes a PDF and attempts to embed the fonts.')
parser.add_argument('-p', help='Paper size', default='a4')
parser.add_argument('input_file', help='The input PDF')
parser.add_argument('output_file', help='The output PDF')
args = parser.parse_args()
cl = 'gs -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite'\
' -sPAPERSIZE=%s -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer'\
' -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true'\
' -dEmbedAllFonts=true -sOutputFile="%s" -f "%s"' % (
args.p, args.output_file, args.input_file)
return subprocess.Popen(shlex.split(cl))
if __name__ == '__main__':
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment