Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active April 22, 2021 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/2396821770031adfbe82eee1d66854f0 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/2396821770031adfbe82eee1d66854f0 to your computer and use it in GitHub Desktop.
Convert Excel to PDF Java
// Create Workbook to load Excel file
Workbook workbook = new Workbook("Book1.xlsx");
// Create PDF options
PdfSaveOptions options = new PdfSaveOptions();
options.setOnePagePerSheet(true);
// Save the document in PDF format
workbook.save("Excel-to-PDF.pdf", options);
// Create Workbook to load Excel file
Workbook workbook = new Workbook("Book1.xlsx");
// Create PDF options
PdfSaveOptions options = new PdfSaveOptions();
// To render sheet2 only
options.setPageIndex(1);
options.setPageCount(1);
// Save the document in PDF format
workbook.save("Excel-to-PDF.pdf", options);
// Create Workbook to load Excel file
Workbook workbook = new Workbook("Book1.xlsx");
// Save the document in PDF format
workbook.save("Excel-to-PDF.pdf", SaveFormat.PDF);
// Create Workbook to load Excel file
Workbook workbook = new Workbook("Book1.xlsx");
// Create PDF options
PdfSaveOptions options = new PdfSaveOptions();
options.setCompliance(PdfCompliance.PDF_A_1_A);
// Save the document in PDF format
workbook.save("Excel-to-PDF.pdf", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment