fdo#49431 PDF Import: Improve line and space detection algorithm

Change-Id: Ia0d53e90f49fa020e0738e295a4584254e2b474e
Reviewed-on: https://gerrit.libreoffice.org/8800
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>