Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Word’s bounds
  FAQ FAQ  Forum Search   Register Register  Login Login

Word’s bounds

 Post Reply Post Reply
Author
Message
Dmitry View Drop Down
Team Player
Team Player


Joined: 21 Sep 06
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmitry Quote  Post ReplyReply Direct Link To This Post Topic: Word’s bounds
    Posted: 17 Nov 06 at 5:28AM
Hi!
Please tell me how to define bounds(in pixels) of exact word.

For example.
I could get the bounds of exact line using function GetPageText(4):

"PDMFNG+CMR10", {Font}
#000000, {Color}
10.90, {Font Size}
72.0009,628.7132,512.1819,628.7132,512.1819,639.6223,72.0009,639.6223, {Bounds}
"Although there is a long history of empirical research into the deformation behaviour of" {Text line}

But how can I define the bounds of word 'history' for example?

Edited by Dmitry
Back to Top
ukobsa View Drop Down
Senior Member
Senior Member


Joined: 29 May 06
Location: Germany
Status: Offline
Points: 115
Post Options Post Options   Thanks (0) Thanks(0)   Quote ukobsa Quote  Post ReplyReply Direct Link To This Post Posted: 17 Nov 06 at 10:22AM
Hi Dmitry,

As far as I know: If GetPageText cannot split the text to single words then you can't. Maybe you can make the pdf available so that someone can debug it in source to see, why it can't splitt into single words and if there is a solution.

best regards,
Uli
Back to Top
swb1 View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert
Avatar

Joined: 05 Dec 05
Location: United States
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote swb1 Quote  Post ReplyReply Direct Link To This Post Posted: 17 Nov 06 at 10:43AM

The PDF Specification allows for a virtually unlimited number of ways in which text can be laid out in a document all the way from one character at time to a paragraph wrapped down an entire page. This means that is nearly impossible to know for certain where a word is or that it even is a word using text extraction methods.

 

The easiest solution to your problem lies in controlling how the document is created. If you have no control over that you are probably out of luck.

Back to Top
Dmitry View Drop Down
Team Player
Team Player


Joined: 21 Sep 06
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmitry Quote  Post ReplyReply Direct Link To This Post Posted: 18 Nov 06 at 12:13AM
Thanks to all. But what will say Ingo?
Back to Top
Dmitry View Drop Down
Team Player
Team Player


Joined: 21 Sep 06
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmitry Quote  Post ReplyReply Direct Link To This Post Posted: 18 Nov 06 at 4:32AM
BTW, I just develope the next algorithm


ASentence := Text; //Sentence
AWord := ErrorWord; // The word that needs to be underlined
WPos := Pos(AWord, ASentence);
BefWord := Copy(ASentence, 1, WPos-1);
AfWord := Copy(ASentence, 1, WPos+Length(AWord));

BM:= TBitmap.Create; // Creating bitmap
BM.Canvas.Font.Name:=FontName;
BM.Canvas.Font.Size:=FontSize;

WordBeginPos:=(BM.Canvas.TextWidth(BefWord));
WordEndPos:=(BM.Canvas.TextWidth(AfWord));
Afword:=IntToStr(WordEndPos);

LTop := LineBounds.LeftTop.Y;
LLeft := LineBounds.LeftTop.X+4;

Qp.SetLineColor(1,0,0); // red
Qp.DrawLine(LLeft+WordBeginPos,LTop,LLeft+WordEndPos,LTop);


But this method defines the wrong begin and end positions of the AWord.

Edited by Dmitry
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 18 Nov 06 at 2:19PM
Hi Dimitry!

I don't know much enough about pdf ;-)
My thoughts are: You have the beginning point (pixel) of the string and you have the ending point (pixel) of the string... and you can get the length of the string... i think with a bit maths it should be possible to get the position of a special word you're searching for...?

Best regards,
Ingo


Edited by Ingo
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store