java.lang.ObjectNodeRendererBase
com.aspose.words.ShapeRenderer
public class ShapeRenderer
Constructor Summary |
---|
ShapeRenderer(ShapeBase shape)
Initializes a new instance of this class. |
Property Getters/Setters Summary | ||
---|---|---|
java.awt.geom.Rectangle2D.Float | getBoundsInPoints() | → inherited from NodeRendererBase |
Gets the actual bounds of the shape in points. | ||
java.awt.geom.Rectangle2D.Float | getOpaqueBoundsInPoints() | → inherited from NodeRendererBase |
Gets the opaque bounds of the shape in points. | ||
java.awt.Dimension | getSizeInPoints() | → inherited from NodeRendererBase |
Gets the actual size of the shape in points. |
Method Summary | ||
---|---|---|
java.awt.Rectangle | getBoundsInPixels(float scale, float dpi) | → inherited from NodeRendererBase |
Calculates the bounds of the shape in pixels for a specified zoom factor and resolution. | ||
java.awt.Rectangle | getBoundsInPixels(float scale, float horizontalDpi, float verticalDpi) | → inherited from NodeRendererBase |
Calculates the bounds of the shape in pixels for a specified zoom factor and resolution. | ||
java.awt.Rectangle | getOpaqueBoundsInPixels(float scale, float dpi) | → inherited from NodeRendererBase |
Calculates the opaque bounds of the shape in pixels for a specified zoom factor and resolution. | ||
java.awt.Rectangle | getOpaqueBoundsInPixels(float scale, float horizontalDpi, float verticalDpi) | → inherited from NodeRendererBase |
Calculates the opaque bounds of the shape in pixels for a specified zoom factor and resolution. | ||
java.awt.Dimension | getSizeInPixels(float scale, float dpi) | → inherited from NodeRendererBase |
Calculates the size of the shape in pixels for a specified zoom factor and resolution. | ||
java.awt.Dimension | getSizeInPixels(float scale, float horizontalDpi, float verticalDpi) | → inherited from NodeRendererBase |
Calculates the size of the shape in pixels for a specified zoom factor and resolution. | ||
java.awt.geom.Point2D.Float | renderToScale(java.awt.Graphics2D graphics, float x, float y, float scale) | → inherited from NodeRendererBase |
Renders the shape into a |
||
float | renderToSize(java.awt.Graphics2D graphics, float x, float y, float width, float height) | → inherited from NodeRendererBase |
Renders the shape into a |
||
void | save(java.io.OutputStream stream, ImageSaveOptions saveOptions) | → inherited from NodeRendererBase |
Renders the shape into an image and saves into a stream. | ||
void | save(java.lang.String fileName, ImageSaveOptions saveOptions) | → inherited from NodeRendererBase |
Renders the shape into an image and saves into a file. |
Constructor Detail |
---|
public ShapeRenderer(ShapeBase shape) throws java.lang.Exception
shape
- The DrawinML shape object that you want to render.Property Getters/Setters Detail |
---|
getBoundsInPoints | → inherited from NodeRendererBase |
public java.awt.geom.Rectangle2D.Float getBoundsInPoints() |
This property returns the actual (as rendered on the page) bounding box of the shape. The bounds takes into account shape rotation (if any).
Example:
Shows how to measure and scale shapes.// Open a document that contains an OfficeMath object Document doc = new Document(getMyDir() + "Office math.docx"); // Create a renderer for the OfficeMath object OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath); // We can measure the size of the image that the OfficeMath object will create when we render it Assert.assertEquals(renderer.getSizeInPoints().getX(), 117.0, 0.1); Assert.assertEquals(renderer.getSizeInPoints().getY(), 12.9, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getHeight(), 12.9, 0.1); // Shapes with transparent parts may return different values here Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getHeight(), 14.7, 0.1); // Get the shape size in pixels, with linear scaling to a specific DPI Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 18.0); // 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(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 27.0); // The opaque bounds may vary here also bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(20.0, bounds.getHeight()); bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(31.0, bounds.getHeight());
getOpaqueBoundsInPoints | → inherited from NodeRendererBase |
public java.awt.geom.Rectangle2D.Float getOpaqueBoundsInPoints() |
This property returns the opaque (i.e. transparent parts of the shape are ignored) bounding box of the shape. The bounds takes the shape rotation into account.
Example:
Shows how to measure and scale shapes.// Open a document that contains an OfficeMath object Document doc = new Document(getMyDir() + "Office math.docx"); // Create a renderer for the OfficeMath object OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath); // We can measure the size of the image that the OfficeMath object will create when we render it Assert.assertEquals(renderer.getSizeInPoints().getX(), 117.0, 0.1); Assert.assertEquals(renderer.getSizeInPoints().getY(), 12.9, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getHeight(), 12.9, 0.1); // Shapes with transparent parts may return different values here Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getHeight(), 14.7, 0.1); // Get the shape size in pixels, with linear scaling to a specific DPI Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 18.0); // 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(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 27.0); // The opaque bounds may vary here also bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(20.0, bounds.getHeight()); bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(31.0, bounds.getHeight());
getSizeInPoints | → inherited from NodeRendererBase |
public java.awt.Dimension getSizeInPoints() |
This property returns the size of the actual (as rendered on the page) bounding box of the shape. The size takes into account shape rotation (if any).
Example:
Shows how to measure and scale shapes.// Open a document that contains an OfficeMath object Document doc = new Document(getMyDir() + "Office math.docx"); // Create a renderer for the OfficeMath object OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath); // We can measure the size of the image that the OfficeMath object will create when we render it Assert.assertEquals(renderer.getSizeInPoints().getX(), 117.0, 0.1); Assert.assertEquals(renderer.getSizeInPoints().getY(), 12.9, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getHeight(), 12.9, 0.1); // Shapes with transparent parts may return different values here Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getHeight(), 14.7, 0.1); // Get the shape size in pixels, with linear scaling to a specific DPI Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 18.0); // 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(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 27.0); // The opaque bounds may vary here also bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(20.0, bounds.getHeight()); bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(31.0, bounds.getHeight());
Method Detail |
---|
getBoundsInPixels | → inherited from NodeRendererBase |
public java.awt.Rectangle getBoundsInPixels(float scale, float dpi) |
This method converts
scale
- The zoom factor (1.0 is 100%).dpi
- The resolution (horizontal and vertical) to convert from points to pixels (dots per inch).Example:
Shows how to measure and scale shapes.// Open a document that contains an OfficeMath object Document doc = new Document(getMyDir() + "Office math.docx"); // Create a renderer for the OfficeMath object OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath); // We can measure the size of the image that the OfficeMath object will create when we render it Assert.assertEquals(renderer.getSizeInPoints().getX(), 117.0, 0.1); Assert.assertEquals(renderer.getSizeInPoints().getY(), 12.9, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getHeight(), 12.9, 0.1); // Shapes with transparent parts may return different values here Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getHeight(), 14.7, 0.1); // Get the shape size in pixels, with linear scaling to a specific DPI Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 18.0); // 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(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 27.0); // The opaque bounds may vary here also bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(20.0, bounds.getHeight()); bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(31.0, bounds.getHeight());
getBoundsInPixels | → inherited from NodeRendererBase |
public java.awt.Rectangle getBoundsInPixels(float scale, float horizontalDpi, float verticalDpi) |
This method converts
scale
- The zoom factor (1.0 is 100%).horizontalDpi
- The horizontal resolution to convert from points to pixels (dots per inch).verticalDpi
- The vertical resolution to convert from points to pixels (dots per inch).Example:
Shows how to measure and scale shapes.// Open a document that contains an OfficeMath object Document doc = new Document(getMyDir() + "Office math.docx"); // Create a renderer for the OfficeMath object OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath); // We can measure the size of the image that the OfficeMath object will create when we render it Assert.assertEquals(renderer.getSizeInPoints().getX(), 117.0, 0.1); Assert.assertEquals(renderer.getSizeInPoints().getY(), 12.9, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getHeight(), 12.9, 0.1); // Shapes with transparent parts may return different values here Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getHeight(), 14.7, 0.1); // Get the shape size in pixels, with linear scaling to a specific DPI Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 18.0); // 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(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 27.0); // The opaque bounds may vary here also bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(20.0, bounds.getHeight()); bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(31.0, bounds.getHeight());
getOpaqueBoundsInPixels | → inherited from NodeRendererBase |
public java.awt.Rectangle getOpaqueBoundsInPixels(float scale, float dpi) throws java.lang.Exception |
This method converts
scale
- The zoom factor (1.0 is 100%).dpi
- The resolution to convert from points to pixels (dots per inch).Example:
Shows how to measure and scale shapes.// Open a document that contains an OfficeMath object Document doc = new Document(getMyDir() + "Office math.docx"); // Create a renderer for the OfficeMath object OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath); // We can measure the size of the image that the OfficeMath object will create when we render it Assert.assertEquals(renderer.getSizeInPoints().getX(), 117.0, 0.1); Assert.assertEquals(renderer.getSizeInPoints().getY(), 12.9, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getHeight(), 12.9, 0.1); // Shapes with transparent parts may return different values here Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getHeight(), 14.7, 0.1); // Get the shape size in pixels, with linear scaling to a specific DPI Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 18.0); // 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(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 27.0); // The opaque bounds may vary here also bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(20.0, bounds.getHeight()); bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(31.0, bounds.getHeight());
getOpaqueBoundsInPixels | → inherited from NodeRendererBase |
public java.awt.Rectangle getOpaqueBoundsInPixels(float scale, float horizontalDpi, float verticalDpi) throws java.lang.Exception |
This method converts
scale
- The zoom factor (1.0 is 100%).horizontalDpi
- The horizontal resolution to convert from points to pixels (dots per inch).verticalDpi
- The vertical resolution to convert from points to pixels (dots per inch).Example:
Shows how to measure and scale shapes.// Open a document that contains an OfficeMath object Document doc = new Document(getMyDir() + "Office math.docx"); // Create a renderer for the OfficeMath object OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath); // We can measure the size of the image that the OfficeMath object will create when we render it Assert.assertEquals(renderer.getSizeInPoints().getX(), 117.0, 0.1); Assert.assertEquals(renderer.getSizeInPoints().getY(), 12.9, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getHeight(), 12.9, 0.1); // Shapes with transparent parts may return different values here Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getHeight(), 14.7, 0.1); // Get the shape size in pixels, with linear scaling to a specific DPI Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 18.0); // 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(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 27.0); // The opaque bounds may vary here also bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(20.0, bounds.getHeight()); bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(31.0, bounds.getHeight());
getSizeInPixels | → inherited from NodeRendererBase |
public java.awt.Dimension getSizeInPixels(float scale, float dpi) |
This method converts
scale
- The zoom factor (1.0 is 100%).dpi
- The resolution (horizontal and vertical) to convert from points to pixels (dots per inch).Example:
Shows how to measure and scale shapes.// Open a document that contains an OfficeMath object Document doc = new Document(getMyDir() + "Office math.docx"); // Create a renderer for the OfficeMath object OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath); // We can measure the size of the image that the OfficeMath object will create when we render it Assert.assertEquals(renderer.getSizeInPoints().getX(), 117.0, 0.1); Assert.assertEquals(renderer.getSizeInPoints().getY(), 12.9, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getHeight(), 12.9, 0.1); // Shapes with transparent parts may return different values here Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getHeight(), 14.7, 0.1); // Get the shape size in pixels, with linear scaling to a specific DPI Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 18.0); // 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(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 27.0); // The opaque bounds may vary here also bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(20.0, bounds.getHeight()); bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(31.0, bounds.getHeight());
getSizeInPixels | → inherited from NodeRendererBase |
public java.awt.Dimension getSizeInPixels(float scale, float horizontalDpi, float verticalDpi) |
This method converts
scale
- The zoom factor (1.0 is 100%).horizontalDpi
- The horizontal resolution to convert from points to pixels (dots per inch).verticalDpi
- The vertical resolution to convert from points to pixels (dots per inch).Example:
Shows how to measure and scale shapes.// Open a document that contains an OfficeMath object Document doc = new Document(getMyDir() + "Office math.docx"); // Create a renderer for the OfficeMath object OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath); // We can measure the size of the image that the OfficeMath object will create when we render it Assert.assertEquals(renderer.getSizeInPoints().getX(), 117.0, 0.1); Assert.assertEquals(renderer.getSizeInPoints().getY(), 12.9, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getBoundsInPoints().getHeight(), 12.9, 0.1); // Shapes with transparent parts may return different values here Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getWidth(), 117.0, 0.1); Assert.assertEquals(renderer.getOpaqueBoundsInPoints().getHeight(), 14.7, 0.1); // Get the shape size in pixels, with linear scaling to a specific DPI Rectangle bounds = renderer.getBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 18.0); // 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(bounds.getWidth(), 156.0); Assert.assertEquals(bounds.getHeight(), 27.0); // The opaque bounds may vary here also bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(20.0, bounds.getHeight()); bounds = renderer.getOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f); Assert.assertEquals(156.0, bounds.getWidth()); Assert.assertEquals(31.0, bounds.getHeight());
renderToScale | → inherited from NodeRendererBase |
public java.awt.geom.Point2D.Float renderToScale(java.awt.Graphics2D graphics, float x, float y, float scale) throws java.lang.Exception |
graphics
- The object where to render to.x
- The X coordinate (in world units) of the top left corner of the rendered shape.y
- The Y coordinate (in world units) of the top left corner of the rendered shape.scale
- The scale for rendering the shape (1.0 is 100%).renderToSize | → inherited from NodeRendererBase |
public float renderToSize(java.awt.Graphics2D graphics, float x, float y, float width, float height) throws java.lang.Exception |
graphics
- The object where to render to.x
- The X coordinate (in world units) of the top left corner of the rendered shape.y
- The Y coordinate (in world units) of the top left corner of the rendered shape.width
- The maximum width (in world units) that can be occupied by the rendered shape.height
- The maximum height (in world units) that can be occupied by the rendered shape.save | → inherited from NodeRendererBase |
public void save(java.io.OutputStream stream, ImageSaveOptions saveOptions) throws java.lang.Exception |
stream
- The stream where to save the image of the shape.saveOptions
- Specifies the options that control how the shape is rendered and saved. Can be null.
If this is null, the image will be saved in the PNG format.Example:
Shows how to export shapes to files in the local file system using a shape renderer.// Open a document that contains shapes and get its shape collection Document doc = new Document(getMyDir() + "Various shapes.docx"); NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true); Assert.assertEquals(7, shapes.getCount()); // There are 7 shapes in the document, with one group shape with 2 child shapes // The child shapes will be rendered but their parent group shape will be skipped, so we will see 6 output files for (Shape shape : (Iterable<Shape>) shapes) { ShapeRenderer renderer = shape.getShapeRenderer(); ImageSaveOptions options = new ImageSaveOptions(SaveFormat.PNG); renderer.save(getArtifactsDir() + MessageFormat.format("Shape.RenderAllShapes.{0}.png", shape.getName()), options); }
save | → inherited from NodeRendererBase |
public void save(java.lang.String fileName, ImageSaveOptions saveOptions) throws java.lang.Exception |
fileName
- The name for the image file. If a file with the specified name already exists, the existing file is overwritten.saveOptions
- Specifies the options that control how the shape is rendered and saved. Can be null.Example:
Shows how to convert specific object into image.Document doc = new Document(getMyDir() + "Office math.docx"); // Get OfficeMath node from the document and render this as image (you can also do the same with the Shape node) OfficeMath math = (OfficeMath) doc.getChild(NodeType.OFFICE_MATH, 0, true); math.getMathRenderer().save(getArtifactsDir() + "Shape.SaveShapeObjectAsImage.png", new ImageSaveOptions(SaveFormat.PNG));