PDF Creator Pilot documentation |
Download CHM version of this manual. |
|
![]() ![]() Collapse AllThis method adds a TTF font from a file and returns the font name.
|
| BSTR AddTTFFontFromFile ( BSTR fontFile, TxFontCharset charset ) |
Parameters
fontFile
Path to font file
charset
Character set of the loaded font
Return value
This method returns the font name. If the font can't be added (when you try to add a commercial font, for example), it returns an empty string.
Remarks
This method can load TTF, OTF, and Type1 fonts.
If you don't know the font's type, use AddTTFFontFromFile2 instead. This method will determine the font's type and try to load it.
The return value is the name of the font added and can be used in PDFPAGE_SetActiveFont.
Equivalents in new interface: IPDFDocument4::AddFont, IPDFDocument4::AddFontFromFile, IPDFDocument4::AddBuiltInFont.
Example
Adding a Font from a File
Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.BeginDoc;
fontName := PDF.AddTTFFontFromFile('c:\path\to\font.ttf', charsetDEFAULT_CHARSET);
PDF.PDFPAGE_SetActiveFont(fontName, False, False, False, False, 14, charsetDEFAULT_CHARSET);
PDF.PDFPAGE_TextOut(100, 100, 0.0, '0123456789');
PDF.EndDoc;
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->BeginDoc();
CString fontName = PDF.AddTTFFontFromFile("c:\\path\\to\\font.ttf", charsetDEFAULT_CHARSET);
PDF.PDFPAGE_SetActiveFont(fontName, FALSE, FALSE, FALSE, FALSE, 14.0, charsetDEFAULT_CHARSET);
PDF.PDFPAGE_TextOut(100, 100, 0.0, "0123456789");
PDF.EndDoc();
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF->BeginDoc();
string fontName = PDF.AddTTFFontFromFile("c:\\path\\to\\font.ttf", TxFontCharset.charsetDEFAULT_CHARSET);
PDF.PDFPAGE_SetActiveFont(fontName, false, false, false, false, 14.0, TxFontCharset.charsetDEFAULT_CHARSET);
PDF.PDFPAGE_TextOut(100, 100, 0.0, "0123456789");
PDF.EndDoc();
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.BeginDoc
fontName = PDF.AddTTFFontFromFile("c:\path\to\font.ttf", charsetDEFAULT_CHARSET)
PDF.PDFPAGE_SetActiveFont fontName, False, False, False, False, 14, charsetDEFAULT_CHARSET
PDF.PDFPAGE_TextOut 100, 100, 0, "0123456789"
PDF.EndDoc
See Also
Reference


