English 中文(简体)
与Gtk.Printing/cairo/pango合编的印刷-Haskell的印刷
原标题:Printing with Gtk.Printing/cairo/pango in gtk2hs - Print-operations in Haskell

我目前正在尝试使用、开罗和潘戈,在Haskell印刷文档或文本(向打印机,而不是终端等)。

法典如下:

op <- printOperationNew
on op printOptBeginPrint $ context ->   do
                                 set op [ printOperationNPages := 1]
                return ()

on op printOptDrawPage $ context pages -     do
                     let text = "Hello World"
                     putStrLn $ "Printing :" ++ text

                     --cairo
                     cairoContext<- printContextGetCairoContext context

                     --pango
                     layout<- printContextCreatePangoLayout context

                     layoutSetText layout text

                     let _ = do
                     --inside the Render Monad
                                 showLayout layout
                                 return ()
                     return ()

result <- printOperationRun op PrintOperationActionPrintDialog window

This prints an empty page since I set the printOperationNPages to 1. The problem is that cairo does not draw anything. I suppose I have to connect the cairoContext with the pango layout, the proper call to showLayout would actually be pango_cairo_show_layout (cr, layout);.

我已在邮寄特克2hs名单中讨论了这一问题。

因此,如果有人有这方面的经验,请让我知道。 我也要感谢其他更好的依赖平台的解决办法,即印刷纸面文件/文字。

Link to conversation: [1] http://sourceforge.net/mailarchive/message.php?msg_id=27662267

GTK(2hs) in Hackage: http://hackage.haskell.org/package/gtk-0.12.0

问题回答

Have you tried to use GtkPrintUnixDialog instead?
Much simpler to use. Basically you create the GtkPrintUnixDialog, Create a GtkPrintJob. Set the print to to source file (text,pdf you name it) and then print it out. You can also not show the dialog so that it uses the default print settings on the system.





相关问题
Euler Problem in Haskell -- Can Someone Spot My Error

I m trying my hand at Euler Problem 4 in Haskell. It asks for that largest palindrome formed by multiplying two three-digit numbers. The problem was simple enough, and I thought my Haskell-fu was up ...

How does foldr work?

Can anybody explain how does foldr work? Take these examples: Prelude> foldr (-) 54 [10, 11] 53 Prelude> foldr (x y -> (x+y)/2) 54 [12, 4, 10, 6] 12.0 I am confused about these executions....

Efficient queue in Haskell

How can I efficiently implement a list data structure where I can have 2 views to the head and end of the list, that always point to a head a tail of a list without expensive calls to reverse. i.e: ...

Problem detecting cyclic numbers in Haskell

I am doing problem 61 at project Euler and came up with the following code (to test the case they give): p3 n = n*(n+1) `div` 2 p4 n = n*n p5 n = n*(3*n -1) `div` 2 p6 n = n*(2*n -1) p7 n = n*(5*n -3)...

Ways to get the middle of a list in Haskell?

I ve just started learning about Functional Programming, using Haskel. I m slowly getting through Erik Meijer s lectures on Channel 9 (I ve watched the first 4 so far) and in the 4th video Erik ...

haskell grouping problem

group :: Ord a => [(a, [b])] -> [(a, [b])] I want to look up all pairs that have the same fst, and merge them, by appending all the list of bs together where they have the same a and discarding ...

Closest equivalent to subprocess.communicate in Haskell

I want to do a popen() / python s subprocess.communicate from Haskell - start a program, give it stdin, and get its stdout/stderr. What s the most direct / Haskellish way to do this?

热门标签