java.lang.Object
com.aspose.words.ConvertUtil
public class ConvertUtil
- extends java.lang.Object
Provides helper functions to convert between various measurement units.
Example:
Shows how to specify page properties in inches.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
PageSetup pageSetup = builder.getPageSetup();
pageSetup.setTopMargin(ConvertUtil.inchToPoint(1.0));
pageSetup.setBottomMargin(ConvertUtil.inchToPoint(1.0));
pageSetup.setLeftMargin(ConvertUtil.inchToPoint(1.5));
pageSetup.setRightMargin(ConvertUtil.inchToPoint(1.5));
pageSetup.setHeaderDistance(ConvertUtil.inchToPoint(0.2));
pageSetup.setFooterDistance(ConvertUtil.inchToPoint(0.2));
Example:
Specifies paper size, orientation, margins and other settings for a section.
DocumentBuilder builder = new DocumentBuilder();
PageSetup ps = builder.getPageSetup();
ps.setPaperSize(PaperSize.LEGAL);
ps.setOrientation(Orientation.LANDSCAPE);
ps.setTopMargin(ConvertUtil.inchToPoint(1.0));
ps.setBottomMargin(ConvertUtil.inchToPoint(1.0));
ps.setLeftMargin(ConvertUtil.inchToPoint(1.5));
ps.setRightMargin(ConvertUtil.inchToPoint(1.5));
ps.setHeaderDistance(ConvertUtil.inchToPoint(0.2));
ps.setFooterDistance(ConvertUtil.inchToPoint(0.2));
builder.writeln("Hello world.");
builder.getDocument().save(getMyDir() + "PageSetup.PageMargins Out.doc");
Method Summary |
static double | inchToPoint(double inches) | |
Converts inches to points.
|
static double | millimeterToPoint(double millimeters) | |
Converts millimeters to points.
|
static int | pixelToNewDpi(double pixels, double oldDpi, double newDpi) | |
Converts pixels from one resolution to another.
|
static double | pixelToPoint(double pixels) | |
Converts pixels to points at 96 dpi.
|
static double | pixelToPoint(double pixels, double resolution) | |
Converts pixels to points at the specified pixel resolution.
|
static double | pointToInch(double points) | |
Converts points to inches.
|
static double | pointToPixel(double points) | |
Converts points to pixels at 96 dpi.
|
static double | pointToPixel(double points, double resolution) | |
Converts points to pixels at the specified pixel resolution.
|
inchToPoint | |
public static double inchToPoint(double inches) |
-
Converts inches to points.
1 inch equals 72 points.
- Parameters:
inches
- The value to convert.
Example:
Specifies paper size, orientation, margins and other settings for a section.
DocumentBuilder builder = new DocumentBuilder();
PageSetup ps = builder.getPageSetup();
ps.setPaperSize(PaperSize.LEGAL);
ps.setOrientation(Orientation.LANDSCAPE);
ps.setTopMargin(ConvertUtil.inchToPoint(1.0));
ps.setBottomMargin(ConvertUtil.inchToPoint(1.0));
ps.setLeftMargin(ConvertUtil.inchToPoint(1.5));
ps.setRightMargin(ConvertUtil.inchToPoint(1.5));
ps.setHeaderDistance(ConvertUtil.inchToPoint(0.2));
ps.setFooterDistance(ConvertUtil.inchToPoint(0.2));
builder.writeln("Hello world.");
builder.getDocument().save(getMyDir() + "PageSetup.PageMargins Out.doc");
millimeterToPoint | |
public static double millimeterToPoint(double millimeters) |
-
Converts millimeters to points.
1 inch equals 25.4 millimeters. 1 inch equals 72 points.
- Parameters:
millimeters
- The value to convert.
pixelToNewDpi | |
public static int pixelToNewDpi(double pixels, double oldDpi, double newDpi) |
-
Converts pixels from one resolution to another.
- Parameters:
pixels
- The value to convert.oldDpi
- The current dpi (dots per inch) resolution.newDpi
- The new dpi (dots per inch) resolution.
pixelToPoint | |
public static double pixelToPoint(double pixels) |
-
Converts pixels to points at 96 dpi.
1 inch equals 72 points.
- Parameters:
pixels
- The value to convert.
pixelToPoint | |
public static double pixelToPoint(double pixels, double resolution) |
-
Converts pixels to points at the specified pixel resolution.
1 inch equals 72 points.
- Parameters:
pixels
- The value to convert.resolution
- The dpi (dots per inch) resolution.
pointToInch | |
public static double pointToInch(double points) |
-
Converts points to inches.
1 inch equals 72 points.
- Parameters:
points
- The value to convert.
pointToPixel | |
public static double pointToPixel(double points) |
-
Converts points to pixels at 96 dpi.
1 inch equals 72 points.
- Parameters:
points
- The value to convert.
pointToPixel | |
public static double pointToPixel(double points, double resolution) |
-
Converts points to pixels at the specified pixel resolution.
1 inch equals 72 points.
- Parameters:
points
- The value to convert.resolution
- The dpi (dots per inch) resolution.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.