ConvertUtil Class
Provides helper functions to convert between various measurement units.
Inheritance Hierarchy
SystemObject
  Aspose.WordsConvertUtil

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public static class ConvertUtil

The ConvertUtil type exposes the following members.

Methods
  NameDescription
Public methodStatic memberCode exampleInchToPoint
Converts inches to points.
Public methodStatic memberCode exampleMillimeterToPoint
Converts millimeters to points.
Public methodStatic memberCode examplePixelToNewDpi
Converts pixels from one resolution to another.
Public methodStatic memberCode examplePixelToPoint(Double)
Converts pixels to points at 96 dpi.
Public methodStatic memberCode examplePixelToPoint(Double, Double)
Converts pixels to points at the specified pixel resolution.
Public methodStatic memberCode examplePointToInch
Converts points to inches.
Public methodStatic memberCode examplePointToPixel(Double)
Converts points to pixels at 96 dpi.
Public methodStatic memberCode examplePointToPixel(Double, Double)
Converts points to pixels at the specified pixel resolution.
Examples
Shows how to specify page properties in inches.
[C#]

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

PageSetup pageSetup = builder.PageSetup;
pageSetup.TopMargin = ConvertUtil.InchToPoint(1.0);
pageSetup.BottomMargin = ConvertUtil.InchToPoint(1.0);
pageSetup.LeftMargin = ConvertUtil.InchToPoint(1.5);
pageSetup.RightMargin = ConvertUtil.InchToPoint(1.5);
pageSetup.HeaderDistance = ConvertUtil.InchToPoint(0.2);
pageSetup.FooterDistance = ConvertUtil.InchToPoint(0.2);
Examples
Specifies paper size, orientation, margins and other settings for a section.
[C#]

DocumentBuilder builder = new DocumentBuilder();

PageSetup ps = builder.PageSetup;
ps.PaperSize = Aspose.Words.PaperSize.Legal;
ps.Orientation = Orientation.Landscape;
ps.TopMargin = ConvertUtil.InchToPoint(1.0);
ps.BottomMargin = ConvertUtil.InchToPoint(1.0);
ps.LeftMargin = ConvertUtil.InchToPoint(1.5);
ps.RightMargin = ConvertUtil.InchToPoint(1.5);
ps.HeaderDistance = ConvertUtil.InchToPoint(0.2);
ps.FooterDistance = ConvertUtil.InchToPoint(0.2);

builder.Writeln("Hello world.");

builder.Document.Save(ArtifactsDir + "PageSetup.PageMargins.doc");
See Also