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

Free Support Forum - aspose.com

Aspose-Cells - Excel to PDF

Hi,
I am converting an Excel file to PDF using aspose cells.
I want to increase the page size to A2 and the contents of the Excel file should also scale up accordingly. But this is not happening right now.
Following is the current code. Can you tell me the appropriate code changes.

	Workbook workbook = new Workbook(filePath);
	WorksheetCollection worksheets = workbook.getWorksheets();
	Iterator itr = workbook.getWorksheets().iterator();
	for(int i=0;i<worksheets.getCount();i++)
	{
		Worksheet worksheetTemp = worksheets.get(i);
		worksheetTemp.autoFitColumns();
	}
	PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
	pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);
	workbook.save(this.destinationFilePath, pdfSaveOptions);

@pranavkhedkar1512,

You may try to add the following line of code to your code segment if it works for your needs:
e.g.
Sample code:

Workbook workbook = new Workbook(filePath);
WorksheetCollection worksheets = workbook.getWorksheets();
Iterator itr = workbook.getWorksheets().iterator();
for(int i=0;i<worksheets.getCount();i++)
{
	Worksheet worksheetTemp = worksheets.get(i);
        PageSetup pageSetup = worksheetTemp.getPageSetup();
        //set paper size
        pageSetup.setPaperSize(PaperSizeType.PAPER_A_2);

	worksheetTemp.autoFitColumns();
}
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);
workbook.save(this.destinationFilePath, pdfSaveOptions);

If you still have some issue or other requirements, kindly do provide the following with further details:

  1. Template Excel file
  2. Current output PDF by Aspose.Cells for Java API
  3. Your expected output PDF

As soon as we get these resource files, we will start investigating your issue and assist you accordingly.

@pranavkhedkar1512
a)You may set the options for PdfSaveOptions , see:



b)Or set FitToPages Options of page setup´╝îsee: