Hello Aspose Team,
I am currently using Aspose.Words 25.1.0, where converting SVG/WMF/EMF images to PNG with higher resolution works correctly. Below is the callback code I am using. In version 25.1.0, the resolution enhancement works as expected.
class ImageSavingCallback : IImageSavingCallback
{
private String _imagesFolder;
public ImageSavingCallback(String imagesFolder)
{
_imagesFolder = imagesFolder;
Directory.CreateDirectory(_imagesFolder);
}
public void ImageSaving(ImageSavingArgs args)
{
var shape = args.CurrentShape as Shape;
if (shape == null || !shape.HasImage)
return;
var imgType = shape.ImageData.ImageType;
bool isVector = imgType == ImageType.Wmf ||
imgType == ImageType.Emf ||
imgType == ImageType.Eps;
string imgFileName = args.ImageFileName;
string imgFilePath = Path.Combine(_imagesFolder, imgFileName);
if (isVector)
{
float resolution;
double imgDpi = shape.ImageData.ImageSize?.HorizontalResolution ?? 96;
resolution = Math.Max((float)imgDpi, 300);
imgFileName = Path.ChangeExtension(imgFileName, ".png");
imgFilePath = Path.Combine(_imagesFolder, imgFileName);
ShapeRenderer renderer = new ShapeRenderer(shape);
var imgSaveOptions = new ImageSaveOptions(SaveFormat.Png)
{
Resolution = resolution,
HorizontalResolution = resolution,
VerticalResolution = resolution,
Scale = Math.Min(3.0f, (float)imgDpi / 96),
ImageColorMode = ImageColorMode.None,
PixelFormat = ImagePixelFormat.Format32BppArgb,
UseAntiAliasing = true,
UseHighQualityRendering = true
};
renderer.Save(imgFilePath, imgSaveOptions);
args.ImageFileName = imgFileName;
args.ImageStream = Stream.Null;
args.KeepImageStreamOpen = false;
}
else
{
args.ImageStream = new FileStream(imgFilePath, FileMode.Create);
args.KeepImageStreamOpen = false;
}
}
}
Now I am trying to use the same approach in Aspose.Words 19.2.0, but the resolution does not improve the way it does in version 25.1.0. The exported PNG images appear blurry, and DPI-related options do not seem to be applied.
Could you please clarify the following:
- Does Aspose.Words 19.2.0 support high-resolution rasterization for vector images (SVG/WMF/EMF)?
- Are features such as
Scale, UseHighQualityRendering, and 32-bit PixelFormat supported in version 19.2.0?
- Is there any recommended workaround to enhance image resolution in the older version?
- Could you provide the official documentation link for Aspose.Words 19.2.0?
@cosmicboy
Overview
The behavior you see in Aspose.Words 25.1.0 (high‑resolution rasterisation of SVG/WMF/EMF via ShapeRenderer and the ImageSaveOptions you set) was introduced after version 19.2.0.
In Aspose.Words 19.2.0:
| Feature |
Availability in 19.2.0 |
High‑resolution rasterisation of vector images (ability to set Resolution, Scale and get a crisp PNG) |
Not supported. Vector shapes are rasterised at the default 96 dpi. |
Scale property on ImageSaveOptions |
Absent – the property does not exist in this version. |
UseHighQualityRendering |
Absent – the rendering engine used the legacy rasteriser. |
32‑bit PixelFormat (e.g., Format32BppArgb) |
The PixelFormat enum exists, but the rasteriser ignores it for vector shapes; only 24‑bit output is produced. |
ShapeRenderer class |
Introduced in later builds (≈ 22.x). 19.2.0 does not expose it. |
Therefore the callback code that works in 25.1.0 cannot achieve the same result in 19.2.0.
Answers to Your Specific Questions
-
High‑resolution rasterisation for SVG/WMF/EMF in 19.2.0?
No. The engine rasterises vector shapes at the default screen resolution (96 dpi). DPI‑related options are ignored for these image types.
-
Support for Scale, UseHighQualityRendering, 32‑bit PixelFormat?
These members were added in later releases. In 19.2.0 they either do not exist or have no effect on vector shape rendering.
-
Work‑around for the older version
-
Upgrade – The simplest and recommended solution is to upgrade to a newer Aspose.Words version (≥ 22.5) where the high‑quality rasterisation API is fully available.
-
Intermediate PDF route – Export the document (or the specific shape) to PDF using doc.Save(..., SaveFormat.Pdf), then use Aspose.Pdf (or any PDF rasteriser) to convert the PDF page/segment to a PNG with the desired DPI. This gives you control over resolution but introduces an extra step.
-
Custom rendering via System.Drawing – Extract the vector image (e.g., shape.ImageData.ToString() for EMF/WMF) and render it with System.Drawing.Graphics onto a Bitmap that you create at the required size/DPI. This requires manual handling of the vector format and is not officially supported by Aspose.Words 19.2.0.
-
Replace with raster images – If the source SVG/WMF can be supplied already rasterised at the desired resolution, embed those raster images directly in the document.
-
Documentation for Aspose.Words 19.2.0
The above links contain the classes and members that were present in the 19.2.0 release.
Recommended Next Steps
-
Evaluate upgrade feasibility – Moving to the latest stable version (currently 25.x) gives you the ShapeRenderer‑based workflow you already have, with many bug‑fixes and performance improvements.
-
If upgrade is not possible now, choose one of the work‑arounds described above (PDF conversion is the most reliable without writing custom rendering code).
-
Test DPI after work‑around – When using Aspose.Pdf, you can set Resolution or PageInfo.Width/Height to control the output size, e.g.:
// Export to PDF (19.2)
doc.Save("tmp.pdf", SaveFormat.Pdf);
// Convert PDF page to PNG at 300 DPI (Aspose.Pdf)
var pdfDoc = new Aspose.Pdf.Document("tmp.pdf");
var resolution = new Aspose.Pdf.Devices.Resolution(300);
var pngDevice = new Aspose.Pdf.Devices.PngDevice(resolution);
pngDevice.Process(pdfDoc.Pages[1], "output.png");
This yields a crisp PNG comparable to the output of the newer ShapeRenderer path.
Feel free to ask
If you need a code sample for the PDF‑to‑PNG route, or if you encounter any issues while testing the work‑around, let us know and we’ll provide a detailed example.
@cosmicboy Fist of all, why do you need to downgrade to 19.2 version of Aspose.Words? You should note we do not provide any fixed or patches for old versions of Aspose.Words. All fixes and improvements in the library are shipped with new versions. So old versions are provided as is.
As far I know, there is no limitation in high-resolution rasterization for vector images in 19.2 version.
All mentioned properties are available in 19.2 version of Aspose.Words.
There are no specific recommendations.
You can get CHM offline documentation for old version of Aspose.Words from MSI package. For your convenience I am attaching CHM for 19.2 version of Aspose.Words: Words.Help.Words19.2.chm.zip (2.9 MB)