Re: [Xournal-devel] xournal with search and jump to next/previous annotation
Brought to you by:
andreasb123,
auroux
From: Denis A. <au...@ma...> - 2009-12-14 06:47:35
|
Hi Daniel, In the canvas coordinate system, the origin is the top-left-most point of the document, and the rectangle occupied by a given page has upper-left corner at (page->hoffset, page->voffset) and lower right corner at (page->hoffset + page->width, page->voffset + page->height). (the Y axis increases downwards; the units are points (1/72 in)). In the PDF coordinate system, the origin is usually at the lower-left corner of the page, but there can be exceptions. I haven't been able to find any way in the poppler API to get the bounding box of the page, only its size, so either there's a missing piece of the API, or poppler always converts things so the lower-left corner is (0,0). Who knows. The Y axis increases going upwards; the units are points (1/72 in), however the page may be scaled differently in the xournal document since one can change the paper size. With this understood, let's say that you have gotten the page size from poppler by something like poppler_page_get_size(pdfpage, &pdfwidth, &pdfheight); Then a point with coordinates (x,y) in the PDF system translates to the point with coordinates (page->hoffset + x*page->width/pdfwidth, page->voffset + page->height - y*page->height/pdfheight) in the canvas. This is again assuming the page does start at (0,0), but unless you see a way to get the page's cropbox in the poppler API, that'll have to be the standing assumption (it only fails for a few specific documents, 2005 US federal tax forms being one notable example; and perhaps poppler always brings back the corner to (0,0) anyway). Denis On 12/14/2009 03:12 AM, D M German wrote: > > > Hi everybody, > > as I mentioned before, I have been trying to implement search. So far I > have the interface for the search box done, and very rudimentary search > support (xournal will jump to the next page where the string appears). > > There are several tasks that need to be done, but perhaps the most > important is to highlight the search result. > > I am not a very good UI programmer, but if somebody can help me figure > out how to determine the canvas coordinates to use (i.e. help me use the > PDF coordinates to draw the box around the text) I can continue > improving the search backend. > > Because my current development version of xournal has several UI patches > applied, it has been difficult to create a patch (due to glade generated > code). For that reason I am creating a bare git repo with my changes. It > might be useful to those who want to track my changes, or help: > > > http://github.com/dmgerman/xournal > > > thanks in advance, > -- Denis Auroux au...@ma... MIT Department of Mathematics ON LEAVE AT UC BERKELEY 77 Massachusetts Ave. 2-236 Cambridge MA 02139 |