Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Most of the object properties provided in the Aspose.Words API that represent some measurement, such as width or height, margins, and various distances, accept values in points, where 1 inch equals 72 points. Sometimes this is not convenient and points need to be converted to other units.
Aspose.Words provides the ConvertUtil class that provides helper functions to convert between various measurement units. It enables converting inches, pixels and millimeters to points, points to inches and pixels, and converting pixels from one resolution to another. Converting pixels to points and vice versa can be performed at 96 dpi (dots per inch) resolutions or specified dpi resolution.
The ConvertUtil class is especially useful when setting various page properties because, for instance, inches are more common measurement units than points.
The following code example shows how to specify page properties in inches:
Q: How do I convert inches to points using Aspose.Words for C++?
A: Call Aspose::Words::ConvertUtil::InchesToPoints(double inches). For example:
double points = Aspose::Words::ConvertUtil::InchesToPoints(2.5); // 2.5 inches = 180 points
Q: How can I convert points to pixels at a specific DPI?
A: Use Aspose::Words::ConvertUtil::PointsToPixels(double points, double dpi). Example:
int pixels = Aspose::Words::ConvertUtil::PointsToPixels(72, 96); // 72 points = 96 pixels at 96 dpi
Q: Is there a method to convert millimeters to points?
A: Yes, Aspose::Words::ConvertUtil::MillimetersToPoints(double millimeters). Example:
double points = Aspose::Words::ConvertUtil::MillimetersToPoints(25.4); // 25.4 mm = 72 points
Q: How do I convert pixels from one resolution to another?
A: Use Aspose::Words::ConvertUtil::PixelsToPixels(int pixels, double sourceDpi, double targetDpi). Example:
int newPixels = Aspose::Words::ConvertUtil::PixelsToPixels(200, 96, 300); // 200 px at 96 dpi → equivalent at 300 dpi
Q: Can ConvertUtil convert points back to inches?
A: Yes, call Aspose::Words::ConvertUtil::PointsToInches(double points). Example:
double inches = Aspose::Words::ConvertUtil::PointsToInches(144); // 144 points = 2 inches
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.