diff --git a/Makefile b/Makefile index be3e85f..fa8e1f3 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Build the cpdf command line tools and top level MODS = cpdfyojson cpdfxmlm \ cpdferror cpdfjson cpdfstrftime cpdfcoord cpdfattach \ - cpdfpagespec cpdfposition cpdf cpdfcommand + cpdfpagespec cpdfposition cpdffont cpdf cpdfcommand SOURCES = $(foreach x,$(MODS),$(x).ml $(x).mli) cpdfcommandrun.ml diff --git a/cpdffont.ml b/cpdffont.ml new file mode 100644 index 0000000..3c0e8e4 --- /dev/null +++ b/cpdffont.ml @@ -0,0 +1,14 @@ +(* Embed missing fonts with Ghostscript. *) +let embed_missing_fonts path_to_ghostscript gs_quiet fi fo = + if path_to_ghostscript = "" then begin + Printf.eprintf "Please supply path to gs with -gs\n%!"; + exit 2 + end; + let gscall = + path_to_ghostscript ^ + " -dNOPAUSE " ^ (if gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ Filename.quote fo ^ + " -dBATCH " ^ Filename.quote fi + in + match Sys.command gscall with + | 0 -> exit 0 + | _ -> Printf.eprintf "Font embedding failed.\n%!"; exit 2 diff --git a/cpdffont.mli b/cpdffont.mli new file mode 100644 index 0000000..499b5cc --- /dev/null +++ b/cpdffont.mli @@ -0,0 +1 @@ +val embed_missing_fonts : string -> bool -> string -> string -> unit