// Create a pdf file stream FileOutputStream outputStream = null; try { outputStream = new FileOutputStream("GetPaginationInfo.pdf"); } catch (FileNotFoundException e) { e.printStackTrace(); } // Create a new workbook Workbook workbook = new Workbook(); // Open an excel file InputStream fileStream = this.getResourceStream("xlsx/Medical office start-up expenses 1.xlsx"); workbook.open(fileStream); IWorksheet worksheet = workbook.getWorksheets().get(1); PrintManager printManager = new PrintManager(); // The columnIndexs is [4, 12, 20], this means that the horizontal direction is split after the column 5th, 13th, and 21th. List columnIndexs = printManager.GetPaginationInfo(worksheet, PaginationOrientation.Horizontal); // The rowIndexs is [42, 61], this means that the vertical direction is split after the row 43th and 62th. List rowIndexs = printManager.GetPaginationInfo(worksheet, PaginationOrientation.Vertical); // Save the pages into pdf file. List pages = printManager.paginate(worksheet); printManager.savePageInfosToPDF(outputStream, pages); // Close the file stream try { outputStream.close(); } catch (IOException e) { e.printStackTrace(); }