AddFontFromFile
IPDFDocument4 :: General document management :: Fonts

See Also Example
Collapse All

This method adds a font from a file using the specified character set and font style and returns a font identifier.

You can pass the path to any font file as a parameter (TTF, OTF or Type1).

Syntax

LONG AddFontFromFile (
BSTR filename,
VARIANT_BOOL bold,
VARIANT_BOOL italic,
VARIANT_BOOL underline,
VARIANT_BOOL strikeout
)
Parameters
filename
Name of the file containing the 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

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

Example

Adding a Font from a File

Delphi
[copy to clipboard]
// PDF object is supposed to be created
fnt := PDF.AddFontFromFile('path\to\font.ttf', false, false, true, false);
PDF.UseFont(fnt, 14);
PDF.ShowTextAt(20, 20, 'Here is the text. 0123456789.');
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
long fnt = PDF->AddFontFromFile("path\\to\\font.ttf", false, false, true, false);
PDF->UseFont(fnt, 14);
PDF->ShowTextAt(20, 20, "Here is the text. 0123456789.");
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
long fnt = PDF.AddFontFromFile(@"path\to\font.ttf", false, false, true, false);
PDF.UseFont(fnt, 14);
PDF.ShowTextAt(20, 20, "Here is the text. 0123456789.");
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
fnt = PDF.AddFontFromFile("path\to\font.ttf", false, false, true, false)
PDF.UseFont fnt, 14
PDF.ShowTextAt 20, 20, "Here is the text. 0123456789."
PDF.SaveToFile "test.pdf", true

See Also

Reference