Hello,

This code might work even you resize the window.
Please see: https://pastebin.com/GJMPwLU3

It draws the selected text in the "draw" event.

ps. I hard coded the PDF_DOC and FIND_TEXT values.

Feliz Natal,
  moma, Portugal

Marius Gedminas <mar...@gedmin.as> escreveu no dia segunda, 3/12/2018 à(s)
17:12:

> On Fri, Nov 30, 2018 at 09:56:12PM +0100, Радомир Хаџић via
> gtk-app-devel-list wrote:
> > I use poppler_page_find_text() to find text in PDF files. This returns
> > GList of pointers to PopplerRectangles. Then I use
> > poppler_page_render_selection() to mark the found text.
> >
> > What is wrong is that PopplerRectangles returned by
> > poppler_page_find_text() are incompatible with those that
> > poppler_page_render_selection() requests, which is why the wrong text
> > is selected.
> >
> > I have found that to make those two compatible, I have to do the
> > following to PopplerRectangles returned by poppler_page_find_text():
> > 1) SWAP(rectangle.x1, rectangle.x2);
> > 2) SWAP(rectangle.y1, rectangle.y2);
> > 3) rectangle.y1 = page_height - rectangle.y1;
> > 4) rectangle.y2 = page_height - rectangle.y2;
> > But this does not solve the problem because the marked text cycles
> > between right and wrong again while resizing the window.
>
> > is: https://pastebin.com/h3F56Yv7
>
> You're doing in-place coordinate conversions in your drawing code.
> Every expose event will change the coordinates event, which is why
> you're seeing the flip-flopping.
>
> Do the conversion only once, or use a local temporary PopplerRectangle
> variable and avoid in-place conversions.
>
> (I'm not familiar with poppler's APIs and cannot say if your conversion
> code is correct.)
>
> HTH,
> Marius Gedminas
> --
> Lutetium is the heaviest and hardest of the rare earth metals, and is used
> in
> the production of umlauts and other fraktur font features.
>         -- Charles Stross
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



-- 
Sent from my PC, laptop or phone with Ubuntu-Linux.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to