// Create a pdf file stream FileOutputStream outputStream = null; try { outputStream = new FileOutputStream("PrintSpecificPages.pdf"); } catch (FileNotFoundException e) { e.printStackTrace(); } // Create a new workbook Workbook workbook = new Workbook(); workbook.open(this.getResourceStream("xlsx/PrintSpecificPDFPages.xlsx")); IWorksheet worksheet = workbook.getWorksheets().get(0); //Create a PrintManager. PrintManager printManager = new PrintManager(); //Get the natural pagination information of the workbook. List pages = printManager.paginate(workbook); //Pick some pages to print. List newPages = new ArrayList(); newPages.add(pages.get(0)); newPages.add(pages.get(2)); //Update the page number and the page settings of each page. The page number is continuous. printManager.updatePageNumberAndPageSettings(newPages); //Save the pages into pdf file. printManager.savePageInfosToPDF(outputStream, newPages); // Close the file stream try { outputStream.close(); } catch (IOException e) { e.printStackTrace(); }