30 Oct 2013 gpoo   » (Master)

PDF Annotations in Poppler GLib

Last weekend I was in the in the mood of finishing the support to annotate PDF documents in Poppler's GLib frontend.

For those who do not know, Poppler is the library used by Evince (and by extension Documents) to render PDF documents. Any performance or visual improvement in Poppler is an improvement for Evince.

I restructured poppler-glib-demo to make easier to add and test multiple types of annotations (it was tied to text annotations, the ones that look like post-it notes). After digging Poppler's Annotation source code, I decided to start implementing lines (simple ones), then squares, circles and, finally, text markups (highlight, underline, squiggly and strike out).

Here is a screencast showing the progress so far.

In the demo, I do not draw directly on a cairo surface. I add the annotation to the page, update it accordingly while the pointer is pressed and ask Poppler to render back the PDF. The upside is what you see is the actual PDF modified interactively. The downside of this approach is a potential performance penalty in documents that Poppler is slow to render.

If you already have Evince built with a standard jhbuild, then you have everything to try this out with the following easy steps:

$ cd /to/your/jhbuild/checkout
$ git clone https://github.com/gpoo/poppler.git
$ cd poppler
$ git checkout annot-demo-fixes
$ jhbuild make
$ jhbuild shell poppler/glib/demo/poppler-glib-demo <pdf-document>

The next steps are: improve annotations in Evince, edit and move annotations, add other annotation types, and polish.

All in all, Evince is a critical application for me; I consume a lot of PDF documents and produce some. To annotate I have been using ezPDF Pro for Android, convenient but non-free and I spend more time in front of a desktop, where I also need to annotate. Mendeley's viewer was close to my needs, but also non-free. Scholiar (a kind of Xournal's fork) is good to annotate documents, but it flattens the annotations in the PDF (I believe as a workaround for the lack of proper support in Poppler's GLib frontend). So, I am looking forward to another weekend.

Syndicated 2013-10-30 02:48:00 from Moving a castle

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!