In the Aspose.Words for .NET component, the section.PageSetup.TopMargin property retrieves values in points. Is there a corresponding property that retrieves the value in centimeters?
Can you please specify if you are looking for a method to convert points to centimeters or if you need a specific property in Aspose.Words for .NET that directly provides margins in centimeters?
need a specific property in Aspose.Words for .NET that directly provides margins in centimeters
@Melancholy Aspose.Words uses points as measurement unit. You can convert between units using ConvertUtil. Or you can write your own method to convert between units. 1 inch equals 25.4 millimeters.
In the ConvertUtil object, there is only the MillimeterToPoint method but no PointToMillimeter method. When converting centimeters to points, the result has multiple decimal places and requires rounding, which leads to inaccuracies compared to the exact point values used in Office’s margin settings. This makes it imprecise and unusable for practical applications. Could you add a PointToMillimeter method?
@Melancholy Here is implementation of PointToMillimeter method:
private static double PointToMillimeter(double points)
{
const double PointsPerInch = 72.0;
const double MmPerInch = 25.4;
return (points / PointsPerInch) * MmPerInch;
}
You can add rounding of the resulting value according to your needs.