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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Bug in PDF Object Coordiantes

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jeffp Posted - Aug 05 2026 : 15:20:22
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
7   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Aug 08 2026 : 19:13:00
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
jeffp Posted - Aug 08 2026 : 08:32:53
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
xequte Posted - Aug 08 2026 : 02:16:05
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
jeffp Posted - Aug 07 2026 : 21:10:32
Interesting. Must be PDFium because my other PDF components don't do this.

jp
xequte Posted - Aug 07 2026 : 21:07:20
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
jeffp Posted - Aug 07 2026 : 09:18:52
What about part [2] of my question above?

jp
xequte Posted - Aug 05 2026 : 18:03:38
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