Skip to main content

SetSpacingLine

Sets the paragraph line spacing. If the value of the sLineRule parameter is either "atLeast" or "exact", then the value of nLine will be interpreted as twentieths of a point. If the value of the sLineRule parameter is "auto", then the value of the nLine parameter will be interpreted as 240ths of a line.

Syntax

expression.SetSpacingLine(nLine, sLineRule);

expression - A variable that represents a ApiParaPr class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nLineRequiredtwips | line240The line spacing value measured either in twentieths of a point (1/1440 of an inch) or in 240ths of a line.
sLineRuleRequired"auto" | "atLeast" | "exact"The rule that determines the measuring units of the line spacing.

Returns

boolean

Example

Adjust the spacing between lines of text in a PDF.

// How do I change the line spacing in a PDF?

// Modify the distance between text lines in a PDF.

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

const gs1 = Api.CreateGradientStop(Api.RGB(255, 213, 191), 0);
const gs2 = Api.CreateGradientStop(Api.RGB(255, 111, 61), 100000);
const fill = Api.CreateRadialGradientFill([gs1, gs2]);
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 paraPr = paragraph.GetParaPr();
paraPr.SetSpacingLine(3 * 240, "auto");
paragraph.AddText("Paragraph 1. Spacing: 3 times of a common paragraph line spacing.");
paragraph.AddLineBreak();
paragraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
paragraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
paragraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
page.AddObject(shape);