GraphicsQualityOptions

Inheritance: java.lang.Object

public class GraphicsQualityOptions

Allows to specify additional java.awt.RenderingHints.

To learn more, visit the Save a Document documentation article.

Gets current java.awt.RenderingHints to view or to add new hints. Overwrites current java.awt.RenderingHints.

Examples:

Shows how to set render quality options while converting documents to image formats.


 Document doc = new Document(getMyDir() + "Rendering.docx");

 GraphicsQualityOptions qualityOptions = new GraphicsQualityOptions();
 qualityOptions.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // SmoothingMode
 qualityOptions.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); // TextRenderingHint
 qualityOptions.getRenderingHints().put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); // CompositingMode
 qualityOptions.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); // CompositingQuality
 qualityOptions.getRenderingHints().put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); // InterpolationMode
 qualityOptions.getRenderingHints().put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); // StringFormat

 ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
 saveOptions.setGraphicsQualityOptions(qualityOptions);

 doc.save(getArtifactsDir() + "ImageSaveOptions.GraphicsQuality.jpg", saveOptions);
 

Methods

MethodDescription
getRenderingHints()
getUseTileFlipMode()Gets a flag indicating whether WrapMode is TileFlipXY.
setRenderingHints(RenderingHints renderingHints)
setUseTileFlipMode(boolean value)Sets a flag indicating whether WrapMode is TileFlipXY.

getRenderingHints()

public RenderingHints getRenderingHints()

Returns: java.awt.RenderingHints

getUseTileFlipMode()

public boolean getUseTileFlipMode()

Gets a flag indicating whether WrapMode is TileFlipXY.

Remarks:

The WrapMode specifies how a texture or gradient is tiled when it is smaller than the area being filled.

By default uses WrapMode#TILE.TILE (specifies tiling without flipping). This causes inaccurate rendering of the scaled image(with high resolution).

This property allows to switch WrapMode to WrapMode#TILE_FLIP_XY.TILE_FLIP_XY (specifies that tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column).

Examples:

Shows how to prevent the white line appears when rendering with a high resolution.


 Document doc = new Document(getMyDir() + "Shape high dpi.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 ShapeRenderer renderer = shape.getShapeRenderer();

 ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.PNG);
 {
     saveOptions.setResolution(500f); saveOptions.setGraphicsQualityOptions(new GraphicsQualityOptions()); { saveOptions.getGraphicsQualityOptions().setUseTileFlipMode(true); }
 }
 renderer.save(getArtifactsDir() + "ImageSaveOptions.UseTileFlipMode.png", saveOptions);
 

Returns: boolean - A flag indicating whether WrapMode is TileFlipXY.

setRenderingHints(RenderingHints renderingHints)

public void setRenderingHints(RenderingHints renderingHints)

Parameters:

ParameterTypeDescription
renderingHintsjava.awt.RenderingHints

setUseTileFlipMode(boolean value)

public void setUseTileFlipMode(boolean value)

Sets a flag indicating whether WrapMode is TileFlipXY.

Remarks:

The WrapMode specifies how a texture or gradient is tiled when it is smaller than the area being filled.

By default uses WrapMode#TILE.TILE (specifies tiling without flipping). This causes inaccurate rendering of the scaled image(with high resolution).

This property allows to switch WrapMode to WrapMode#TILE_FLIP_XY.TILE_FLIP_XY (specifies that tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column).

Examples:

Shows how to prevent the white line appears when rendering with a high resolution.


 Document doc = new Document(getMyDir() + "Shape high dpi.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 ShapeRenderer renderer = shape.getShapeRenderer();

 ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.PNG);
 {
     saveOptions.setResolution(500f); saveOptions.setGraphicsQualityOptions(new GraphicsQualityOptions()); { saveOptions.getGraphicsQualityOptions().setUseTileFlipMode(true); }
 }
 renderer.save(getArtifactsDir() + "ImageSaveOptions.UseTileFlipMode.png", saveOptions);
 

Parameters:

ParameterTypeDescription
valuebooleanA flag indicating whether WrapMode is TileFlipXY.