public class OfficeMathRenderer extends NodeRendererBase
OfficeMath to a raster or vector image or to a Graphics object.
To learn more, visit the Working with OfficeMath documentation article.
Examples:
Shows how to measure and scale shapes.
Document doc = new Document(getMyDir() + "Office math.docx");
OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true);
OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath);
Assert.assertEquals(122.0f, renderer.getBoundsInPoints().getWidth(), 0.25f);
Assert.assertEquals(12.9f, renderer.getBoundsInPoints().getHeight(), 0.1f);
// Shapes with transparent parts may contain different values in the "OpaqueBoundsInPoints" properties.
Assert.assertEquals(122.0f, renderer.getOpaqueBoundsInPoints().getWidth(), 0.25f);
Assert.assertEquals(14.2f, renderer.getOpaqueBoundsInPoints().getHeight(), 0.1f);
// Get the shape size in pixels, with linear scaling to a specific DPI.
Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f);
Assert.assertEquals(163.0, bounds.getWidth());
Assert.assertEquals(18.0, bounds.getHeight());
// Get the shape size in pixels, but with a different DPI for the horizontal and vertical dimensions.
bounds = renderer.getBoundsInPixels(1.0f, 96.0f, 150.0f);
Assert.assertEquals(163.0, bounds.getWidth());
Assert.assertEquals(27.0, bounds.getHeight());
// The opaque bounds may vary here also.
bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f);
Assert.assertEquals(163.0, bounds.getWidth());
Assert.assertEquals(19.0, bounds.getHeight());
bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f);
Assert.assertEquals(163.0, bounds.getWidth());
Assert.assertEquals(29.0, bounds.getHeight());
| Constructor and Description |
|---|
OfficeMathRenderer(OfficeMath math)
Initializes a new instance of this class.
|
getBoundsInPixels, getBoundsInPixels, getBoundsInPoints, getOpaqueBoundsInPixels, getOpaqueBoundsInPixels, getOpaqueBoundsInPoints, getSizeInPixels, getSizeInPixels, getSizeInPoints, renderToScale, renderToSize, save, save, save, savepublic OfficeMathRenderer(OfficeMath math) throws java.lang.Exception
Examples:
Shows how to measure and scale shapes.
Document doc = new Document(getMyDir() + "Office math.docx");
OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true);
OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath);
Assert.assertEquals(122.0f, renderer.getBoundsInPoints().getWidth(), 0.25f);
Assert.assertEquals(12.9f, renderer.getBoundsInPoints().getHeight(), 0.1f);
// Shapes with transparent parts may contain different values in the "OpaqueBoundsInPoints" properties.
Assert.assertEquals(122.0f, renderer.getOpaqueBoundsInPoints().getWidth(), 0.25f);
Assert.assertEquals(14.2f, renderer.getOpaqueBoundsInPoints().getHeight(), 0.1f);
// Get the shape size in pixels, with linear scaling to a specific DPI.
Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f);
Assert.assertEquals(163.0, bounds.getWidth());
Assert.assertEquals(18.0, bounds.getHeight());
// Get the shape size in pixels, but with a different DPI for the horizontal and vertical dimensions.
bounds = renderer.getBoundsInPixels(1.0f, 96.0f, 150.0f);
Assert.assertEquals(163.0, bounds.getWidth());
Assert.assertEquals(27.0, bounds.getHeight());
// The opaque bounds may vary here also.
bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f);
Assert.assertEquals(163.0, bounds.getWidth());
Assert.assertEquals(19.0, bounds.getHeight());
bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f);
Assert.assertEquals(163.0, bounds.getWidth());
Assert.assertEquals(29.0, bounds.getHeight());
math - The OfficeMath object that you want to render.java.lang.Exception