Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-129615

QPdfDocuments getSelection(...) always returning empty QPdfSelection

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • 6.7.3
    • PDF
    • None
    • Windows
    • 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)

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            srutledg Shawn Rutledge
            patschke Patrick Mischke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes