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 - TQuickPDF0813.DrawText
  FAQ FAQ  Forum Search   Register Register  Login Login

TQuickPDF0813.DrawText

 Post Reply Post Reply
Author
Message
micha View Drop Down
Beginner
Beginner
Avatar

Joined: 18 Dec 11
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote micha Quote  Post ReplyReply Direct Link To This Post Topic: TQuickPDF0813.DrawText
    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
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 Dec 11 at 8:15PM
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

Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 19 Dec 11 at 10:04PM

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");


Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 20 Dec 11 at 2:31PM
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
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. AboutContactBlogSupportOnline Store