API referenceFonts

pdfSaveFontToFile

Write the currently active font's raw font-program bytes to a

CategoryFont export
Exported namespdfSaveFontToFileA, pdfSaveFontToFileW, pdfSaveFontToFile
Noteoperates on the current font only, and saves the whole original file, not a subset (see Remarks)

Purpose — Write the currently active font's raw font-program bytes to a file.

Declarations

C
int32_t __stdcall pdfSaveFontToFile(PPDF IPDF, const char* FileName);
int32_t __stdcall pdfSaveFontToFileA(PPDF IPDF, const char* FileName);
int32_t __stdcall pdfSaveFontToFileW(PPDF IPDF, const wchar_t* FileName);
Delphi
function pdfSaveFontToFileA(const IPDF: PPDF; FileName: PAnsiChar): Integer; stdcall; external 'LumasPdf.dll';
function pdfSaveFontToFileW(const IPDF: PPDF; FileName: PWideChar): Integer; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
FileNamestringOutput path.

Return value1 on success; 0 if no font is currently active, the active font isn't a TrueType font (standard-14, Type 1, and CID-predefined fonts have no extractable byte buffer through this call and always fail), or the file write fails.

**Remarks — two things this call does *not* do. (1) There is no font handle parameter — it always operates on whatever font pdfChangeFont/ pdfSetFont last selected as current; switch to the target font first. (2) It writes the complete, original TrueType font file bytes exactly as loaded** — not a subset reflecting only the glyphs actually used in the document, despite this chapter's subsetting-adjacent naming context. For subsetting concerns, see pdfUpdateTrueTypeSubsettedFont, which tracks *which glyphs* are used but does not itself produce a subsetted file via this call.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfSaveFontToFileW(IntPtr IPDF, IntPtr FileName);
public static extern int pdfSaveFontToFile(IntPtr IPDF, IntPtr FileName);
public static extern int pdfSaveFontToFileA(IntPtr IPDF, IntPtr FileName);
Area
Fonts
Category

Core

Exported names

pdfSaveFontToFileW pdfSaveFontToFile pdfSaveFontToFileA

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.