How to configure the pagesetup?

Hi, Support,

I have a question that how to set pagesetup properties such as:

builder.PageSetup.LeftMargin = TPageLeft.Text
builder.PageSetup.TopMargin = TPageTop.Text
builder.PageSetup.RightMargin = TPageRight.Text
builder.PageSetup.BottomMargin = TPageBottom.Text
builder.ParagraphFormat.SpaceBefore = TParaBefore.Text
builder.ParagraphFormat.SpaceAfter = TParaAfter.Text
builder.ParagraphFormat.LineSpacing = TRowSpace.Text

Because the unit of TPageLeft.Text is centimeter not pixel/pang, how to convert the value of centimeter to pixel/pang.
for example, TPageLeft.text is 1.5 centimeter, how to convert 1.5 centimeter to 50 pixel or 40 pang?

Thanks for your help!

@ducaisoft

Thanks for your inquiry. You can convert centimeter into inch by dividing a value to 2.54. Once you have conversion value, you can convert inches to points using ConvertUtil.InchToPoint method and points to pixels using ConvertUtil.PointToPixel method. Hope this helps you.

Thanks for your reply.

Another question is what the unit of Linespacing is. Is it pond or pixel or Point?
the unit of original parameter of Linespacing as TRowSpace.Text is pond, who need to convert into pixel or point?
That is to say ,if TRowSpace.Text=20 pond, which is the right code?
Code 1: builder.ParagraphFormat.LineSpacing = TRowSpace.Text
Or
Code 2: builder.ParagraphFormat.LineSpacing = ConvertUtil.InchToPoint(TRowSpace.Text/72)

@ducaisoft

Thanks for your inquiry. Most of the object properties provided in the Aspose.Words API that represent some measurement (width/height, margins and various distances) accept values in points (1 inch equals 72 points).

ParagraphFormat.LineSpacing property gets or sets the line spacing (in points) for the paragraph.

Moreover, we suggest you please read following article.
How to Convert Between Measurement Units

@lovecomputer You can specify LineSpacingRule to LineSpacingRule.Multiple, then you use LineSpacing value, keeping in mind that 12 points corresponds one line. For example the following code specifies line spacing to 1.5 lines:

paragraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
paragraphFormat.LineSpacing = 1.5 * 12;