Details
-
Bug
-
Resolution: Cannot Reproduce
-
Not Evaluated
-
None
-
6.7.3
-
None
-
Windows
Description
I'm unable to retrieve any text from PDF files using the getSelection() method from QPdfDocument. The QPdfSelection returned is always empty for me (that is: It has an empty text() and empty boundingRectangle()), no matter what I chose as start and end point. Am I doing something wrong? Other methods like getAllText() or getSelectionAtIndex() work fine, so I guess it's not the fault of the pdf files I've tried or a general mistake in creating the QPdfDocument...
I've encounterd this using python and PySide6. My bug report there was closed with the comment that the underlying issue is in the Qt library and not in the python bindings. I'm not a C++ dev, so I'll not provide a minimal example in C++. However, here's some python example.
from PySide6.QtCore import QPointF
from PySide6.QtPdf import QPdfDocument
doc = QPdfDocument(None)
doc.load(r"path-to-some.pdf")
page = 10
print("############### get all ###############")
all = doc.getAllText(page)
print(all.text()) # this works just fine
print(all.boundingRectangle())
print("############### getSelection ###############")
selection = doc.getSelection(page, QPointF(11, 49), QPointF(537, 705))
print(selection.text()) # this is always empty
print(selection)