Excel to PDF - Length page ( not large file size)

When I covert an excel to pdf. The page rendered on pdf is very long even though the content of the excel is less than 10 rows. But seems pdf is generated for rest of blank 57K+ rows of the xl. Can someone please help to solve this issue?

@ravichn,

Please open the Excel file into MS Excel manually and take the print preview of the sheet, so you will also notice long list of pages with those blank rows and columns. Either you may set the printable area (e.g., worksheet.PageSetup.PrintArea = “A1:H10”; ) or remove those blank rows using the following lines of code before rendering to PDF file format:

worksheet.Cells.DeleteBlankColumns();
worksheet.Cells.DeleteBlankRows();

Hope, this helps a bit.

Thanks @Amjad_Sahi.

I am not finding such properties. Please find the code snippet I am using below

com.aspose.cells.Workbook sourceDocument = new com.aspose.cells.Workbook(path);
		WorksheetCollection wc = sourceDocument.getWorksheets();
		for (int i = 0; i < wc.getCount(); i++) {
			Worksheet worksheet = sourceDocument.getWorksheets().get(i);
			//Clear the print area 
			worksheet.getPageSetup().setPrintArea("");
			worksheet.autoFitColumns();
			worksheet.autoFitRows();
		}

		// Implement one page per worksheet option
		PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
		pdfSaveOptions.setOnePagePerSheet(true);
		 
        pdfSaveOptions.setOptimizationType(PdfOptimizationType.MINIMUM_SIZE);
       sourceDocument.save(fileName, pdfSaveOptions);

@ravichn,
You can use the below code in java as these properties exist in latest version of the API:

worksheet.getCells().deleteBlankColumns();
worksheet.getCells().deleteBlankRows();

share your source file with us if the issue persists.