2.
- Code: Select all
public static String convertExcelToPdf(File inputExcelFile) throws IOException {
// Set license key
com.spire.license.LicenseProvider.setLicenseKey(LICENSE_KEY);
logger.info("inputExcelFile created: " + inputExcelFile.getPath());
File outputPdfFile = File.createTempFile("outputPdf", "." + "pdf");
Workbook workbook = new Workbook();
workbook.loadFromFile(inputExcelFile.getAbsolutePath());
// Set worksheets to fit to page when converting
workbook.getConverterSetting().setSheetFitToPage(true);
// Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0);
// Get the PageSetup object of the first worksheet.
PageSetup pageSetup = sheet.getPageSetup();
// Set the page margins of bottom, left, right and top.
pageSetup.setBottomMargin(2);
pageSetup.setLeftMargin(1);
pageSetup.setRightMargin(1);
pageSetup.setTopMargin(3);
// Set the margins of header and footer.
pageSetup.setHeaderMarginInch(2);
pageSetup.setFooterMarginInch(2);
// Save the resulting document to a specified path
workbook.saveToFile(outputPdfFile.getAbsolutePath());
logger.info("outputPdfFile.getAbsolutePath() " + outputPdfFile.getAbsolutePath());
return changePageSizeToA4(addPageNumberToPDF(outputPdfFile.getAbsolutePath()));
}
3. Manifest-Version: 1.0
Extension-Name: spire.office
Implementation-Title: spire.office for java
Implementation-Version: 5.4.2
Implementation-Vendor: E-iceblue Co., Ltd.
Implementation-Vendor-Id: com.spire
Implementation-URL: https://www.e-iceblue.com
4. Application Type: Spingboot JDK 1.8