pdfrx_web
    Preparing search index...

    Function prepareFreeTextAppearance

    • Builds a language-aware, wrapped FreeText appearance without requiring a PdfDocument instance.

      Most callers that already have an open document should use PdfDocument.prepareFreeTextAppearance. This standalone form is useful for preparing specs in an adapter or service layer. It performs the same operation and mutates spec.fontFace, spec.appearanceLines, and spec.appearanceRuns.

      options.language is a hint, not a required field. Kana and Hangul identify Japanese and Korean directly; in browsers, navigator.languages and navigator.language are used automatically. Pass an explicit language for ambiguous Han-only content, to override the browser preference, or in a server runtime where no browser locale exists. A server commonly gets it from document metadata, the authenticated user's locale, or a parsed Accept-Language preference.

      Parameters

      Returns Promise<void>

      The resulting Promise.

      const spec: PdfAnnotationSpec = {
      subtype: 'freeText',
      rect: { left: 40, bottom: 700, right: 260, top: 750 },
      contents: '繁體中文 👋',
      };

      // Explicit because this Han-only text is prepared outside a browser.
      await prepareFreeTextAppearance(spec, { language: 'zh-Hant' });
      await page.addAnnotation(spec);

      The defaults use deterministic approximate text measurement outside the browser, PDFium's default font when no resolveFont service is supplied, and native-browser or downloadable Noto PNG emoji rendering. Pass options.services when the runtime requires exact measurement, registered script fonts, offline emoji assets, or a custom renderer.

      For provider and deployment examples, read the Text, language, and emoji appearance guide. To reuse the analyzed runs as ordinary PDF page text and images rather than an annotation, see the practical multilingual Unicode page-content pipeline.