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

Free Support Forum - aspose.com

AsposeBaseException when converting xlsx to pdf

Hi

Today i 've downloaded the latest version of Apose.Total for Java and now i’m trying to convert simple xlsx file to pdf. Using JDK6 on Windows 7. Running this code i’ll get the following error:

Exception in thread “main” com.aspose.pdf.exception.AsposeBaseException: null
at com.aspose.pdf.elements.Section.a(Unknown Source)
at com.aspose.pdf.elements.Pdf.if(Unknown Source)
at com.aspose.pdf.elements.Pdf.a(Unknown Source)
at com.aspose.pdf.elements.Pdf.save(Unknown Source)
at ch.tie.pdf.Main.main(Main.java:41)

Here is my code:

import com.aspose.cells.Cells;
import com.aspose.cells.FileFormatType;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.aspose.cells.Worksheets;
import com.aspose.pdf.elements.Pdf;
import com.aspose.pdf.exception.AsposeBaseException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;

public class Main {

private final static File WORKING_DIR = new File(“C:\Users\ralf\Desktop\PDF”);
private final static File LICENCE_FILE = new File(WORKING_DIR, “Aspose.Total.Java.lic”);

public static void main(String[] args) throws IOException, AsposeBaseException,
ParserConfigurationException, SAXException, Exception {

new com.aspose.pdf.License().setLicense(new FileInputStream(LICENCE_FILE));
new com.aspose.cells.License().setLicense(new FileInputStream(LICENCE_FILE));

Workbook workbook = new Workbook();
File xmlFile = new File(WORKING_DIR, “test.xml”);

Worksheets worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.getSheet(0);
sheet.setName(“Product List”);
Cells cells = sheet.getCells();
for (int i = 0; i < 20; i++) {
cells.getCell(i, i).setValue(i);
}
workbook.save(new File(WORKING_DIR, “test.xlsx”).getPath(), FileFormatType.EXCEL2007);
workbook.save(xmlFile.getPath(), FileFormatType.ASPOSE_PDF);

Pdf pdf = Pdf.bindXML(new FileInputStream(xmlFile));
pdf.save(new FileOutputStream(new File(WORKING_DIR, “test.pdf”)));
}
}

What’s wrong???
Thanks in advance.

Regards
Ralf

Hello Ralf,

Thanks for considering Aspose.

Can you please share the resource XLSX file that you're using so that we can test the scenario at our end.

We apologize for your inconvenience.

Hi Nayyer


The XLSX will be generated via java code i sent you in my last post, so you will be able to reproduce it.

Regards
Ralf

Hello Ralf,

Sorry for replying you late.

I've tried to generate the XLSX file using the code snippet that you've shared and I'm very sorry to inform that I'm unable to generate it. I've tried to correct the issues, but still couldn't find the workaround for that. I'm facing issue while generating XLSX file and it's not related to PDF generation.

Instead of spending more time while rectifying the issues, I thought of asking from you to share the file that you've generated.

We apologize for your inconvenience.

Hi Nayyer

Here is the XSLX file.

Regards
Ralf


Hello Ralf,

Thanks for sharing the resource file.

I've tested the scenario using Aspose.Pdf for Java 2.4.3 and Aspose.Cells for Java 2.1.1 with JDK 1.6 Update 6 on Windows 7 Ultimate and I'm unable to notice the problem. The resultant PDF is being generated without any issue. I've also attached the resultant PDF, please take a look.

Aspose.Pdf for Java 2.4.3.2 is also in attachment. Download Aspose.Cells for Java 2.1.1 from here

FYI, I've also tested the scenario over Windows XP and I'm also unable to notice the issue over it.

Hi Nayyer

Thanks for your research. Now our solution is running and i found the reason for my error: there is a gap in your software packages.

The current version of Aspose.Pdf for Java is 2.4.3.2 and this code works well.
But the current Aspose.Total for Java contains Aspose.Pdf for Java 2.4.0.0, which seems to be buggy.
Please can you check this?

Regards
Ralf

Hello Ralf,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Aspose.Pdf for Java 2.4.3.2 is the latest hotfix, whereas in Aspose.Total for Java, the earlier release of Aspose.Pdf for Java 2.4.0 is included. Please try using the latest hotfix and in case you face any further problem, please feel free to contact.