Skip to main content

SetLanguage

Specifies the languages which will be used to check spelling and grammar (if requested) when processing the contents of the text run.

Inherited from ApiTextPr.SetLanguage.

Syntax​

expression.SetLanguage(langId);

expression - A variable that represents an ApiRun class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
langIdRequiredstring | nullThe possible value for this parameter is a language identifier as defined by RFC 4646/BCP 47. Example: "en-CA". Pass null to remove the language.

Returns​

ApiTextPr

Example​

Specify the language for text in a PDF.

// How do I set text language for spell checking in a PDF?

// Configure language detection for text content in a PDF.

const doc = Api.GetDocument();
const page = doc.GetPage(0);

const fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("flowChartMagneticTape", 150 * 36000, 65 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);

const docContent = shape.GetContent();
const paragraph = docContent.GetElement(0);
const run = Api.CreateRun();
run.AddText("This is a text run with the text language set to English (Canada).");
paragraph.AddElement(run);
run.SetLanguage("en-CA");
page.AddObject(shape);