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:
Template Excel file
Current output PDF by Aspose.Cells for Java API
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:
Class Libraries & REST APIs for the developers to manipulate & process Files from Word, Excel, PowerPoint, Visio, PDF, CAD & several other categories in Web, Desktop or Mobile apps. Develop & deploy on Windows, Linux, MacOS &...
Class Libraries & REST APIs for the developers to manipulate & process Files from Word, Excel, PowerPoint, Visio, PDF, CAD & several other categories in Web, Desktop or Mobile apps. Develop & deploy on Windows, Linux, MacOS &...
b)Or set FitToPages Options of page setup,see:
This article provides sample code to set page options of Excel worksheets programmatically using C# API and .NET Library. You will be able to set Page Orientation, Scaling Factor, FitToPages Options, Paper Size, Print Quality, First Page Number.