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

Free Support Forum - aspose.com

Excel file does not convert to PDF

I use this version, aspose-cells-7.5.3.jar to convert simple excel file to pdf file.
It is ok in window 7 but got this error message in

Apache Tomcat/7.0.30 1.6.0_35-b10-428-11M3811 Apple Inc. Mac OS X 10.8.2 x86_64

com.aspose.cells.CellsException: File path can't be "". at com.aspose.cells.bdg.a(Unknown Source) at com.aspose.cells.Workbook.a(Unknown Source) at com.aspose.cells.Workbook.save(Unknown Source) at com.all.crm.service.ConvertOthersToPDF.xlsToPdf(ConvertOthersToPDF.java:276) at com.all.crm.service.ConvertOthersToPDF.process(ConvertOthersToPDF.java:98) at

My logic is below.

public void xlsToPdf() {
// TODO Auto-generated method stub
//Instantiate a Presentation object that represents a PPT file
try {

sheetNames = new ArrayList();
//Initialize a new Workbook
//Open an Excel file
Workbook workbook = new Workbook(baseFolder+ fileName);

WorksheetCollection worksheets = workbook.getWorksheets();

ArrayList subEntryList = new ArrayList();
//Create the PdfBookmark entry object.
PdfBookmarkEntry pbeRoot = new PdfBookmarkEntry();
//Set the bookmark collapsed.
//Set its text.
Cell cellInPage = null;
Row row = null;
//Set its destination source page.
PdfBookmarkEntry subPbe = null;
for ( int i = 0; i < worksheets.getCount(); i++ ) {
Worksheet worksheet = worksheets.get(i);
cellInPage = getFirstNotHiddenCell(worksheet);
//Add another PdfBookmark entry object.
subPbe = new PdfBookmarkEntry();
//Set its text.
String sheetName = worksheet.getName();
if ( sheetName == null || sheetName.equals("") ) {
sheetName = "Sheet " + (i+1);
//Set its destination source page.

//Add the entry objects to it.



//Implement one page per worksheet option
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
//Set the pdf bookmarks, you need to specify the root object here.

///Save the pdf file
log.info("baseFodler filename="+this.baseFolder + pdfFileName);
workbook.save(this.baseFolder + pdfFileName, pdfSaveOptions);
//Save only one current worksheet
//workbook.save(baseFolder + pdfFileName, FileFormatType.PDF);
} catch ( Exception ex ) {
errorMessages.append(LF+"xlsToPdf error="+ex.getMessage());
log.info("xlsToPdf(),ex=" + MyUtil.exceptionLog(ex));
} // end of xlsToPdf


Thanks for sharing the sample files and code.

I have tested your scenario / case using your sample code (I have to modify a bit to execute it accordingly) on Win8 with JDK1.7.x using our latest v7.5.3, it works fine. For the sake of investigation, I have logged a ticket with an id “CELLSJAVA-40614” for your issue. We will evaluate your issue as you are finding the issue on Mac OS (with your mentioned environment). We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

We have evaluated your issue further. As per your line of code:
pdfSaveOptions.setCompliance(1); ---- when this option set to 1, the Pdf must have embedded fonts, so you must set fonts directory to generate PDF.
You have two options to solve this issue:

1) set font directory -- You may use the line at the start
2) remove this line of code: pdfSaveOptions.setCompliance(1);

Let us know if it works fine now.

Thank you.

We don’t know the stringFontDirPath.
How do we know the path?

Chang Shin


Well, you have to use your own JAVA code to get the fonts folder path, e.g
On Windows you may try to use:
System.out.println( FontManager.getFontPath( true ) ); // C:\WINDOWS\Fonts

While on MAC OS, there are two paths (folders) for fonts, e.g /Library/Fonts and /System/Library/Fonts. etc.

Alternatively you may try to remove the line of code:

Thank you.

Window is ok without setting path.
So, I will test it on Mac OS and then let you know.

Chang Shin

We are also facing a similar issue in a Linux environment (receiving the following when attempting to convert from an xls file to PDF: com.aspose.cells.CellsException: File path can’t be “”.
at com.aspose.cells.zbuz.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)).

we are setting compliance as follows:

and get the error on workbook save:
workbook.save(tempFile.getPath(), saveOptions);

So would the compliance setting above also force the need to add the font path?

Hi Mike,

Please try setting the font directory using the CellsHelper.setFontDir method at very start of your application, that is, before initializing any of the Asposr.Cells’ objects. Moreover the path you specify in aforesaid method should contain TTF files.

thank you for the very quick response on this. Is it just the setting of PDFCompliance that’s forcing the need to supply the font directory? If so, I believe we can remove this setting…

Hi Mike,

In order to understand this scenario further, here are some insights.

First of all, please note that the PDF/A-1b compliance specifications require the font to be embedded in the PDF. We suggest you to check the PDF/A-1b compliance specifications from internet to get a better understanding. From Aspose.Cells’ perspective, the previous releases of the API require the explicit setting of the font directory because the API was not capable of searching the fonts on Linux machine therefore the said exception can only occur when the API is not able find the fonts to render a particular glyph. However, in recent releases, the API searches the regular font directories on Linux machines to find the suitable fonts therefore the said exception should not occur even though you are not setting the font directory in your code or through JVM arguments because if the API is not able to find the exact font (used in the spreadsheet), it will substitute the font with the one available at the time of rendering. You may give the latest version of Aspose.Cells for Java a try on your side in reference to the aforementioned discussion.

Please go through the detailed articles to better understand the usage scenarios of TrueType fonts when rendering spreadsheets with Aspose.Cells for Java API .

Thanks for the clarification and quick response - I will try again with the latest version of Aspose.Cells

Hi Mike,

Sure, please give a try to the latest version, and feel free to contact us back in case you face any difficulty or have more questions for us.