ConvertUtilPixelToPoint Method (Double)

Converts pixels to points at 96 dpi.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public static double PixelToPoint(
	double pixels
)

Parameters

pixels
Type: SystemDouble
The value to convert.

Return Value

Type: Double
Remarks
1 inch equals 72 points.
Examples
Shows how to specify page properties in pixels with default and custom resolution.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

PageSetup pageSetupNoDpi = builder.PageSetup;
pageSetupNoDpi.TopMargin = ConvertUtil.PixelToPoint(100.0);
pageSetupNoDpi.BottomMargin = ConvertUtil.PixelToPoint(100.0);
pageSetupNoDpi.LeftMargin = ConvertUtil.PixelToPoint(150.0);
pageSetupNoDpi.RightMargin = ConvertUtil.PixelToPoint(150.0);
pageSetupNoDpi.HeaderDistance = ConvertUtil.PixelToPoint(20.0);
pageSetupNoDpi.FooterDistance = ConvertUtil.PixelToPoint(20.0);

builder.Writeln("Hello world.");
builder.Document.Save(ArtifactsDir + "UtilityClasses.PixelToPoint.DefaultResolution.doc");

double myDpi = 150.0;

PageSetup pageSetupWithDpi = builder.PageSetup;
pageSetupWithDpi.TopMargin = ConvertUtil.PixelToPoint(100.0, myDpi);
pageSetupWithDpi.BottomMargin = ConvertUtil.PixelToPoint(100.0, myDpi);
pageSetupWithDpi.LeftMargin = ConvertUtil.PixelToPoint(150.0, myDpi);
pageSetupWithDpi.RightMargin = ConvertUtil.PixelToPoint(150.0, myDpi);
pageSetupWithDpi.HeaderDistance = ConvertUtil.PixelToPoint(20.0, myDpi);
pageSetupWithDpi.FooterDistance = ConvertUtil.PixelToPoint(20.0, myDpi);

builder.Document.Save(ArtifactsDir + "UtilityClasses.PixelToPoint.CustomResolution.doc");
See Also