Hi,
I am unable generate custom-size thumbnail from an Xps file using Aspose.Page 24.1 version.
I tried setting size using ImageDevice as below,
// Create an instance of PNGSaveOptions
com.aspose.xps.XpsDocument document = new com.aspose.xps.XpsDocument(sourceFilePath);
com.aspose.xps.rendering.PngSaveOptions pngSaveOptions = new com.aspose.xps.rendering.PngSaveOptions();
pngSaveOptions.setSmoothingMode(SmoothingMode.HighQuality);
pngSaveOptions.setResolution(300);
pngSaveOptions.setPageNumbers(new int[] { 1 });
// Create rendering device for XPS format
ImageDevice device = new ImageDevice();
device.setSize(new Dimension(216, 288));
// Save XPS as PNG
document.save(device, pngSaveOptions);
// Iterate through document partitions (fixed documents, in XPS terms)
for (int i = 0; i < 1; i++) {
// Iterate through partition pages
for (int j = 0; j < device.getResult()[i].length; j++) {
// Initialize image output stream
FileOutputStream imageStream = new FileOutputStream(outputFilePath);
// Write image
imageStream.write(device.getResult()[i][j], 0, device.getResult()[i][j].length);
// Close the Stream
imageStream.close();
}
}
However, the dimensions of the generated png do not match to that I have set.
Here is the input .xps file I have used and its output png,
XPS_to_PNG.zip (1.9 MB)