|
java.lang.Object
com.aspose.words.ConvertUtil
public class ConvertUtil - extends java.lang.Object
Provides helper functions to convert between various measurement units.
|
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) | |
|
Convers 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.
|
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.
Example: Opens an HTML document with images from a stream with a base URI.
// We are opening this HTML file:
/*
<html>
<body>
<p>Simple file.</p>
<p><img src="Aspose.Words.gif" width="80" height="60"></p>
</body>
</html>
*/
String fileName = getMyDir() + "Document.OpenFromStreamWithBaseUri.html";
// Open the stream.
InputStream stream = new FileInputStream(fileName);
// Open the document. Note the Document constructor detects HTML format automatically.
// Pass the URI of the base folder so any images with relative URIs in the file can be found.
Document doc = new Document(stream, getMyDir());
// You can close the stream now, it is no longer needed because the document is in memory.
stream.close();
// Lets make sure the image was imported successfully into a Shape node.
// Get the 1st shape node in the document.
Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
// Verify some properties of the image.
Assert.assertTrue(shape.isImage());
Assert.assertNotNull(shape.getImageData().getImageBytes());
Assert.assertEquals(80.0, ConvertUtil.pointToPixel(shape.getWidth()));
Assert.assertEquals(60.0, ConvertUtil.pointToPixel(shape.getHeight()));
// Save in the DOC format.
doc.save(getMyDir() + "Document.OpenFromStreamWithBaseUri Out.doc");
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.
pixelToPoint | |
public static double pixelToPoint(double pixels) |
-
Convers 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.
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.
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("Hellow world.");
builder.getDocument().save(getMyDir() + "PageSetup.PageMargins Out.doc");
pointToInch | |
public static double pointToInch(double points) |
-
Converts points to inches.
1 inch equals 72 points.
- Parameters:
points - The value to convert.
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.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.
|