all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Cc: emacs-devel@gnu.org
Subject: Re: Printing
Date: Fri, 04 May 2012 23:06:43 -0400	[thread overview]
Message-ID: <jwv1umzba5f.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <wlprf97xlv.wl%mituharu@math.s.chiba-u.ac.jp> (YAMAMOTO Mitsuharu's message of "Sun, 19 Apr 2009 19:21:16 +0900")

Hi,

I'd be interested to see this pushed further.  Maybe you could make
a branch in the bzr repository for it?


        Stefan


>>>>> "YAMAMOTO" == YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> writes:

>>>>> On Tue, 07 Apr 2009 18:46:01 +0900, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> said:

>>>> I tried making a really preliminary proof-of-concept cairo port. :-)
>>>> It's still rough and has several glitches/limitations, but at least
>>>> it can generate a "resolution-independent screenshot" PDF as
>>>> attached.  Maybe I'll clean up the code this weekend and hopefully
>>>> post a patch.

>>> Here's the patch for the Emacs 23.0.92 pretest (not the trunk HEAD).

>>> * No configure support.  The easiest way would be to compile it with
>>> the GTK+ support that is already linked with cairo libs.  Add
>>> -DUSE_CAIRO to CFLAGS to activate the cairo code.

>>> * Currently, texts, rectangles (filling and stroking), and trapezoids
>>> for reliefs are drawn using cairo by hooking the corresponding
>>> drawing routine calls in xterm.c.

> This time, I combined the cairo drawing code with GTK+ print dialogs
> code, which is actually almost the same as examples in the GTK+
> reference.  The added primitives are:

> (x-page-setup-dialog): Pop up a page setup dialog.
> (x-get-page-setup): Return the value of the current page setup.
>   It returns an alist like
>   ((orientation . portrait)
>    (width . 559.2755905511812) (height . 783.5697637795276)
>    (left-margin . 18.0) (right-margin . 18.0)
>    (top-margin . 18.0) (bottom-margin . 40.32000000000001))
> (x-print-frames-dialog FRAMES): Pop up a print dialog to print the
>   current contents of FRAMES.

> The last one is intended to be called after some pagination (in Lisp)
> that creates a frame per page.  Below is a simple example.

> (defun test-print-buffer (buffer-or-name)
>   "Paginate and print buffer contents."
>   (interactive "bBuffer to export:")
>   (with-current-buffer buffer-or-name
>     (let* ((buffer (current-buffer))
> 	   (start-pos (point-min))
> 	   (end-pos (point-max))
> 	   (page-setup (if (fboundp 'x-get-page-setup)
> 			   (x-get-page-setup)
> 			 '((width . 559.0) (height . 783.0))))
> 	   (width-in-points (cdr (assq 'width page-setup)))
> 	   (height-in-points (cdr (assq 'height page-setup)))
> 	   buffers frames)
>       (unwind-protect
> 	  (progn
> 	    (with-selected-frame (selected-frame)
> 	      ;; Paginate and create a frame for each page.
> 	      (while (< start-pos end-pos)
> 		(let ((inhibit-quit t))
> 		  (set-buffer
> 		   (make-indirect-buffer
> 		    buffer (generate-new-buffer-name (buffer-name buffer)) t))
> 		  (push (current-buffer) buffers)
> 		  (setq kill-buffer-hook nil) ;; XXX
> 		  (select-frame (make-frame
> 				 '((internal-border-width . 0)
> 				   (vertical-scroll-bars . nil)
> 				   (left-fringe . 0) (right-fringe . 0)
> 				   (menu-bar-lines . 0) (tool-bar-lines . 0)
> 				   (line-spacing . 0)
> 				   (minibuffer . nil) (visibility . nil)
> 				   (cursor-type . nil)))
> 				'norecord)
> 		  (push (selected-frame) frames))
> 		(set-frame-size (selected-frame)
> 				(floor (/ width-in-points (frame-char-width)))
> 				(floor (/ height-in-points (frame-char-height))))
> 		(setq header-line-format nil)
> 		(setq mode-line-format nil)
> 		(set-window-start nil start-pos)
> 		(goto-char (window-end nil t))
> 		(while (and (< start-pos (point))
> 			    (not (pos-visible-in-window-p (1- (point)))))
> 		  (backward-char))
> 		(narrow-to-region start-pos (point))
> 		(setq start-pos (point))))
> 	    ;; Print the frames.
> 	    (if (null frames)
> 		(error "Buffer %s is empty" buffer-or-name)
> 	      (mapc 'make-frame-visible frames)
> 	      (if (fboundp 'x-print-frames-dialog)
> 		  (x-print-frames-dialog (reverse frames))
> 		;; Dummy stub just to reproduce an intermittent error
> 		;; in x-print-frames-dialog even without it.
> 		(dolist (frame frames)
> 		  (unless (eq (frame-visible-p frame) t)
> 		    (error "Frames to be printed must be visible.")))
> 		(redisplay t))))
> 	;; Clean up
> 	(mapc 'delete-frame frames)
> 	(mapc 'kill-buffer buffers)))))

> You can try printing with M-x test-print-buffer RET.  Because the
> current cairo drawing routines are hooked onto those in xterm.c in
> order to minimize the change, you'll see the actual frames on screen.
> Moreover, you might get an incorrect printed result because your
> window manager may clip the frames to fit in the screen size.
> Nevertheless, I think you can get the basic idea with this sample
> code.

> 				     YAMAMOTO Mitsuharu
> 				mituharu@math.s.chiba-u.ac.jp




  reply	other threads:[~2012-05-05  3:06 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-28 10:31 Printing Андрей Парамонов
2009-03-28 14:56 ` Printing Jan Djärv
2009-03-31  2:13   ` Printing YAMAMOTO Mitsuharu
2009-04-02  9:39     ` Printing YAMAMOTO Mitsuharu
2009-04-04  2:44       ` Printing YAMAMOTO Mitsuharu
2009-04-04  6:54         ` Printing Lennart Borgman
2009-04-04  7:25           ` Printing YAMAMOTO Mitsuharu
2009-04-04  9:40         ` Printing Leo
2009-04-04 22:00         ` Printing Richard M Stallman
2009-04-05  1:07           ` Printing YAMAMOTO Mitsuharu
2009-04-06  8:03         ` Printing Kenichi Handa
2009-04-06  8:45           ` Printing YAMAMOTO Mitsuharu
2009-04-06 11:47             ` Printing Kenichi Handa
2009-04-06 23:47               ` Printing YAMAMOTO Mitsuharu
2009-04-07  1:01                 ` Printing Kenichi Handa
2009-04-07  1:14                   ` Printing YAMAMOTO Mitsuharu
2009-04-08  1:19                     ` Future of display engine [Re: Printing] Kenichi Handa
2009-04-08  1:53                       ` YAMAMOTO Mitsuharu
2009-04-07  9:46         ` Printing YAMAMOTO Mitsuharu
2009-04-08  1:33           ` Printing Kenichi Handa
2009-05-01 23:30             ` Printing YAMAMOTO Mitsuharu
2009-04-19 10:21           ` Printing YAMAMOTO Mitsuharu
2012-05-05  3:06             ` Stefan Monnier [this message]
2012-05-07  3:38               ` Printing YAMAMOTO Mitsuharu
2012-05-07 11:25                 ` Printing Lennart Borgman
2012-05-08  1:04                   ` Printing YAMAMOTO Mitsuharu
2012-05-08  1:25                     ` Printing Lennart Borgman
2012-05-08  2:15                       ` Printing YAMAMOTO Mitsuharu
2012-05-08 10:59                         ` Printing Lennart Borgman
2012-05-09 14:50                   ` Printing Jason Rumney
2012-05-09 14:58                     ` Printing Lennart Borgman
2012-05-07 12:46                 ` Printing Stefan Monnier
2012-05-07 13:07                   ` Printing joakim
2012-05-07 17:20                   ` Printing Simon Leinen
2012-05-08  1:11                     ` Printing YAMAMOTO Mitsuharu
2009-03-28 15:46 ` Printing Michael Ekstrand
2009-03-28 18:37 ` Printing Stefan Monnier
2009-03-28 20:52   ` Printing Андрей Парамонов
2009-03-30 13:06     ` Printing Michael Ekstrand
2009-03-30 15:24       ` Printing Stefan Monnier
2009-03-30 18:38         ` Printing Eli Zaretskii
2009-03-31  1:56           ` Printing Stefan Monnier
2009-03-31  3:15             ` Printing Eli Zaretskii
2009-04-01  0:52               ` Printing Stefan Monnier
2009-04-01  3:14                 ` Printing Eli Zaretskii
2009-04-01  4:17                   ` Printing Miles Bader
2009-04-01 17:53                     ` Printing Eli Zaretskii
2009-04-01  4:24                   ` Printing Jason Rumney
2009-04-01 17:56                     ` Printing Eli Zaretskii
2009-04-01  8:11                   ` Printing Stephen J. Turnbull
2009-04-01 14:36                   ` Printing Stefan Monnier
2009-04-01 18:16                     ` Printing Eli Zaretskii
2009-04-01 23:42                       ` Printing Stefan Monnier
2009-04-02 13:02                       ` Printing Richard M Stallman
2009-04-02 19:37                         ` Printing Eli Zaretskii
2009-04-02 10:08                   ` Printing tomas
2009-04-02 10:52                     ` Printing Lennart Borgman
2009-04-02 11:51                       ` Printing tomas
2009-04-02 11:49                         ` Printing Lennart Borgman
2009-04-02 13:37                           ` Printing Stefan Monnier
2009-04-02 13:47                             ` Printing Óscar Fuentes
2009-04-02 13:55                               ` Printing Samuel Bronson
2009-04-02 14:24                                 ` Printing Óscar Fuentes
2009-04-02 14:34                                   ` Printing Lennart Borgman
2009-04-02 14:00                             ` Printing Lennart Borgman
2009-04-02 16:15                               ` Printing Stefan Monnier
2009-04-02 16:47                                 ` Printing Reiner Steib
2009-04-02 19:44                                 ` Printing Eli Zaretskii
2009-04-03  0:43                                   ` Printing Stefan Monnier
2009-04-02 20:56                                 ` Printing Lennart Borgman
2009-04-04  0:00                                   ` Printing Lennart Borgman
2009-04-04  0:36                                     ` Printing Stefan Monnier
2009-04-04  0:45                                       ` Printing Lennart Borgman
2009-04-04  1:05                                         ` Printing Óscar Fuentes
2009-04-04  6:52                                           ` Printing Lennart Borgman
2009-04-04  8:57                                     ` Printing Eli Zaretskii
2009-04-04  9:22                                       ` Printing Lennart Borgman
2009-04-04  9:49                                         ` Printing Eli Zaretskii
2009-03-28 20:30 ` Printing James Cloos
2009-03-29  2:15 ` Printing Richard M Stallman
2009-03-29  3:20   ` Printing Eli Zaretskii
2009-03-30  1:17     ` Printing Richard M Stallman
2009-03-30  3:10       ` Printing Eli Zaretskii
2009-03-30  6:36         ` Printing Lennart Borgman
2009-03-30 18:41           ` Printing Eli Zaretskii
2009-03-30 19:04             ` Printing Lennart Borgman
2009-03-30 20:48               ` Printing Eli Zaretskii
2009-03-30 20:53                 ` Printing Lennart Borgman
2009-03-30 20:59                   ` Printing Eli Zaretskii
2009-03-30 21:27                     ` Printing Lennart Borgman
2009-03-31  3:19                       ` Printing Eli Zaretskii
2009-03-30 21:46                   ` Printing Óscar Fuentes
2009-03-30 21:50         ` Printing Richard M Stallman
2009-03-31  3:18           ` Printing Eli Zaretskii
2009-03-31 19:14             ` Printing Richard M Stallman
2009-03-30 18:03   ` Printing Андрей Парамонов
  -- strict thread matches above, loose matches on Subject: below --
2022-12-17 12:31 printing Gottfried
2022-12-17 13:09 ` printing tomas
2022-12-14 16:38 wie kann ich Emacs so einstellen, dass ich drucken kann Gottfried
2022-12-14 17:27 ` Philip Kaludercic
2022-12-16 15:27   ` printing Gottfried
2022-12-16 22:26     ` printing Michael Heerdegen
2022-12-17  6:29       ` printing tomas
2022-12-17  7:41         ` printing Emanuel Berg
2022-12-17 13:48     ` printing Gottfried
2022-12-17 16:30       ` printing tomas
2016-03-03 14:35 Printing Sharon Kimble
2016-03-03 20:22 ` Printing tomas
2016-03-05 13:40 ` Printing Robert Thorpe
2009-04-01 17:22 Printing grischka
2009-04-01 18:55 ` Printing David De La Harpe Golden
2009-04-01 18:58   ` Printing David De La Harpe Golden
2009-04-01 20:51   ` Printing grischka
2009-04-01 21:19   ` Printing Lennart Borgman
2009-04-02  0:09   ` Printing David De La Harpe Golden
2009-04-01 23:32 ` Printing Stefan Monnier
2009-04-02  2:33   ` Printing grischka
2009-04-02  3:05     ` Printing Samuel Bronson
2009-04-02 13:41       ` Printing grischka
2009-04-02 13:31     ` Printing Stefan Monnier
2009-04-02 18:39       ` Printing grischka
2009-04-02 18:53         ` Printing Stefan Monnier
2003-03-18 21:18 printing Kevin Reeder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv1umzba5f.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=mituharu@math.s.chiba-u.ac.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.