Hi; On 7 February 2017 at 00:09, Norbert de Jonge <m...@norbertdejonge.nl> wrote:
> Yesterday, I finished the migration of a 16+ year old GTK+ 1.2 > application to GTK+ 3.18. Congrats! > In previous releases of the application, printing was done by writing > directly to "lpr". I want code to be C99 compatible, so I replaced the > popen() functions with GtkPrintOperation. > > Currently, printing works properly, but both the preview and output end > after page 1. This is, of course, not the intended behavior. > > A quick glance at the print.c source file shows the problem. The > relevant code is under "/*** print operation ***/" and in the PrintPage > function. > > The solution... I don't know. The solution would be to use Cairo to render on a PDF surface, instead of generating a massive string and then sending it to lpr, because this is not 1997 any more, and we do have better API for printing data, these days. :-) The GNOME Dictionary is a simple application that has the ability to print a text buffer. Here's the relevant, self-contained code: https://git.gnome.org/browse/gnome-dictionary/tree/src/gdict-print.c You construct a buffer of lines (possibly using things like GString, instead of sprintf()) and then use Pango to create a layout; then, Cairo to draw the layout at the given page size and position. This has the advantage of giving you PDF output and preview working out of the box. Ciao, Emmanuele. -- https://www.bassi.io [@] ebassi [@gmail.com] _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list