HPDF 1.2 and a Fashion Magazine in Haskell

I am pleased to release a new version of my PDF library for Haskell and an example showing what's possible with the library : a magazine generated in an automatic way with Haskell.

The parsing for the magazine has not yet been debugged totally and the image layout algorithm is currently very simple. The text formatting in columns is not always ok because I have not yet implemented an hyphenation algorithm. But, the result, still in beta, is good.

UPDATE : I had to remove the magazine. Other people working with me on that project don't want it to be visible while it is in the testing phase.

1. Layout

So, what's new in HPDF 1.2 compared to HPDF 1.1 ? Answer : the layout features.

I have added a simple new concept : a container that can be used with the function fillContainer whose type is:

 fillContainer :: (ParagraphStyle ps s, ComparableStyle ps) => VerState ps
               -> Container ps s
               -> [VBox ps s]
               -> (Draw(),Container ps s,[VBox ps s])

The first argument is the vertical style used to control the interline space and dilatation. The second argument is a container described by a rectangle on the page. The third argument is a list of boxes to place vertically in the container.

The result is first a draw value used to draw the text in the container. The second part of the result is new container used to get the content size since the container may not be totally full and some lines may overflow horizontally.

The last part of the result is a remaining list of boxes not placed in the container because there was not enough remaining place. Note that a VBox can be a paragraph. The linebreaking algorithm will restart on the remaining part of the paragraph if it was not possible to put the full paragraph in the container.

I have also added left, right and centered justification for the line breaking algorithm.

2. Annotation

In the PDF spec an annotation is using page coordinates. So, if you change the coordinates with a matrix transform, it won't impact the annotation. It is annoying because an annotation may be an url link that you want to put over a line of text and that line may be impacted by the matrix transforms.

It is solved in HPDF 1.2. The library is tracking the matrix transforms and will apply them to the annotations.

3. Style

The style API has totally changed. It is now based on algebraic data types. You'll need to create an algebraic datatype for the horizontal style and one for the paragraph style. Look at test.hs in Test folder.

4. Misc

Lots of bugs where corrected.

In the next version I'll try to add an hyphenation algorithm based upon Liang thesis. And I'll finally add support for unicode and truetype fonts.

As usual, the library can be downloaded on Hackage

(This post was imported from my old blog. The date is the date of the import. The comments where not imported.)

blog comments powered by Disqus