Hi team,
We are using Aspose Cells v 22.7
input - TURKIYE PETROL RAFINERILERI A.zip (12.0 KB)
output - bundle_25dd31b4-ff3e-41e5-8353-7d2f1694c77b_08.12.2022.17.11.25.395.pdf.zip (100.9 KB)
Using the following code to convert an excel to pdf like so -
public byte[] convertExcelToPDF(ByteArrayInputStream excelInputStream) throws Exception {
ByteArrayOutputStream outputStreamPdf = new ByteArrayOutputStream();
try {
log.info("Initiating Excel to pdf conversion");
Workbook workbook = new Workbook(excelInputStream);
// Expanding columns before merging
WorksheetCollection worksheets = workbook.getWorksheets();
int workSheetCount = worksheets.getCount();
for (int sheetNo = 0; sheetNo < workSheetCount; sheetNo++) {
Worksheet sheet = worksheets.get(sheetNo);
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setPrintArea("");
pageSetup.setPrintGridlines(true);
sheet.autoFitRow(0,0,1,new AutoFitterOptions());
sheet.autoFitColumns();
}
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setAllColumnsInOnePagePerSheet(true);
workbook.save(outputStreamPdf, saveOptions);
log.info("Conversion from Excel to pdf completed");
return outputStreamPdf.toByteArray();
} catch (Exception ex) {
log.info("Exception occurred while converting Excel to pdf : ", ex);
throw ex;
} finally {
outputStreamPdf.close();
}
}
The output has the following issues -
- Inconsistent grid.
- Text on Page 1 is cut and it spills into Page 2.
Please help and let us know if this is fixable.
Cheers,
Shaurya