[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Does ps-print-buffer-with-faces give the correct colors?

From: Mathias Dahl
Subject: Does ps-print-buffer-with-faces give the correct colors?
Date: Wed, 22 Nov 2006 19:25:47 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.90 (windows-nt)

I made a small hack today while playing wirh Ghostscript. It creates a
PDF file of the current buffer in Emacs. The problem is that the
colors of the faces become strange.

Here is the code:


(defcustom ps2pdf-gs-program "C:/Program Files/GPLGS/gswin32c.exe"
  "Path to GhostView program."
  :type 'string
  :group 'ps2pdf)

(defun ps2pdf-convert (file)
  (let* ((pdf-file (concat (file-name-sans-extension file) ".pdf"))
          (call-process ps2pdf-gs-program nil nil t
                       "-q" "-dNOPAUSE" "-sDEVICE=pdfwrite" 
                       (concat "-sOutputFile=" pdf-file)
    (if (eq 0 result)
      (error "PDF creation failed"))))

(defun ps2pdf (file)
  (interactive "fSelect Postscript file: ")
  (let ((pdf-file (ps2pdf-convert file)))
    (message "PDF file %s created successfully" pdf-file)))

(defun ps2pdf-from-buffer ()
  (let ((fname (make-temp-file "ps2pdf-buffer" nil ".ps"))
    (ps-print-buffer-with-faces fname)
    (message "Postscript file %s created" fname)
    (setq pdf-file (ps2pdf-convert fname))
    (message "PDF file %s created successfully" pdf-file)

(defun w32-ps2pdf-from-buffer ()
  (w32-shell-execute "Open" (ps2pdf-from-buffer)))

(provide 'ps2pdf)


How does `ps-print-buffer-with-faces' calculate the colors from the
faces in the buffer? Something is clearly wrong. I took a screenshot
of the Emacs buffer and used Gimp to check the color values of a
specific text on the screen. The values were: Red: 63%, Green: 13%,
Blue: 94%. In the ps file that Emas generates, I can see the

0.686 0.933 0.933 FG
(lambda) S

I don't know what kind of values those are but clearly two of the
values are the same, which is not the case when I checked the color in

You can see the screenshots here: (Emacs buffer) (PDF in Acrobat)

I tested this on Windows XP with a quite recent (November 2006) CVS
Emacs and the newest GPL Ghostscript version.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]