We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Question about extracting vector image from excel

Hi,


I am using Aspose Cells for Java version 7.7.1.5.

I extracted emf image from excel and then put it back to that file, but I can see the fonts are slightly different (attaching the file). What is the reason for such behaviour? Is it possible to extract the image so that it looks exactly the same as the original image in the Excel file?

Thanks,
Krzysztof Pawlowski

Hi,


Well, you may try to use anti-aliasing for the rendered WMF image a bit, it works ok, see the sample code below for your reference:
e.g
Sample code:

String filePath = “Test.xlsx”;


//Load the source workbook

Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.getWorksheets().get(0);


Picture pic = worksheet.getPictures().get(0);


ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageFormat(ImageFormat.getWmf());

options.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

options.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

pic.toImage(filePath + “.out2.wmf”, options);

worksheet.getPictures().add(3, 9, filePath + “.out2.wmf”);

workbook.save(“out1.xlsx”);

Hope, this helps a bit.

Thank you.

No difference at all after switching antialiasing on. Also, I used emf format - not wmf.

Hi,


I observed the issue while extracting EMF image and then put it back to Excel file, I can see the fonts are slightly different if we compare them with the original picture.
e.g
Sample code:

String filePath = “Test.xlsx”;


//Load the source workbook

Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.getWorksheets().get(0);


Picture pic = worksheet.getPictures().get(0);


ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageFormat(ImageFormat.getEmf());

pic.toImage(filePath + “.out1.emf”, options);

worksheet.getPictures().add(3, 9, filePath + “.out1.emf”);

workbook.save(“outTest1.xlsx”);

I have logged a ticket with an id “CELLSJAVA-40786” for your issue. We will look into it to figure it out soon.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-40786) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi,

We recommend you to kindly try the following code segment to cope with your issue.
e.g
Sample code:

String dir = "D:/tmp/";
String filePath = "Test.xlsx";
Workbook workbook = new Workbook(dir + filePath);

Worksheet worksheet = workbook.getWorksheets().get(0);

Picture pic = worksheet.getPictures().get(0);

ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageFormat(ImageFormat.getEmf());

byte[] imgOriginalData = pic.getData();
InputStream is = new ByteArrayInputStream(imgOriginalData);

worksheet.getPictures().add(3, 9, is);

workbook.save(dir + "outTest1.xlsx");

Let us know if you still have any issue.

Thank you.