AddFont
IPDFDocument4 :: General document management :: Fonts

See Also Example
Collapse All

This method adds a system font using the specified font face, font style, and character set and returns a font identifier.

Syntax

LONG AddFont (
BSTR fontFace,
VARIANT_BOOL bold,
VARIANT_BOOL italic,
VARIANT_BOOL underline,
VARIANT_BOOL strikeout,
FontCharset charset
)
Parameters
fontFace
Face name of a system font

bold
When true, sets the font style to bold

italic
When true, sets the font style to italic

underline
When true, sets the font style to underline

strikeout
When true, sets the font style to strikeout

charset
Character set of the font

Return value
Identifier of the added font to be used in the UseFont method.

Example

Adding a System Font

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
charSet := fcDefault;
font1 := PDF.AddFont('Arial', true, true, true, true, charset);
font2 := PDF.AddFont('Georgia', false, false, false, false, charset);
font3 := PDF.AddFont('Comic Sans MS', false, false, true, false, charset);
str := 'Here is the text. 0123456789.';
PDF.UseFont(font1, 14);
PDF.ShowTextAt(20, 20, str);
PDF.UseFont(font2, 14);
PDF.ShowTextAt(20, 40, str);
PDF.UseFont(font3, 14);
PDF.ShowTextAt(20, 60, str);
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
FontCharset charSet = fcDefault;
long font1 = PDF->AddFont("Arial", true, true, true, true, charset);
long font2 = PDF->AddFont("Georgia", false, false, false, false, charset);
long font3 = PDF->AddFont("Comic Sans MS", false, false, true, false, charset);
char* str = "Here is the text. 0123456789.";
PDF->UseFont(font1, 14);
PDF->ShowTextAt(20, 20, str);
PDF->UseFont(font2, 14);
PDF->ShowTextAt(20, 40, str);
PDF->UseFont(font3, 14);
PDF->ShowTextAt(20, 60, str);
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
FontCharset charSet = FontCharset.fcDefault;
long font1 = PDF.AddFont("Arial", true, true, true, true, charset);
long font2 = PDF.AddFont("Georgia", false, false, false, false, charset);
long font3 = PDF.AddFont("Comic Sans MS", false, false, true, false, charset);
string str = "Here is the text. 0123456789.";
PDF.UseFont(font1, 14);
PDF.ShowTextAt(20, 20, str);
PDF.UseFont(font2, 14);
PDF.ShowTextAt(20, 40, str);
PDF.UseFont(font3, 14);
PDF.ShowTextAt(20, 60, str);
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
charSet = 0 'FontCharset.fcDefault
font1 = PDF.AddFont("Arial", true, true, true, true, charset)
font2 = PDF.AddFont("Georgia", false, false, false, false, charset)
font3 = PDF.AddFont("Comic Sans MS", false, false, true, false, charset)
str = "Here is the text. 0123456789."
PDF.UseFont font1, 14
PDF.ShowTextAt 20, 20, str
PDF.UseFont font2, 14
PDF.ShowTextAt 20, 40, str
PDF.UseFont font3, 14
PDF.ShowTextAt 20, 60, str
PDF.SaveToFile "test.pdf", true

See Also

Reference