// Create a pdf file stream FileOutputStream outputStream = null; try { outputStream = new FileOutputStream("CustomPageInfos.pdf"); } catch (FileNotFoundException e) { e.printStackTrace(); } // Create a new workbook Workbook workbook = new Workbook(); workbook.open(this.getResourceStream("xlsx/KeepTogether.xlsx")); IWorksheet worksheet = workbook.getWorksheets().get(0); //Firstly, create a printManager. PrintManager printManager = new PrintManager(); //Get the natural pagination information of the worksheet. //The first page of the natural pagination is "A1:F37", the second page is from row "A38:F73" List pages = printManager.paginate(worksheet); //Custom the pageInfos. pages.get(0).getPageContent().setRange(worksheet.getRange("A1:F36")); // The first page is "A1:F36". pages.get(0).getPageSettings().setCenterHeader("&KFF0000&20 Budget summary report"); // The center header of the first page will show the text "Budget summary report". pages.get(0).getPageSettings().setCenterFooter("&KFF0000&20 Page &P"); // The center footer of the first page will show the page number "1". pages.get(1).getPageContent().setRange(worksheet.getRange("A37:F73"));// The second page is "A37:F73". //Save the modified pages into pdf file. printManager.savePageInfosToPDF(outputStream, pages); // Close the file stream try { outputStream.close(); } catch (IOException e) { e.printStackTrace(); }