Note that there are some explanatory texts on larger screens.

plurals
  1. POPrinting with Gtk.Printing/cairo/pango in gtk2hs - Print-operations in Haskell
    primarykey
    data
    text
    <p>I am currently trying to print files or text (to a printer, not to a terminal etc.) in Haskell with gtk(2hs) using <code>Graphics.UI.Gtk.Printing</code>, Cairo and Pango.</p> <p>Code is the following:</p> <pre><code>op &lt;- printOperationNew on op printOptBeginPrint $ \context -&gt; do set op [ printOperationNPages := 1] return () on op printOptDrawPage $ \context pages - do let text = "Hello World" putStrLn $ "Printing :" ++ text --cairo cairoContext&lt;- printContextGetCairoContext context --pango layout&lt;- printContextCreatePangoLayout context layoutSetText layout text let _ = do --inside the Render Monad showLayout layout return () return () result &lt;- printOperationRun op PrintOperationActionPrintDialog window </code></pre> <p>This prints an empty page since I set the <code>printOperationNPages</code> to 1. The problem is that cairo does not draw anything. I suppose I have to connect the <code>cairoContext</code> with the pango layout, the proper call to <code>showLayout</code> would actually be <code>pango_cairo_show_layout (cr, layout);</code>.</p> <p>I already discussed this problem on the mailing list for gtk2hs [1].</p> <p>So if anybody has experience with this, please let me know. I would also be grateful for other - preferable platform-independent - solutions to printing files/text in haskell.</p> <p>Link to conversation: [1] <a href="http://sourceforge.net/mailarchive/message.php?msg_id=27662267" rel="nofollow">http://sourceforge.net/mailarchive/message.php?msg_id=27662267</a></p> <p>GTK(2hs) in Hackage: <a href="http://hackage.haskell.org/package/gtk-0.12.0" rel="nofollow">http://hackage.haskell.org/package/gtk-0.12.0</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload