Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-3794

Problem in TextPosition implementation

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.6
    • Fix Version/s: 2.0.7
    • Component/s: Text extraction
    • Labels:

      Description

      In 2.0.3 there wasn't hashCode implemented in TextPosition, and for me that was fine. Same instance, same hashCode.

      In 2.0.6 the hashCode is now checking the fields values, which is reasonable. But, the hashCode in the same instance can have different results.

      The problem is in the `direction` field, which is -1.0 and initialised only when getDir is called the first time.

      For now as workaround, anytime (or just the first time) I need the textPosition's hashCode I call getDir before that.

      Quick example:

      Object getObjectFromTextPos(TextPosition textPos) {
          textPos.getDir();
          return someHashMap.get(textPos);
      }
      

      I don't know the reason of the late assignment to direction, but if that is necessary, I would say that the hashCode should call getDir() instead of using the field.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tilman Tilman Hausherr
                Reporter:
                miromannino Miro Mannino
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: