Haskell PDF 0.3
Posté par alpheccar le27 Oct 2006 à 20:11 CEST
I made some updates to my small Haskell PDF library.
I removed a space leak (see below), corrected a bug in the management of the PDF resources, added support for shading (axial and radial) and transparency. I improved a little bit the text handling and added support for clipping.
To get the update:
darcs get http://darcs.alpheccar.org/HPDF
The first version was using LOT OF memory because of my use of the StateT monad. It is lazy and initialy I was writing:
writeText f text = do (s,t) <- get
put (s + (length text),t)
lift $ hPutStr f text
but the total length of the text was not computed until the very end. So, for a big PDF it was wasting lot of memory. So, I added a seq operator to force the evaluation of s. It improved a lot the behavior of the library for big PDF files (like a penrose 11).
Have fun !


Posté par alpheccar le05 Jun 2007 à18:42 CEST
When I developped that library I was a newbie too. As a consequence, the API is really not good at all and if I had the time, the 0.4 version would use a totally different API. So, in its current form it is an experiment and no more than that. The goal was not to reinvent the wheel but to learn Haskell.
Pipe PS to ps2pdf?
Posté par Dave Bayer le05 Jun 2007 à18:01 CEST
I'm a Haskell newbie evaluating my options for generating PDF. While I admire this effort, my conclusion is that not every wheel needs to be reinvented in Haskell. Ghostscript is well established as the most robust open-source option, and ps2pdf is an easy-to-use script calling Ghostscript. To get properly sized PDF files, one needs to write Postscript files of the form
%!PS-Adobe-2.0 << /PageSize [100 100] >> setpagedevice 10 setlinewidth 5 5 moveto 0 90 rlineto 90 0 rlineto 0 -90 rlineto closepath stroke showpage
and process them with ps2pdf. That's all one needs to know about PDF; Postscript is a much easier format for Haskell programs to generate.
Posté par alpheccar le13 Déc 2006 à19:07 CEST
You have to be patient because I don't know when I will update it. It is on my to do list but that list is long :-)
Posté par Alexey Zakhlestin le13 Déc 2006 à18:34 CEST
ok. then I am waiting for an update ;)
I actually try to use your api as an instrument for making non-dynamic excersises from "Haskell School of Expression"
Posté par alpheccar le13 Déc 2006 à17:54 CEST
It is already in the wiki :-) Section libraries in Graphics.
I intend to update the library and totally change the API and take into account some very good suggestions I got from apfelmus. The new API will use monads. The path API will also be totally changed and improved.
I'll take any suggestion into account :-)
Posté par Alexey Zakhlestin le13 Déc 2006 à17:07 CEST
notes about API:
would be useful if 1) startPathAt/addLineToPath/... family of functions took tuples with coordinates as parameters 2) there was the function addPoly which would take [Point] (list of tuples) as it's parameter
Posté par Alexey Zakhlestin le12 Déc 2006 à22:26 CEST
You should add your library to the wiki: http://haskell.org/haskellwiki/Libraries_and_tools/Graphics
It would be much easier to find it, then