# Customize Border Style

DsExcel Java is a MESCIUS Documents product that offers a comprehensive library to create, manipulate, convert, and share Microsoft Excel-compatible spreadsheets.

## Content





DsExcel enables you to export PDF documents with a custom border style using [getBorderOptions](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/PdfSaveOptions.html#getBorderOptions) method of [PdfSaveOptions](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/PdfSaveOptions.html) class. This method uses [setBorderWidth](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/CustomBorderStyle.html#setBorderWidth) and [setDashes](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/CustomBorderStyle.html#setDashes) properties of [CustomBorderStyle](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/CustomBorderStyle.html) class and [BorderLineStyle](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/BorderLineStyle.html) enumeration to set the border width, dash length, and line style. setBorderWidth method adjusts the width of a border when exporting a PDF document, whereas setDashes method adjusts the length of each segment of the dashed line. BorderLineStyle enumeration specifies the line style for the border.

The following table lists the default values of all the border styles:

| **Border Type** | **Default Line Width (point)** | **Dashes (point)** | **Comment** |
| --- | --- | --- | --- |
| Hair | 0.2 | None | \- |
| DashDotDot | 1 | 9,3,3,3,3,3 | \- |
| DashDot | 1 | 8,2,2,2 | \- |
| Dotted | 1 | 1,1 | \- |
| Dashed | 1 | 3,1 | \- |
| Thin | 1 | None | \- |
| MediumDashDotDot | 2 | 4.5,1.5,1.5,1.5,1.5,1.5 | \- |
| SlantDashDot | 1 | 11, 1,5,1 | This border type comprises two lines, each with a width of 1 point. |
| MediumDashDot | 2 | 4.5,1.5,1.5,1.5 | \- |
| MediumDashed | 2 | 4.5,1.5 | \- |
| Medium | 2 | None | \- |
| Thick | 3 | None | This border type comprises three lines, each with a width of 1 point. |
| Double | 1 | None | This border type comprises two lines, each with a width of 1 point. |

Refer to the following example code to adjust the border width, dash length, and line style when exporting to a PDF document:

```Java
// Create a new workbook.
Workbook workbook = new Workbook();
        
// Open template file.
workbook.open("CustomBorderStyle.xlsx");

// Customize the border style for PDF export.
// Initialize PdfSaveOptions.
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
        
// Set outer border width to 0.4.
CustomBorderStyle thinBorderSetting = new CustomBorderStyle();
thinBorderSetting.setBorderWidth(0.4);
        
// Set middle border width to 1.5.
CustomBorderStyle middleBorderSetting = new CustomBorderStyle();
middleBorderSetting.setBorderWidth(1.5);
        
// Set inner horizontal border width to 0.4 in dash style.
CustomBorderStyle dashBorderSetting = new CustomBorderStyle();
dashBorderSetting.setBorderWidth(0.4);
dashBorderSetting.setDashes(new ArrayList<>(Arrays.asList(0.8, 0.8)));
        
// Add borders with custom border styles.
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 workbook to PDF file.
workbook.save("CustomBorder.pdf", pdfSaveOptions);
```

![](https://cdn.mescius.io/document-site-files/images/dd59ea42-cd61-4fa6-a018-6231c2a9c598/images/border-style-export-pdf.png)