# Excluding Columns from the Exported PDF File

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Grid for Progress® Telerik® UI for UI for ASP.NET Core </td>
 </tr>
</table>

## Description

How can I exclude certain columns from the exported PDF file in a Telerik UI for ASP.NET Core  Grid?

## Solution

#### Using the `k-pdf-export` Class and CSS

To hide a Grid column only during the PDF export, use a CSS rule and reduce the width of the target column to zero. This approach is implemented because the Kendo UI Drawing API adds [the `k-pdf-export` class](https://docs.telerik.com/kendo-ui/framework/drawing/pdf-output/custom-appearance#using-the) on all elements of the exported content and you can target specific elements in the following way.

```
<style>
  .k-pdf-export colgroup > col:nth-child(4) {
    width:0; /* hides only the 4th column during PDF export */
  }
</style>

```

For example refer to this [Telerik REPL Project](https://netcorerepl.telerik.com/mGEbbFlv24kGE8ul49)

#### Using the `showColum()` and `hideColumn()` Grid Methods

1. Hide the columns by using the [`hideColumn`](https://docs.telerik.com/kendo-ui/api/ui/grid/methods/hidecolumn) method within the [`pdfExport`](https://docs.telerik.com/kendo-ui/api/ui/grid/events/pdfexport) event handler.
2. When the export is done, display the hidden column by using the [`showColumn`](https://docs.telerik.com/kendo-ui/api/ui/grid/methods/showcolumn) method.

```
<script>
    var exportFlag = false;
    function onPdfExport(e){
             if (!exportFlag) {
              e.sender.hideColumn(1);
              e.preventDefault();
              exportFlag = true;

              e.sender.saveAsPDF().then(function(){
                e.sender.showColumn(1);
                exportFlag = false;
              });

            }
    }
</script>
```

For example refer to this [Telerik REPL Project](https://netcorerepl.telerik.com/mmYPvbvv29bLqpSd35)

## More ASP.NET Core Grid Resources

* [ASP.NET Core Grid Documentation](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/grid/overview)

* [ASP.NET Core Grid Demos](https://demos.telerik.com/aspnet-core/grid/index)

* [ASP.NET Core DataGrid Product Page](https://www.telerik.com/aspnet-core-ui/grid)

* [Telerik UI for ASP.NET Core Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-core-ui/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET Core Forums](https://www.telerik.com/forums/aspnet-core-ui)

## See Also

* [Telerik REPL: Excluding Columns from the Exported PDF File by Using `k-pdf-export`](https://netcorerepl.telerik.com/mGEbbFlv24kGE8ul49)
* [Telerik REPL: Excluding Columns from the Exported PDF File by Using `showColumn` and `hideColumn`](https://netcorerepl.telerik.com/mmYPvbvv29bLqpSd35)
* [Client-Side API Reference of the Grid for ASP.NET Core](https://docs.telerik.com/kendo-ui/api/ui/grid)
* [Server-Side API Reference of the Grid for ASP.NET Core](https://docs.telerik.com/aspnet-core/api/grid)
* [Telerik UI for ASP.NET Core Breaking Changes](https://www.telerik.com/aspnet-core-ui/documentation/backwards-compatibility/2023-backwards-compatibility)
* [Telerik UI for ASP.NET Core Knowledge Base](https://docs.telerik.com/aspnet-core/knowledge-base)
