I have the following code to convert an Excel file to PDF file. Page size is correct but the content is not covering the full page.
Workbook workbook = new Workbook();
FileInputStream fileInputStream = new FileInputStream(attachmentFile);
workbook.loadFromStream(fileInputStream);
//workbook.getConverterSetting().setSheetFitToPage(true);
WorksheetsCollection worksheets = workbook.getWorksheets();
Worksheet worksheet;
PageSetup pageSetup;
for (int i = 0; i < worksheets.size(); i++) {
worksheet = worksheets.get(i);
pageSetup = worksheet.getPageSetup();
pageSetup.setHeaderMarginInch(.5);
pageSetup.setFooterMarginInch(.5);
pageSetup.setTopMargin(.5);
pageSetup.setBottomMargin(.5);
pageSetup.setLeftMargin(.5);
pageSetup.setRightMargin(.5);
//pageSetup.isFitToPage(true);
pageSetup.setOrientation(PageOrientationType.Portrait);
pageSetup.setPaperSize(PaperSizeType.PaperLetter);
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
workbook.saveToStream(outputStream, FileFormat.PDF);
byte pdfFileBytes[] = outputStream.toByteArray();
Where am I going wrong?