Actually, I need to convert an excel report (which has been generated in Aspose.Cells Java ) to Pdf format. The issue is that the text in the PDF file is very small making it unreadable. So, in my code, I tried to increase the font size but the font was still unreadable. Can you please suggest us some better way to convert excel files into pdf?
I am using the following piece of code:
public String convertToPdfFromExcelReport (String destinationPath, String SourcePath) {
try {
Workbook workbook = new Workbook(SourcePath);
Worksheet sheet = workbook.getWorksheets().get(0);
PageSetup pageSetup = sheet.getPageSetup();
Style style = sheet.getCells().getStyle();
Font font = style.getFont();
font.setName("Calibri");
font.setSize(14);
sheet.getCells().setStyle(style);
for(int rowIndex = 0 ; rowIndex < 106; rowIndex++){
if(rowIndex != 95 && rowIndex != 96 && rowIndex != 97 && rowIndex != 98){
sheet.getCells().setRowHeight(rowIndex, 14);
}else{
sheet.getCells().setRowHeight(rowIndex, 0);
}
}
pageSetup.setZoom(48);
pageSetup.setFitToPagesTall(1);
pageSetup.setCenterHorizontally(true);
PdfSaveOptions options = new PdfSaveOptions();
options.setPageIndex(0);
for (int i = 0; i <= workbook.getWorksheets().getCount(); i++) {
options.setPageCount(i);
}
options.setCompliance(PdfCompliance.NONE);
workbook.save(destinationPath, options);
return destinationPath;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}