all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Does ps-print-buffer-with-faces give the correct colors?
@ 2006-11-22 18:25 Mathias Dahl
  2006-11-22 22:35 ` Peter Dyballa
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Mathias Dahl @ 2006-11-22 18:25 UTC (permalink / raw)



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"))
         (result
          (call-process ps2pdf-gs-program nil nil t
                       "-q" "-dNOPAUSE" "-sDEVICE=pdfwrite" 
                       (concat "-sOutputFile=" pdf-file)
                       file)))
    (if (eq 0 result)
        pdf-file
      (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"))
         (pdf-file))
    (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)
    pdf-file))

(defun w32-ps2pdf-from-buffer ()
  (interactive)
  (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
following:

...
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
Gimp.

You can see the screenshots here:

http://www.flickr.com/photos/klibb/303651087/ (Emacs buffer)

http://www.flickr.com/photos/klibb/303651103/ (PDF in Acrobat)

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

/Mathias

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-11-27  9:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-22 18:25 Does ps-print-buffer-with-faces give the correct colors? Mathias Dahl
2006-11-22 22:35 ` Peter Dyballa
2006-11-23  4:08   ` Eli Zaretskii
2006-11-23 10:46     ` Peter Dyballa
2006-11-23  0:43 ` Mathias Dahl
2006-11-23  4:16   ` Eli Zaretskii
     [not found] ` <mailman.1005.1164235028.2155.help-gnu-emacs@gnu.org>
2006-11-23  9:29   ` Mathias Dahl
2006-11-23 17:32 ` Mathias Dahl
2006-11-24 20:16   ` Kim F. Storm
2006-11-24 23:15     ` Lennart Borgman
2006-11-25 10:21       ` Eli Zaretskii
     [not found]   ` <mailman.1023.1164399420.2155.help-gnu-emacs@gnu.org>
2006-11-27  9:28     ` Mathias Dahl

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.