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

Free Support Forum - aspose.com

Evaluation Only does not go away

Hi there.

I have a Aspose.Total.Java licence, but the ‘Evaluation Only. Created with Aspose.Pdf for Java. Copyright 2002-2010 Aspose Pty Ltd’ does not go away on xls and xlsx conversions. It does work on doc and docx though.

Below it the code snippet. Can you please assists?

private File xlsToPDF(byte[] inputDocument, String fileName) throws IOException, AsposeLicenseException
{
File tmpFile = createTempPDF(fileName);
File xmlFile = createTempXML(fileName);


try
{
com.aspose.cells.License cellLic = new com.aspose.cells.License();
cellLic.setLicense(new FileInputStream(“Aspose.Total.Java.lic”));
Pdf.setLicense(“Aspose.Total.Java.lic”);
Workbook workbook = new Workbook();
workbook.open(new ByteArrayInputStream(inputDocument));
workbook.save(xmlFile.getAbsolutePath(), FileFormatType.ASPOSE_PDF);

Pdf pdf = new Pdf();

pdf.bindXML(xmlFile.getAbsolutePath(), null);

pdf.save(tmpFile.getAbsolutePath());
}
finally
{
if(xmlFile != null)
xmlFile.delete();
}


return tmpFile;
}
Thank you

Hi,

Thank you for the post. Well, for every Aspose product, License class needs to be instantiated separately. For example, in case of Aspose.Cells and Aspose.Pdf, the following sequence of statements should work fine:

com.aspose.cells.License cellsLic=new com.aspose.cells.License();
aspose.pdf.License pdfLic=new aspose.pdf.License();
try {
cellsLic.setLicense(new FileInputStream(“d:\Aspose.Total.Java.lic”));
pdfLic.setLicense(new FileInputStream(“d:\Aspose.Total.Java.lic”));
//
//statements
//
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AsposeLicenseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Please try to follow the above approach. If problem persists, share your license file by following the instructions here.

Hi,

Also, we would like to inform you that in Aspose.Cells for Java (Latest Version) we have introduced Direct conversion approach where you are not required to use Aspose.Pdf for Java or its API any longer, so, you may use that version with the following sample code:

e.g

com.aspose.cells.License cellLic = new com.aspose.cells.License();

cellLic.setLicense(new
FileInputStream(“Aspose.Total.Java.lic”));

Workbook
workbook = new Workbook();
workbook.open(“c:\MyFile.xls”);

workbook.save(“c:\MyPdfFile.pdf”, FileFormatType.PDF);

See the document for your further reference:
Convert Excel file to PDF format compatible with PDFA-1a

Thank you.

Hi

Thanks for the reply we have managed to solve that particular issue by rolling back to 1.4 on the pdf (license issue) api. We have implemented the code as specified above which resolved a header issue we had. We are now getting the following error on the xls document attached (BUG_788_Survey For Amanda
van Vuuren.xlsx)

java.io.IOException: Invalid column index: 16384
at com.aspose.cells.Workbook.save(Unknown Source)

Here is the code snippet we are using which is throwing the error:

inputStream = new ByteArrayInputStream(inputDocument);

Workbook workbook = new Workbook();
workbook.open(inputStream);

for (byte count = 0; count < workbook.getWorksheets().size() ; count++)
{
Worksheet sheet = workbook.getWorksheets().getSheet(count);

com.aspose.cells.PageSetup pageSetup = sheet.getPageSetup();
//Setting the orientation to Portrait
pageSetup.setOrientation(PageOrientationType.PORTRAIT);
//pageSetup.setFitToPagesTall(1);
pageSetup.setFitToPagesWide(1);
//pageSetup.
pageSetup.setPaperSize(PaperSizeType.PAGE_A4);
}


//Setting the paper size to A4
workbook.save(tmpFile.getAbsolutePath(), FileFormatType.PDF);

again thank you for your replay and assistance.

Liwies

Hi Liwies,

The issue has been found with the attached XLSX file when exported to PDF. The issue has been logged into our Issue Tracking System as 18096. This thread has been linked with the issue.

We will update you once there is any update regarding this issue.

Best Regards

Hi,

We have fixed the issue of “Invalid
column index” for direct xls2pdf feature. Please try the attached version.

Thank you.

Hi

We tried the above suggestion and although the error isn’t thrown anymore a blank document with just the gridlines and columns showing. Please see attached pdf result.

Thanks

Hi,

Well, we tested the conversion using your template file and it works fine, I can get 11 pages in total same as MS Excel print preview. I have attached my generated file using the following code with v2.3.0.3.
Sample code:
Workbook workbook = new Workbook();
workbook.open(“d:\files\BUG_788_Survey+For+Amanda+van+Vuuren.xlsx”,FileFormatType.EXCEL2007);
workbook.save(“d:\files\myoutputFile.pdf”, FileFormatType.PDF);

Could you give us more details about the issue, are you using the same template file or other, please give us also other information such us, the locale settings, os, jdk version and so on.

Thank you.

Hi

We are running the code on Win XP SP3, JDK 1.6. We are using the same template as provided.

We also cannot convert doc, docx, xls, xlsx, ods and odt files on a Max (OS X). Do we need different API’s for Mac? I have attached the files that aren’t converting on a Mac. The conversions work for all file types on a windows box but not for Mac.

This is the code we call to convert xls, xlsx and ods

File tmpFile = createTempPDF(fileName);
File xmlFile = createTempXML(fileName);
InputStream inputStream = null;
Pdf pdf = null;
try
{
inputStream = new ByteArrayInputStream(inputDocument);

Workbook workbook = new Workbook();

workbook.open(inputStream, excelSpecType);

//System.out.println("Workbook type: " + workbook.getFileFormatType());

for (byte count = 0; count < workbook.getWorksheets().size(); count++)
{
Worksheet sheet = workbook.getWorksheets().getSheet(count);

com.aspose.cells.PageSetup pageSetup = sheet.getPageSetup();
// Setting the orientation to Portrait
pageSetup.setOrientation(PageOrientationType.PORTRAIT);
// pageSetup.setFitToPagesTall(1);
pageSetup.setFitToPagesWide(1);
// pageSetup.
pageSetup.setPaperSize(PaperSizeType.PAGE_A4);
}

// Setting the paper size to A4
workbook.save(tmpFile.getAbsolutePath(), FileFormatType.PDF);



and this is for the doc, docx and odt file types


Document doc = new Document(new ByteArrayInputStream(inputDocument));
// removeWatermark(doc);
File tmpFile = createTempPDF(fileName);

OutputStream outputStream = new FileOutputStream(tmpFile);

try
{
PdfOptions options = new PdfOptions();
options.setHeadingsOutlineLevels(3);
options.setExpandedOutlineLevels(1);

// Aspose.Words for Java requires that you specify the true type
// fonts
// directory explicitly before attempting to convert any documents
// to
// PDF.
// It does not have to be an OS fonts folder. You can create your
// own
// folder and copy all the fonts there you think might ever be
// required.
// options.setTrueTypeFontDirectory(“/usr/share/fonts/ttf”);F
doc.saveToPdf(0, doc.getPageCount(), outputStream, options);
}
finally
{
try
{
if (outputStream != null) outputStream.close();
}
catch (Exception e)
{
}
}

tmpFile = compressPDF(tmpFile, fileName);

return tmpFile;

Hi,

We will look into the issue (converting .xls, xlsx and ods file to pdf), we need to simulate the envirorment for MAC. We will check it and get back to you soon.

For the issue regarding the conversion of docx and odt files to pdf please do post a query with your details and attachments to Aspose.Words forum.

Thank you.

Hi,

We have tested your template files and found the pdf files can be created well in Mac environment when all fonts that are used in the template files exist in the correct font path. Please make sure that all the fonts that are used in the template files exist in the specified font path. To specify the font path, please use workbook.getSaveOptions().setFontPath(String[] fontpath).
Thank you

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


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