not able to get selection of pdf document
-
When using
getAllTextI get a validQPdfSelection.pdf_view: QPdfView = main_window.ui.pdfView document: QPdfDocument = pdf_view.document() current_page: int = pdf_view.pageNavigator().currentPage() selection: QPdfSelection = document.getAllText(current_page) print(selection.isValid()) # True print(selection.boundingRectangle()) # PySide6.QtCore.QRectF(73.000000, 118.000000, 450.000000, 682.000000) print(selection.text()) # some text ...But when trying to use
getSelection(even with theQPointFs of the boundingRectagle above) I get an invalid selection with aQRectFwith all its values set to 0.What do I'm missing?
top_left: QPointF = selection.boundingRectangle().topLeft() bottom_right: QPointF = selection.boundingRectangle().bottomRight() selection: QPdfSelection = document.getSelection(current_page, top_left, bottom_right) print(selection.isValid(), selection.boundingRectangle()) print(selection.isValid()) # False print(selection.boundingRectangle()) # False PySide6.QtCore.QRectF(0.000000, 0.000000, 0.000000, 0.000000) -
The QPdfView widget text selection functionality is currently not completely implemented or has bugs, see for example https://bugreports.qt.io/browse/QTBUG-131443 .