// Create a pdf file stream FileOutputStream outputStream = null; try { outputStream = new FileOutputStream("CustomBorder.pdf"); } catch (FileNotFoundException e) { e.printStackTrace(); } // Create a new workbook Workbook workbook = new Workbook(); InputStream templateFile = this.getResourceStream("xlsx\\CustomBorderStyle.xlsx"); workbook.open(templateFile); // Customizing the border style for exporting to PDF. PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); CustomBorderStyle thinBorderSetting = new CustomBorderStyle(); thinBorderSetting.setBorderWidth(0.4); CustomBorderStyle middleBorderSetting = new CustomBorderStyle(); middleBorderSetting.setBorderWidth(1.5); CustomBorderStyle dashBorderSetting = new CustomBorderStyle(); dashBorderSetting.setBorderWidth(0.4); dashBorderSetting.setDashes(new ArrayList<>(Arrays.asList(0.8, 0.8))); pdfSaveOptions.getBorderOptions().put(BorderLineStyle.Thin, thinBorderSetting); pdfSaveOptions.getBorderOptions().put(BorderLineStyle.Medium, middleBorderSetting); pdfSaveOptions.getBorderOptions().put(workbook.getActiveSheet().getRange("B13").getBorders().get(BordersIndex.EdgeTop).getLineStyle(), dashBorderSetting); //Save the workbook into pdf file. workbook.save(outputStream, pdfSaveOptions); // Close the file stream try { outputStream.close(); } catch (IOException e) { e.printStackTrace(); }