OdgImage

Inheritance: java.lang.Object, com.aspose.imaging.DisposableObject, com.aspose.imaging.DataStreamSupporter, com.aspose.imaging.Image, com.aspose.imaging.VectorImage, com.aspose.imaging.VectorMultipageImage, com.aspose.imaging.fileformats.opendocument.OdImage

public class OdgImage extends OdImage

Manipulate OpenDocument Graphic (ODG) vector image file format with our API, widely used by OpenOffice and LibreOffice Draw applications for storing drawing elements in a vector format. Seamlessly parse documents, access pages, resize and rotate images, ensuring efficient processing and customization of ODG files to meet your specific requirements.

Constructors

ConstructorDescription
OdgImage(StreamContainer streamContainer, LoadOptions options)Initializes a new instance of the OdgImage class.
OdgImage(StreamContainer streamContainer)Initializes a new instance of the OdgImage class.

Methods

MethodDescription
getFileFormat()Gets a value of file format
getPageExportingAction()Gets the page exporting action.
setPageExportingAction(PageExportingAction value)Sets the page exporting action.
getPages()Gets the pages.
getDefaultOptions(Object[] args)Gets the default options.
resize(int newWidth, int newHeight, ImageResizeSettings settings)Resizes the image.
resize(int newWidth, int newHeight, int resizeType)Resizes the image.
rotateFlip(int rotateFlipType)Rotates, flips, or rotates and flips the image.

Example: This example loads a multi-page ODG image.

String dir = "c:\\temp\\";

// Using Aspose.Imaging.Image.Load is a unified way to load image.
com.aspose.imaging.fileformats.opendocument.MultiPageImage image = (com.aspose.imaging.fileformats.opendocument.MultiPageImage) com.aspose.imaging.Image.load(dir + "sample.odg");
try {
    // Cast to OdgImage
    com.aspose.imaging.fileformats.opendocument.OdgImage odgImage = (com.aspose.imaging.fileformats.opendocument.OdgImage) image;

    // Get all pages
    com.aspose.imaging.Image[] pages = odgImage.getPages();

    // Do some image processing
} finally {
    image.dispose();
}

Example: The following example shows how to export a FODG (Flat XML ODF Template) image to PDF format.

String dir = "c:\\aspose.imaging\\java\\issues\\1509\\";

String inputFileName = dir + "VariousObjectsMultiPage.fodg";
String outputFileName = inputFileName + ".pdf";

com.aspose.imaging.Image image = com.aspose.imaging.Image.load(inputFileName);
try {
    com.aspose.imaging.imageoptions.OdgRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.OdgRasterizationOptions();
    rasterizationOptions.setBackgroundColor(com.aspose.imaging.Color.getWhite());
    rasterizationOptions.setPageSize(Size.to_SizeF(image.getSize()));

    com.aspose.imaging.imageoptions.PdfOptions saveOptions = new com.aspose.imaging.imageoptions.PdfOptions();
    saveOptions.setVectorRasterizationOptions(rasterizationOptions);

    image.save(outputFileName, saveOptions);
}
finally {
    image.close();
}

OdgImage(StreamContainer streamContainer, LoadOptions options)

public OdgImage(StreamContainer streamContainer, LoadOptions options)

Initializes a new instance of the OdgImage class.

Parameters:

ParameterTypeDescription
streamContainerStreamContainerThe stream.
optionsLoadOptionsThe load options

OdgImage(StreamContainer streamContainer)

public OdgImage(StreamContainer streamContainer)

Initializes a new instance of the OdgImage class.

Parameters:

ParameterTypeDescription
streamContainerStreamContainerThe stream container.

getFileFormat()

public long getFileFormat()

Gets a value of file format

Returns: long - a value of file format

getPageExportingAction()

public PageExportingAction getPageExportingAction()

Gets the page exporting action. Please note that setting this method will automatically release page resources after it is executed. It will be executed just before each page is saved.

Value: The page exporting action.

Returns: PageExportingAction - the page exporting action.

setPageExportingAction(PageExportingAction value)

public void setPageExportingAction(PageExportingAction value)

Sets the page exporting action. Please note that setting this method will automatically release page resources after it is executed. It will be executed just before each page is saved.

Value: The page exporting action.

Parameters:

ParameterTypeDescription
valuePageExportingActionthe page exporting action.

getPages()

public Image[] getPages()

Gets the pages.

Value: The pages.

Returns: com.aspose.imaging.Image[] - the pages.

getDefaultOptions(Object[] args)

public ImageOptionsBase getDefaultOptions(Object[] args)

Gets the default options.

Parameters:

ParameterTypeDescription
argsjava.lang.Object[]The arguments.

Returns: ImageOptionsBase - Default options

resize(int newWidth, int newHeight, ImageResizeSettings settings)

public void resize(int newWidth, int newHeight, ImageResizeSettings settings)

Resizes the image.

Parameters:

ParameterTypeDescription
newWidthintThe new width.
newHeightintThe new height.
settingsImageResizeSettingsThe resize settings.

resize(int newWidth, int newHeight, int resizeType)

public void resize(int newWidth, int newHeight, int resizeType)

Resizes the image.

Parameters:

ParameterTypeDescription
newWidthintThe new width.
newHeightintThe new height.
resizeTypeintThe resize type.

rotateFlip(int rotateFlipType)

public void rotateFlip(int rotateFlipType)

Rotates, flips, or rotates and flips the image.

Parameters:

ParameterTypeDescription
rotateFlipTypeintType of the rotate flip.