Hi everybody,
here we have a xlsx witch causes an error in aspose.cells when converting to PDF.
This worked in 18.4 but now in 19.1 it comes to the error.
Here the code to reproduce it:
import com.aspose.cells.PdfSaveOptions;
import com.aspose.cells.SaveOptions;
import com.aspose.cells.Workbook;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.UUID;
public class Main {
private final ClassLoader classLoader = getClass().getClassLoader();
private final File tmpFolder = new File(System.getProperty("java.io.tmpdir"));
public static void main(String[] args) {
try {
System.out.println("Convert xlsx to PDF");
new Main().createsPdfFromXlsx_onlyConvertToPdf();
System.out.println("Success");
} catch (Exception e) {
System.out.println("Failed to convert xlsx to PDF ");
e.printStackTrace();
}
}
/**
* This error does NOT occur with aspose.cells 18.4
* 18.8, 19.1 and 19.2 tested - all causing an exception
*
* com.aspose.cells.CellsException: Shape to image Error!
* at com.aspose.cells.zax.a(Unknown Source)
* at com.aspose.cells.zax.a(Unknown Source)
* at com.aspose.cells.zax.a(Unknown Source)
* at com.aspose.cells.zax.a(Unknown Source)
* at com.aspose.cells.zax.b(Unknown Source)
* at com.aspose.cells.zax.c(Unknown Source)
* at com.aspose.cells.zax.a(Unknown Source)
* at com.aspose.cells.a.d.zfs.a(Unknown Source)
* at com.aspose.cells.zcbk.a(Unknown Source)
* at com.aspose.cells.zcbk.a(Unknown Source)
* at com.aspose.cells.zcbk.a(Unknown Source)
* at com.aspose.cells.zjk.a(Unknown Source)
* at com.aspose.cells.Workbook.a(Unknown Source)
* at com.aspose.cells.Workbook.save(Unknown Source)
*/
public void createsPdfFromXlsx_onlyConvertToPdf() throws Exception {
// Arrange
final InputStream originalDocument = classLoader.getResourceAsStream("./DEV-14626_forAspose.xlsx");
final File tempPdfFile = new File(tmpFolder.getAbsolutePath() + "/" + UUID.randomUUID().toString() + ".pdf");
final FileOutputStream fileOutputStream = new FileOutputStream(tempPdfFile);
Workbook doc = new Workbook(originalDocument);
SaveOptions saveOptions = new PdfSaveOptions();
// Act
// -- this causes a CellsException
doc.save(fileOutputStream, saveOptions);
// Assert
System.out.println("Saved pdf here: " + tempPdfFile.getAbsolutePath());
// ...
}
}
Here is the main-class to reproduce the issue with the xlsx-file.
MainAndXlsx.zip (222.9 KB)
We are using Java 1.8.
Can you tell us where the problem is?
If you need more information, just let me know.
Thank you and best regards