-(define-public (postscript->pdf papersizename name)
- (let* ((pdf-name (string-append (basename name ".ps") ".pdf" ))
- (cmd (format #f
- "gs\
- -dCompatibilityLevel=1.2\
- -dSAFER\
- -sPAPERSIZE=~a\
- -q\
+(define-public (search-executable names)
+ (define (helper path lst)
+ (if (null? (cdr lst))
+ (car lst)
+ (if (search-path path (car lst)) (car lst)
+ (helper path (cdr lst)))))
+
+ (let ((path (parse-path (getenv "PATH"))))
+ (helper path names)))
+
+(define-public (search-gs)
+
+ ;; must be sure that we don't catch stuff from old GUBs.
+ (search-executable '("gs")))
+
+(define-public (postscript->pdf paper-width paper-height name)
+ (let* ((pdf-name (string-append
+ (dir-basename name ".ps" ".eps")
+ ".pdf"))
+ (is-eps (string-match "\\.eps$" name))
+ (paper-size-string (if is-eps
+ " -dEPSCrop "
+ (ly:format "-dDEVICEWIDTHPOINTS=~$ \
+-dDEVICEHEIGHTPOINTS=~$ "
+ paper-width paper-height )))
+
+ (cmd (simple-format #f
+ "~a\
+ ~a\
+ ~a\
+ ~a\
+ -dCompatibilityLevel=1.4 \