Localize a PDF Form
Localization capabilities enable you to adapt a PDF form to the local language of the viewer. This demo shows how to translate PDF form content to any language. English, German, Italian, French, and Spanish are available as examples. Select one of these languages from the Form language drop-down menu and click the Save as PDF button to generate a localized PDF document.
To localize a PDF form, open its JSON schema and translate visible texts in it (titles, descriptions, choice texts, placeholders). Typically, properties that specify visible texts accept string values. Instead, specify the properties with objects. Each object field should indicate a locale and the field value—a translation for this locale. Refer to the survey JSON schema (the json.js
file) for a code example.
To generate a localized PDF form, assign a required locale code to the locale
property of the SurveyPDF
instance. For example, the following code applies the French locale:
const surveyPdf = new SurveyPDF.SurveyPDF(surveyJson, pdfDocOptions);
surveyPdf.locale = "fr";
// In modular applications:
import { SurveyPDF } from "survey-pdf";
const surveyPdf = new SurveyPDF(surveyJson, pdfDocOptions);
surveyPdf.locale = "fr";
Alternatively, you can specify the locale
property within the survey JSON schema that you pass to the SurveyPDF
instance:
const surveyJson = {
// ...
"locale": "fr"
}
const pdfDocOptions = { /* ... */ };
const surveyPdf = new SurveyPDF(surveyJson, pdfDocOptions);
Default PDF fonts support only Latin-based languages. Other languages require custom fonts.