ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Bug in PDF Object Coordiantes
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jeffp

USA
74 Posts

Posted - Aug 05 2026 :  15:20:22  Show Profile  Reply
I am trying to get the PDF Object coordinates from each word in a text based PDF document. See attached example.

However, I am running into these issues:
[1] The Object Height and Width are always returning a value of 1 (seems to be a bug here. Height and Width should have values)

[2] The text objects on the sample PDF should be one word per text object. You will see that the first word "Banna" is presented as two text objects: "B" and "anna". AND the last line with the text "Banna and Apple" should be 3 separate text objects, NOT one with three words.



    FViewer.PdfViewer.PageIndex := APageNum - 1;
    ACount := FViewer.PdfViewer.Objects.Count;
    for i := 0 to ACount - 1 do
    begin
      AObj := FViewer.PdfViewer.Objects[i];
      if (AObj.ObjectType = ptText) then
      begin
        msgbox(Format( 'Info: %s, %0.2f, %0.2f, %0.2f, %0.2f',
          [ AObj.Text, AObj.X, AObj.Y, AObj.Width, AObj.Height ]));
        msgbox(Format( 'Matrix: %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f',
          [ AObj.matrix.a, AObj.matrix.b, AObj.matrix.c, AObj.matrix.d, AObj.matrix.e, AObj.matrix.f ]));
      end;
    end;


attach/jeffp/202685152012_TEST.pdf

jp

xequte

39499 Posts

Posted - Aug 05 2026 :  18:03:38  Show Profile  Reply
Hi Jeff

That information is returned by PDFium. A width/height of 1 means that it is auto-calculated.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jeffp

USA
74 Posts

Posted - Aug 07 2026 :  09:18:52  Show Profile  Reply
What about part [2] of my question above?

jp
Go to Top of Page

xequte

39499 Posts

Posted - Aug 07 2026 :  21:07:20  Show Profile  Reply
Hi Jeff

Yes, I'm not sure why the text has been split that way. Some quirk in the way Microsoft Word exports to PDF, I guess.

We're just returning the information as PDFium reads it from the document.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jeffp

USA
74 Posts

Posted - Aug 07 2026 :  21:10:32  Show Profile  Reply
Interesting. Must be PDFium because my other PDF components don't do this.

jp
Go to Top of Page

xequte

39499 Posts

Posted - Aug 08 2026 :  02:16:05  Show Profile  Reply
Yes, PDFium is definitely doing something weird there, because analyzing the PDF content shows them as single blocks:

Object 1:
"Banna"
Font: F1
X: 72.024
Y: 708.7

Object 2:
"Apple"
Font: F1
X: 79.224
Y: 708.7

Object 5:
"Banna"
Font: F1
X: 72.024
Y: 658.78

Object 8:
"Banna and Apple"
Font: F1
X: 72.024
Y: 608.86

(Excluding blank text blocks)

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jeffp

USA
74 Posts

Posted - Aug 08 2026 :  08:32:53  Show Profile  Reply
I assume since it's PDFium you can't do anything about this? What did you use to analyze the content? Does ImageEn have another way of getting this information from a PDF? You do have the "native" PDF engine. Does it give text coordinates?

jp
Go to Top of Page

xequte

39499 Posts

Posted - Aug 08 2026 :  19:13:00  Show Profile  Reply
You could generate your own text object list by parsing the ImageEn list and joining rects that have similar top/bottom values and are aligned closely together (In this case "B" is at 73,709,79,717, and "anna" is at 80,709,104,715, so top is the same, bottom is within 2 pixels and join within 1 pixel). Of course, there are risks of false positives. We implement this ourselves, because then we would need to manage the list rather than using PDFium as the authority.

You can use a PDF parser, but I just got ChatGPT to analyze it.

There is not a native PDF parser in ImageEn, just a PDF generator.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: