Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

Problems setting text size when using DrawText

Question

I am using the DrawText function. I need the font size to be smaller but what I'm doing is not working:

Call PDFLibrary.SetPageSize("Letter Landscape") 
Call PDFLibrary.AddStandardFont(0) 
PDFLibrary.SelectFont (1) 
PDFLibrary.SetTextSize (10) 

Please advise!

Answer

I've included some C# sample code below that will probably help you understand better how the DrawText, AddStandardFont, SelectFont and SetTextSize functions work together. In this example we're going to draw a string of text for each of the standard fonts and with each string of text we draw, we're going to increase the font size. Like this:

QP.SetPageSize("Letter Landscape");

int FontSize = 10;
int XPos = 10;
int YPos = 600;

for (int i = 0; i <= 13; i++)
{
QP.AddStandardFont(i);
QP.SelectFont(1);
string FontName = QP.FontName();

QP.SetTextSize(FontSize);
QP.DrawText(XPos, YPos, FontName + " Font With Size " + Convert.ToString(FontSize));
FontSize += 2;
YPos -= 40;
}
QP.SaveToFile("C:\\MyPdf.pdf");

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum