I did test your scenario/case using the following sample code (as we suggested earlier) with your template XLSX file and you are right. The image is rendered with 96 DPI. We will be looking into it soon.
int desiredResolution = 72;
Workbook wb = new Workbook("f:\\files\\SampleWorkbook.xlsx");
Worksheet sheet = wb.getWorksheets().get(0);
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setTopMargin(0);
pageSetup.setBottomMargin(0);
pageSetup.setLeftMargin(0);
pageSetup.setRightMargin(0);
String rangeName = "A1:P37";
pageSetup.setPrintArea(rangeName);
ImageOrPrintOptions imgOpt = new ImageOrPrintOptions();
imgOpt.setOnePagePerSheet(true);
imgOpt.setImageType(ImageType.EMF);
imgOpt.setTransparent(true);
imgOpt.setHorizontalResolution(desiredResolution);
imgOpt.setVerticalResolution(desiredResolution);
SheetRender sr = new SheetRender(sheet, imgOpt);
sr.toImage(0, "f:\\files\\output.emf");
I got the right output EMF image (check the output image) with complete printable area after generating it by the above code segment. I am using latest version of the API (Aspose.Cells for Java v24.1), so you should try it if you are not already using it.
Using the lastest version v24.1, the resolution of output EMF image is the right value 72. Please check the result EMF image generated by @amjad.sahi .
The resolution in âMS Paintâ is the deviceâs DPI, not the resolution of the EMF image. e.g. you can change display setting in Winodows->Settings of your machine. The resolution in âMS Paintâ changes for the same EMF image.(96 for 100% display setting, 192 for 200% setting.)
I use âMicrosoft Office Pictureâ, the resolution is 72. resolution_72.png (27.4 KB)
This is to inform you that the issue (logged earlier as âCELLSJAVA-45828â) has been resolved. The fix/enhancement will be included in the upcoming release (Aspose.Cells v24.2) that we plan to release in the next week hopefully. You will be notified when the next version is released.
We were able to validate the fix for CELLSJAVA-45828 with ASPOSE CELLS v24.10 and notice that the EMF output size has reduced drastically from 1.22mb to 446kb using the below sample code.
Is it possible to reduce the EMF output size further?
Does this logic sr.toImage(0, "SampleWorkbook.emf") convert the workbook to SVG first and then EMF? Reason for asking is we noticed the EMF output has 72 DPI set(based on above sample code) when previewed using an image viewer but when using ASPOSE WORDS JAVA library to generate the same EMF output we noticed that it does not support resolution because EMF is a vector image.
No, both SVG and EMF are vector images. We convert workbook to EMF directly.
According to MS-EMF specification, we specify the last two properties Device (8 bytes) and Millimeters (8 bytes) that control the horizontal/vertical resolution displayed in some image viewers.
To investigate the possibility to reduce the file size of generated Emf image further, we have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSJAVA-46183
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.