public class CdrImage extends VectorMultipageImage implements ICdrImage
The API for CorelDRAW CDR vector image format support is an essential toolkit for developers working with vector graphics. This API enables the seamless processing of CDR files, allowing for the storage and manipulation of diverse elements such as text, lines, shapes, images, colors, and effects. With its comprehensive capabilities, developers can efficiently work with vector representations of image contents, ensuring precision and flexibility in creating and editing CorelDRAW vector graphics programmatically.
Image,
ICdrImage,
VectorMultipageImageThe following example shows how to cache all pages of a CDR image.
String dir = "c:\\temp\\";
// Load an image from a CDR file.
com.aspose.imaging.fileformats.cdr.CdrImage image = (com.aspose.imaging.fileformats.cdr.CdrImage) com.aspose.imaging.Image.load(dir + "sample.cdr");
try {
// This call caches only the default page.
image.cacheData();
// Cache all pages so that no additional data loading will be performed from the underlying data stream.
for (com.aspose.imaging.fileformats.cdr.CdrImagePage page : image.getPages()) {
page.cacheData();
}
} finally {
image.dispose();
}
| Constructor and Description |
|---|
CdrImage(InputStream stream,
LoadOptions loadOptions)
Start working with the
CdrImage class effortlessly by
initializing a new instance with a stream and loadOptions parameters. |
CdrImage(com.aspose.ms.System.IO.Stream stream,
LoadOptions loadOptions) |
| Modifier and Type | Method and Description |
|---|---|
void |
cacheData()
Effortlessly cache the data to prevent additional loading from the underlying source
with this user-friendly method.
|
int |
getBitsPerPixel()
Retrieve the bit depth of the image effortlessly with this user-friendly property.
|
CdrDocument |
getCdrDocument()
Effortlessly retrieve or update the CDR document using this intuitive property.
|
Image |
getDefaultPage()
Deprecated.
Please use getPages()[index]
|
long |
getFileFormat()
Retrieve the file format of the image effortlessly with this intuitive property.
|
int |
getHeight()
Gets the image height.
|
int |
getPageCount()
Effortlessly retrieve or update the total page count of the image with this
intuitive property.
|
Image[] |
getPages()
Retrieve the pages of the image seamlessly with this intuitive property.
|
int |
getWidth()
Gets the image width.
|
boolean |
isCached()
Effortlessly determine whether the object's data is currently cached,
eliminating the need for data reading.
|
void |
setPalette(IColorPalette palette,
boolean updateColors)
Customize the color palette of the image with this intuitive method.
|
crop, getEmbeddedImages, getPageExportingAction, removeBackground, removeBackground, resize, resize, rotate, rotateFlip, setPageExportingActiongetDefaultOptions, getHeightF, getSizeF, getWidthFcanLoad, canLoad, canLoad, canLoad, canSave, create, create, create, create, create, create, crop, getBackgroundColor, getBounds, getBufferSizeHint, getContainer, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getIProgressEventHandler, getOriginalOptions, getPalette, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSerializedStream, getSize, hasBackgroundColor, isAutoAdjustPalette, isUsePalette, load, load, load, load, load, load, removeMetadata, resize, resizeHeightProportionally, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalettegetDataStreamContainer, save, save, saveclose, dispose, getDisposedpublic CdrImage(InputStream stream, LoadOptions loadOptions)
Start working with the CdrImage class effortlessly by
initializing a new instance with a stream and loadOptions parameters.
Ideal for developers seeking a convenient way to load CDR images from
various data sources while customizing the loading process as needed.
stream - The stream.loadOptions - The load options.com.aspose.ms.System.IndexOutOfRangeException - CDR document contains no pages.public CdrImage(com.aspose.ms.System.IO.Stream stream,
LoadOptions loadOptions)
@Deprecated public Image getDefaultPage()
Retrieve the default page of the image with ease using this user-friendly property. Perfect for developers seeking quick access to the primary page of their image, ensuring efficient navigation and management.
getDefaultPage in class VectorMultipageImagepublic boolean isCached()
Effortlessly determine whether the object's data is currently cached, eliminating the need for data reading. Ideal for developers seeking to optimize performance by leveraging cached data efficiently, ensuring faster access to object information.
isCached in class VectorMultipageImagetrue if object's data is cached; otherwise, false.public int getBitsPerPixel()
Retrieve the bit depth of the image effortlessly with this user-friendly property. Ideal for developers seeking to determine the level of detail or color depth present in their images, ensuring accurate processing and manipulation.
getBitsPerPixel in class VectorMultipageImagepublic final int getPageCount()
Effortlessly retrieve or update the total page count of the image with this intuitive property. Ideal for developers seeking to manage multipage images dynamically, ensuring efficient navigation and manipulation of image content.
getPageCount in interface IMultipageImagepublic final Image[] getPages()
Retrieve the pages of the image seamlessly with this intuitive property. Ideal for developers seeking to access and manipulate individual pages within multipage images, ensuring efficient navigation and processing.
getPages in interface IMultipageImageThe following example shows how to export a single page of CDR document to PDF.
int pageNumber = 0;
String dir = "c:\\aspose.imaging\\java\\issues\\1445'\\";
String inputCdrFileName = dir + "tiger.cdr";
String outputPdfFileName = dir + "tiger.cdr.page" + pageNumber + ".pdf";
com.aspose.imaging.fileformats.cdr.CdrImage image = (com.aspose.imaging.fileformats.cdr.CdrImage) com.aspose.imaging.Image.load(inputCdrFileName);
try {
com.aspose.imaging.Image imagePage = image.getPages()[pageNumber];
com.aspose.imaging.imageoptions.PdfOptions pdfOptions = new com.aspose.imaging.imageoptions.PdfOptions();
com.aspose.imaging.imageoptions.CdrRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.CdrRasterizationOptions();
rasterizationOptions.setTextRenderingHint(com.aspose.imaging.TextRenderingHint.SingleBitPerPixel);
rasterizationOptions.setSmoothingMode(com.aspose.imaging.SmoothingMode.None);
rasterizationOptions.setPageWidth(image.getWidth());
rasterizationOptions.setPageHeight(image.getHeight());
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
imagePage.save(outputPdfFileName, pdfOptions);
}
finally {
image.close();
}
public final CdrDocument getCdrDocument()
Effortlessly retrieve or update the CDR document using this intuitive property. Ideal for developers seeking to access or modify the CDR document, ensuring flexibility and efficiency in their applications.
getCdrDocument in interface ICdrImagepublic long getFileFormat()
Retrieve the file format of the image effortlessly with this intuitive property. Ideal for developers seeking to determine the format of their images dynamically, ensuring compatibility and accurate processing in their applications.
getFileFormat in class ImageFileFormatpublic int getWidth()
Gets the image width.
Value: The image width.getWidth in interface IObjectWithBoundsgetWidth in class VectorMultipageImagepublic int getHeight()
Gets the image height.
Value: The image height.getHeight in interface IObjectWithBoundsgetHeight in class VectorMultipageImagepublic void cacheData()
Effortlessly cache the data to prevent additional loading from the underlying source
with this user-friendly method. Ideal for developers seeking to optimize performance
by preloading data, ensuring faster access and smoother operation in their applications.
DataStreamSupporter.DataStreamContainer(DataStreamSupporter.getDataStreamContainer()/DataStreamSupporter.setDataStreamContainer_internalized(StreamContainer)).
cacheData in class VectorMultipageImageThe following example shows how to cache all pages of a CDR image.
String dir = "c:\\temp\\";
// Load an image from a CDR file.
com.aspose.imaging.fileformats.cdr.CdrImage image = (com.aspose.imaging.fileformats.cdr.CdrImage) com.aspose.imaging.Image.load(dir + "sample.cdr");
try {
// This call caches only the default page.
image.cacheData();
// Cache all pages so that no additional data loading will be performed from the underlying data stream.
for (com.aspose.imaging.fileformats.cdr.CdrImagePage page : image.getPages()) {
page.cacheData();
}
} finally {
image.dispose();
}
public void setPalette(IColorPalette palette, boolean updateColors)
Customize the color palette of the image with this intuitive method. Ideal for developers seeking to apply specific color schemes or adjustments dynamically, ensuring precise control over the visual appearance of their images.
setPalette in class VectorMultipageImagepalette - The palette to set.updateColors - if set to true colors will be updated according to the new palette; otherwise color
indexes remain unchanged. Note that unchanged indexes may crash the image on loading if some indexes have no
corresponding palette entries.com.aspose.ms.System.NotImplementedException - method is not supportedCopyright (c) 2008-2025 Aspose Pty Ltd. All Rights Reserved.