SetJc

function SetJc(sJc: left | right | both | center = null): void

Description

Sets the paragraph contents justification.

Parameters

sJcleft | right | both | centerdefault: null

The justification type that will be applied to the paragraph contents.

Returns

void

Try It

var oDocument = Api.GetDocument();
var oMyStyleLeft = oDocument.CreateStyle("My style with left text alignment");
var oParaPr = oMyStyleLeft.GetParaPr();
oParaPr.SetJc("left");
var oMyStyleRight = oDocument.CreateStyle("My style with right text alignment");
oParaPr = oMyStyleRight.GetParaPr();
oParaPr.SetJc("right");
var oMyStyleCenter = oDocument.CreateStyle("My style with center text alignment");
oParaPr = oMyStyleCenter.GetParaPr();
oParaPr.SetJc("center");
var oMyStyleBoth = oDocument.CreateStyle("My style with justify text alignment");
oParaPr = oMyStyleBoth.GetParaPr();
oParaPr.SetJc("both");
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is a paragraph with the text in it aligned by the left side. ");
oParagraph.AddText("The justification is specified in the paragraph style. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes.");
oParagraph.SetStyle(oMyStyleLeft);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is a paragraph with the text in it aligned by the right side. ");
oParagraph.AddText("The justification is specified in the paragraph style. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes.");
oParagraph.SetStyle(oMyStyleRight);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is a paragraph with the text in it aligned by the center. ");
oParagraph.AddText("The justification is specified in the paragraph style. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes.");
oParagraph.SetStyle(oMyStyleCenter);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is a paragraph with the text in it aligned by both sides (justified). ");
oParagraph.AddText("The justification is specified in the paragraph style. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes.");
oParagraph.SetStyle(oMyStyleBoth);
oDocument.Push(oParagraph);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).