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!
![]() |
TQuickPDF0813.DrawText |
Post Reply ![]() |
Author | |
micha ![]() Beginner ![]() ![]() Joined: 18 Dec 11 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() Posted: 18 Dec 11 at 3:48PM |
hello,
im using delphi 7 when using the DrawText function the text is drawn over the y position does anyone know how to draw the text under the y position ? thanks micha
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
Hi Micha!
Perhaps it's better to post the used code-snippet. If you're asking about orientation you should use SetOrigin. Please read here: http://www.quickpdflibrary.com/help/quickpdf/SetOrigin.php Cheers and welcome here, Ingo |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
Text is a PDF file is drawn on the baseline. If you want to draw text from the top of the font cell or the top of the characters then you would use either GetTextHeight or GetTextAscent QP.SetOrigin(1); QP.DrawLine(30, 30, 400, 30); QP.DrawText(30, 30 - QP.GetTextHeight(), "Hello World using text height"); QP.DrawLine(30, 60, 400, 60); QP.DrawText(30, 60 - QP.GetTextAscent(), "Hello World using ascent"); |
|
![]() |
|
edvoigt ![]() Senior Member ![]() ![]() Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
![]() ![]() ![]() ![]() ![]() |
Hi Micha,
Here an overview on the properties around Textheight: ![]() To have text of different size readable in a line, all is drawn on the baseline. It's so in Word, in PDF and it makes sense. But inside a technical drawing, you may want a spezial alignment and so you need some calculations around size. You may get all information by GetTextAscent, GetTextDescent, GetTextBound(...), GetTextHeight, GetTextWidth. But keep in mind, that SetTextSize works ever with points. Here a codesnippet for the above painting in D7: var QP: TQuickPDF; s: string; x, y, tf, ta, td, tt, th, ts, tw: double; begin QP := TQuickPDF.Create; QP.UnlockKey(... QP.SetMeasurementUnits(1); // millimeters QP.SetPageDimensions(210, 297); // DIN A4 QP.SetOrigin(0); // bottomleft x := 20; y := 20; s := 'Ä happy ÉgʦÇ'; // to have real things on all lines QP.AddStandardFont(11); // as you like tf := 24*72/25.4; // 24 mm as points QP.SetTextSize(tf); ta := QP.GetTextAscent; // get all we can need td := QP.GetTextDescent; tt := QP.GetTextBound(2); th := QP.GetTextHeight; ts := QP.GetTextSize*25.4/72; // points to mm tw := QP.GetTextWidth(s); QP.DrawText(x, y, s); tf := 4*72/25.4; // 4 mm as points QP.SetTextSize(tf); QP.SetLineWidth(0.1); QP.SetLineColor(1, 0, 0); // Baseline QP.DrawLine(x-10, y, x+tw+5, y); QP.DrawText(x+tw+6, y, 'Baseline'); QP.SetLineColor(0, 1, 0); // Ascent QP.DrawLine(x-10, y+ta, x+tw+5, y+ta); QP.DrawText(x+tw+6, y+ta, 'Ascent'); QP.SetLineColor(0, 0, 1); // Descent = abs(Bottom) QP.DrawLine(x-10, y+td, x+tw+5, y+td); QP.DrawText(x+tw+6, y+td, 'Descent'); QP.SetLineColor(0, 0.5, 0.5); // Top QP.DrawLine(x-10, y+tt, x+tw+5, y+tt); QP.DrawText(x+tw+6, y+tt, 'Top'); QP.AddStandardFont(4); QP.SetTextSize(tf); QP.DrawText(x, y-10, Format('Ascent=%.2f Descent=%.2f Top=%.2f Textsize=%.2f Delta=%.2f',[ta, td, tt, ts, tt-ta])); Cheers, Werner Edited by edvoigt - 05 Nov 13 at 11:35AM |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store