Dear Aspose Team,
Hi,
Hi,
Hi again,
Hello Amjad,
I made some tests and I concluded to the following:
1) when I use save method on the workbook
workbook.save(workbookFilePath, SaveFormat.TIFF);
I get a multipaged tiff file but quality is low.
2) when I use the code you provided I get separate tiff files for each workbook, which I then zip together into one zip file.
So I think the solution you provided is very nice. I tested it on some sample excel files and I came now into another issue related to the tiff file being truncated.
Please find attached the source file and the resulting tiffs. The first two tiff files that correspond to the first two workbook sheets are OK. The third tiff file corresponding to the third sheet is truncated. You think you can help me or should I open another issue?
Please find attached my input excel file and output zip file.
My code:
Workbook workbook = new Workbook( file.getAbsolutePath() );
// Low quality multipage tiff
// String workbookFilePath = getConvertedTiffFile( file ).getAbsolutePath();
// workbook.save(workbookFilePath, SaveFormat.TIFF);
//Produce ZIP of TIFFS when there are multiple WorkSheets and/or Pages
if ( isMultiPageTiff(workbook) ) {
System.out.println(“ZIP of TIFFS”);
short part = 1;
List fileList = new ArrayList();
File baseDirectory = getZipDirectoryName();
for(int idx = 0; idx<workbook.getWorksheets().getCount(); idx ++) {
Worksheet sheet = workbook.getWorksheets().get( idx );
System.out.println(“sheet” + (idx+1) + “/” + workbook.getWorksheets().getCount());
ImageOrPrintOptions imgOptions = getImageOptions();
SheetRender sr = new SheetRender(sheet, imgOptions);
for(int i = 0;i<sr.getPageCount();i++) {
System.out.println(“page” + (i+1) + “/” + sr.getPageCount() );
//Create a file inside ‘baseDirectory’ folder
convertedFile = getSplitFileName( getSplitFilePrefix(), baseDirectory, part );
fileList.add(convertedFile);
//write into this file one part of the PDF
sr.toImage(i, convertedFile.getAbsolutePath() );
part++;
}
}
//zip files
convertedFile = getConvertedZIPFile( file );
//zip folder named ‘baseDirectory’ into a file named ‘convertedFile’
ZipUnzipHelper.zipFile( baseDirectory, convertedFile );
private ImageOrPrintOptions getImageOptions() {
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.setHorizontalResolution( 400 );
imgOptions.setVerticalResolution( 400 );
imgOptions.setOnePagePerSheet( true );
imgOptions.setImageFitToPage( false );
imgOptions.setTiffCompression(TiffCompression.COMPRESSION_CCITT_4);
imgOptions.setImageFormat(ImageFormat.getTiff());
return imgOptions;
}
Hi,
GSComponent:
1) when I use save method on the workbook
workbook.save(workbookFilePath, SaveFormat.TIFF);
I get a multipaged tiff file but quality is low.
Dear Amjad,
Your advice helped a lot!
Thank you very much for all your support!
Best Regards,
–George Souliotis