CompressFonts

Fonts, Document properties

Description

Sets the default compression flag applied to TrueType, OpenType, Packaged, and Type 1 font programs added to the document after this call. When enabled, the font stream is wrapped in a /FlateDecode filter; when disabled, the font stream is stored uncompressed.

Syntax

Delphi

function TPDFlib.CompressFonts(Compress: Integer): Integer;

ActiveX

Function PDFlib::CompressFonts(Compress As Long) As Long

DLL

int DLCompressFonts(int InstanceID, int Compress);

Parameters

Compress0 — do not compress font streams.
1 — compress font streams with Flate.

Return values

0The Compress parameter was out of range.
1The font-compression setting was updated.

Remarks

This setting only affects fonts added after the call — fonts already embedded in the document keep their original encoding. The default is to compress (matching PDF reader expectations and the smallest output). Disable compression only when debugging a font extraction issue or when integrating with a downstream pipeline that rejects flate-encoded font streams.

Font subsetting (AddTrueTypeSubsettedFont) and font compression are independent: subsetting reduces the number of glyphs included; compression reduces the size of whatever glyph data is included.

Example

// Default behaviour: every font added is flate-compressed
PDF.CompressFonts(1);
PDF.AddTrueTypeFontFromFile('C:\Windows\Fonts\arial.ttf');
PDF.AddTrueTypeFontFromFile('C:\Windows\Fonts\arialbd.ttf');

// One uncompressed font for downstream tooling that cannot decode flate fonts
PDF.CompressFonts(0);
PDF.AddType1Font('Helvetica');

See also

CompressContent, CompressImages, AddTrueTypeFont, AddTrueTypeSubsettedFont, AddOpenTypeFontFromFile