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 - DrawHTMLTextBox and text height
  FAQ FAQ  Forum Search   Register Register  Login Login

DrawHTMLTextBox and text height

 Post Reply Post Reply
Author
Message
Jan View Drop Down
Beginner
Beginner


Joined: 24 May 10
Location: Czech Republic
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jan Quote  Post ReplyReply Direct Link To This Post Topic: DrawHTMLTextBox and text height
    Posted: 14 Mar 12 at 9:10AM

Hi, I have a file in XSL-FO format and I want convert it into PDF.
And I have problem with difference of text height calculated at drawing/printing via C#
and at insert in PDF file.
In both environment I use 'pt' units.

Example XSL-FO:
<fo:block line-height="14.399999999999999pt" top="11.0pt" left="41.0pt" height="15.0pt" width="434.0pt" font-family="Times New Roman" font-size="12.0pt">Test text, test text, test text .... </fo:block>

Inserting into PDF:

pdf.SetMeasurementUnits(0);     // 0 = 1/72 inch "per unit"
pdf.SetOrigin(1);

int idFont = pdf.AddTrueTypeFont("Times New Roman", 0);
pdf.SetHTMLNormalFont("Times New Roman", idFont);

string textHTML = "<p><font size=\"12pt\">Test text, test text, test text .... </font></p>";
pdf.DrawHTMLTextBox(10, 10, 434, 15, textHTML);

int _height = pdf.GetHTMLTextHeight(434, textHTML);

Height of text at C# drawing/printing is lower than 15 pt,
at inserting into PDF (variable _height) is higher than 15 pt (15,768 exactly).

Difference in this case is about 6%.
Solution may be reduce font size at PDF creating by 6% and round down to integer,
but I do not consider this the best solution.

Can you help me?
Thanks 

Back to Top
Jan View Drop Down
Beginner
Beginner


Joined: 24 May 10
Location: Czech Republic
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jan Quote  Post ReplyReply Direct Link To This Post Posted: 19 Mar 12 at 12:26PM
I found, that value returned by GetHTMLTextHeight depends on value spacing parameter HTML text. Same single-line HTML text, same font, different spacing and different text height:
 
 
int iFontID = qp.AddTrueTypeFont("Times New Roman", 0);
qp.SetHTMLNormalFont("Times New Roman", iFontID);
string  textHTML = "<p spacing=\"-2pt\" align=\"left\"><font size=\"11pt\">Test text test text</font></p>";
qp.DrawHTMLTextBox(10, 350, 300, 200, textHTML);
double height = qp.GetHTMLTextHeight(300, textHTML);
textHTML = "<p spacing=\"2pt\" align=\"left\"><font size=\"11pt\">Test text test text</font></p>";
qp.DrawHTMLTextBox(10, 400, 300, 200, textHTML);
height = qp.GetHTMLTextHeight(300, textHTML);
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