Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word wrapping #18

Closed
tengotengo opened this issue Feb 13, 2014 · 5 comments
Closed

Word wrapping #18

tengotengo opened this issue Feb 13, 2014 · 5 comments

Comments

@tengotengo
Copy link

{
"x": 7.9914062500000025,
"y": 3.984375000000001,
"w": 1292.917,
"clr": 0,
"A": "left",
"R": [
{
"T": "SECTION%3A%20CON",
"S": -1,
"TS": [3, 182, 0, 0]
}
]
},
{
"x": 19.10241171875,
"y": 3.984375000000001,
"w": 984.6790000000001,
"clr": 0,
"A": "left",
"R": [
{
"T": "TACT%20LENS",
"S": -1,
"TS": [3, 182, 0, 0]
}
]
},

This was the "SECTION: CONTACT LENS" string in reference PDF.

@modesty
Copy link
Owner

modesty commented Mar 30, 2014

This problem is a direct reflection of PDF text data stream structure: the string is in 2 text blocks in PDF, although it "appears" as one visually. Currently, I don't have enough time to work on an "auto word merge" or "auto word concatenation" during parsing, if anybody wants to take it on, a pull request is welcomed.

@RST-J
Copy link
Contributor

RST-J commented Apr 23, 2014

Looking at the JSON above, shouldn't attribute w refer to the width of text and if so, x + w for the first text be less or equal to x of the second? If so, they appear to be in different units.

@modesty
Copy link
Owner

modesty commented Apr 23, 2014

Short answer is no. Because there might be kernings or spacings between them. But you are right about the unit, w should be converted by lib/pdfunit. Because the w value is not always accurate so it's not used in client renderer, I may forget to process it. I'll take a look at it when I get some time.

@modesty
Copy link
Owner

modesty commented Mar 5, 2016

fixed in v1.0.7

@modesty modesty closed this as completed Mar 5, 2016
@matewka
Copy link

matewka commented Mar 11, 2018

I'm still experiencing the unit issue on v1.1.7.
In my case the original text says:

"4)narzędzia i urządzenia, których używanie może zagrażać życiu lub zdrowiu:"

while the JSON output is:

{
  "x": 4.183,
  "y": 4.811,
  "w": 21.323999999999998,
  "sw": 0.32553125,
  "clr": 0,
  "A": "left",
  "R": [
     {
       "T": "4)na",
       "S": -1,
       "TS": [
         0,
         15,
         0,
         0
       ]
     }
   ]
 },
{
  "x": 6.486,
  "y": 4.811,
  "w": 354.54,
  "sw": 0.32553125,
  "clr": 0,
  "A": "left",
  "R": [
    {
      "T": "rz%C4%99dzia%20i%20urz%C4%85dzenia%2C%20kt%C3%B3rych%20u%C5%BCywanie%20mo%C5%BCe%20zagra%C5%BCa%C4%87%20%C5%BCyciu%20lub%20zdrowiu%3A",
      "S": -1,
      "TS": [
        0,
        15,
        0,
        0
      ]
    }
  ]
}

It doesn't seem to add up.
The text from the first object is a part of the first word from the second object (don't mind the "4)" - let's just treat it as one word), so x + w from the first object should be somewhere between x and x + sw from the second object, right?

Am I doing something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants