ConvertTextToPaths

Content stream editing, Fonts

Description

Rewrites text-showing instructions on the selected pages as vector Form XObject invocations while retaining glyph placement, text spacing, writing mode, transformations, fill colour, stroke colour, and stroke settings

TrueType and Type 1 glyph outlines are extracted once and reused for repeated glyphs. Type 3 CharProcs are converted into ordinary Form XObjects with their font matrix, bounding box, and resource scope preserved. The original text-showing and font-selection instructions are removed

The conversion is transactional. Every selected content layer and requested nested Form is parsed and converted in memory before any PDF object is changed. Unsupported fonts, text clipping rendering modes 4 through 7, malformed text state, and ambiguous shared Form resource scopes fail without partially rewriting the document

Converted text is no longer searchable, selectable, or extractable as text. It remains scalable vector content for rendering and printing

Syntax

Delphi

Function TPDFlib.ConvertTextToPaths(Const PageRange: WideString= ''; Options: Integer= PDF_TEXT_PATH_DEFAULT): Integer;

ActiveX

Function PDFlib::ConvertTextToPaths(PageRange As String, Options As Long) As Long

DLL

int DLConvertTextToPaths(int InstanceID, const wchar_t *PageRange, int Options);
int DLConvertTextToPathsA(int InstanceID, const char *PageRange, int Options);

Parameters

PageRangePage range expression using one-based page numbers. An empty value selects every page
OptionsBitwise combination of PDF_TEXT_PATH_RECURSE_FORMS to convert nested Form XObjects and PDF_TEXT_PATH_PURGE_FONTS to remove source font resources that become unused. PDF_TEXT_PATH_DEFAULT enables both options

Return values

1 or greaterNumber of text-showing instructions converted
0No eligible text was found, the range or options were invalid, or conversion failed. Inspect LastErrorCode to distinguish errors

Error codes

506The source font cannot provide a supported vector glyph program
507A text clipping rendering mode requires a clipping path that cannot be represented by an independent glyph Form
508The text program, font state, or recursive Form resource scope is malformed or ambiguous

Example

Converted := PDF.ConvertTextToPaths('1-3,5', PDF_TEXT_PATH_DEFAULT);
If (Converted= 0)and (PDF.LastErrorCode<> 0) Then
  raise Exception.Create(PDF.LastError);