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

Free Support Forum - aspose.com

Image distorted while converting excel to pdf

Both excel and PDF files are attached, please check issue docuIssues.zip (2.2 MB)
ment with screenshots001_Garment_Specification_85800_04082018_1116.zip (506.9 KB)


For your 001_Garment_Specification_85800_04082018_1116.xls

We were able to observe this issue and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will update you asap.

This issue has been logged as

  • CELLSJAVA-42582 - Image is distorted while converting Excel to Pdf

For your Copy of 001_Garment_Specification_12600_04092018_1241.xls

We have tested this issue with the following code using the most recent version i.e. 18.3.5 and found the output Pdf is good.


Workbook wb = new Workbook(in);

Download Link:
out2.pdf (1.9 MB)


As you suggested , we installed 18.3.5 still issue persist, also image quality (size) getting distorted, please take look at document.
Below is code for excel to PDF.
public static String convertExcelToPDF (String filePathStr){

	    Workbook workbook = null;
			com.aspose.cells.License license = new com.aspose.cells.License();
		if (License.isLicenseSet()) {
			    System.out.println("License is Set!***********");
			FontConfigs.setFontFolder("/usr/share/fonts/msttcore", true);
			workbook = new com.aspose.cells.Workbook(filePathStr);
			WorksheetCollection workSheetColl = workbook.getWorksheets();
			Worksheet specReport = workSheetColl.get(0);
			Worksheet revisionLogSheet = workSheetColl.get(1);
				Worksheet gtin = workSheetColl.get(2);
			PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
		   	workbook.save(filePathStr.split(".xls")[0]+".pdf", pdfSaveOptions);
		} catch (Exception e) {
		logger.debug("After conversion filePathStr*****"+ filePathStr.split(".xls")[0]+".pdf");
		return filePathStr.split(".xls")[0]+".pdf";

ImageIssue.zip (2.6 MB)


Thanks for using Aspose APIs.

Please try the following sample code and let us know if it generates correct results. Please share the output Excel file generated by the code for a reference.

It will help us identify if the issue is existing because of code or because of some bug in Aspose.Cells.


Workbook wb = new Workbook(dirPath + "001_Garment_Specification_12600_04102018_1837.xls");

PdfSaveOptions opts = new PdfSaveOptions();

wb.save(dirPath + CellsHelper.getVersion() + "-output.pdf", opts);


We have looked into your issue further and found that your code is using sheet.autofitRows() that makes the row height changes and the image property is Move but don’t size with cells, so after sheet.autofitRows(), the image exceeds rows in the output pdf.

If you manually autofit rows in Microsoft Excel, you will also find this issue.


So what is the solution for this issue.


Aspose version :18.3.5, attached pdf has the version in the name
001_Garment_Specification_12600_04112018_055918.3.5001_Garment_Specification_12600_04112018_055918.3.5.pdf (1.9 MB)


We are afraid, there is no good solution for it. Because if you will change the row heights, the images that were aligned previously will no more be aligned.

However, you may try the following code and see if it works fine for you.


//Specify Auto Fitter Options - Auto Fit Only Auto 
AutoFitterOptions autoOpts = new AutoFitterOptions();

//Autofit Worksheet Rows	


Still image size is not as excel after specifying auto fitter options, please take look at attached doc.
Now this issue (image size/quality) become show stopper for project, please advise.

SreeniImage Qality Issue2.zip (451.3 KB)


We are afraid, we still could not replicate your issue. Please provide us the following things.

1 - Environment/OS/JDK Settings
2 - Are you using JAI (Java Advanced Imaging) API?
3 - Runnable Sample Code (Exact code where we don’t have to do any modification)
4 - Sample Excel File being used inside the code, it should also be exact. Do not provide copy of it.
5 - PDF file generated by you on your machine for our comparison.


Ok, I will get all the requested info mean while, please could you send output and sample code your using?



Here is the code we used to test this issue.


Workbook workbook = new com.aspose.cells.Workbook(dirPath + "001_Garment_Specification_12600_04102018_1837.xls");
WorksheetCollection workSheetColl = workbook.getWorksheets();

Worksheet specReport = workSheetColl.get(0);

Worksheet revisionLogSheet = workSheetColl.get(1);

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

workbook.save(dirPath + CellsHelper.getVersion() + "-output.pdf", pdfSaveOptions);


Issue narrow down to that, if excel file open manually, enable printer and save then PDF file generating correctly, otherwise it is not generating correctly (image getting small).
So look like need set printer settings, here is printer setting : Print One sided, Collated, Landscape Orientation, Legal 8.5" x 14, Narrow Margins :Left 0.25", Right 0.25", Top:0.75’’ bottom0.75" Header 0.3, Fotter 0.3, Fit Sheet on Pne Page,.
Please advise, it is very high priority for go live.
Excel file1_Working.zip (2.0 MB)

Excel file without printer settingsExcel_file_notworking.zip (2.5 MB)

Correct PDF file attchedNEW_ABC.xlsThu Apr 12 22:40:15 EDT 2018_SreeOutputFile.pdf (1.9 MB)

not good pdf file attachNEW_ABC.xlsThu Apr 12 21:43:53 EDT 2018_SreeOutputFile.pdf (1.9 MB)

Now, Printer setting also added, still same issue. java file attached. take a look.
Also do we need to add printer setting to excel file to generate pdf correctly?

SreeniLatestVerExcelToPDF.zip (1.7 KB)


Please download the modified code and try it at your end. It works fine as we have tested it. The code is same as yours except we have removed the page setup settings and added changing the shape placement as MOVE_AND_SIZE so that pictures got adjusted when heights of the row change. Besides, auto height row is true as it is the problem of auto height row.

Sample Code Link:
modifiedLatestVerExcelToPDF_placement.zip (1.7 KB)