Download pdf files from Markdown (Dash AG Grid Issue #142)

From download pdf file issue with hyper link in table · Issue #142 · plotly/dash-ag-grid · GitHub

@daltonmaurya, please try this (please note this is the proper place to ask these questions):

# step-01
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/solar.csv")
if 'index' not in df:
    df['index'] = list(df.index)
df['filepath'] = df['index'].apply(lambda s : "../"+os.path.join("assets\data\gtre_reports", f"{s}.pdf").replace('\','/'))
df['link'] = df[['State', 'filepath']].apply(lambda s : f"[{s[0]}]({s[1]})", axis = 1)

app = Dash(__name__)

# step-02
def get_agrid(df):
    
    # select columns as per datatype
    link_columns = [s for s in df if s in ['link']]
    object_columns = [s for s in df.select_dtypes(include = "object") if s not in link_columns]
    numeric_columns = [s for s in df.select_dtypes(include = np.number) if (s not in link_columns) and (s not in object_columns)]

    # create column definitions
    columnDefs = [{"headerName": "Row ID", "valueGetter": {"function": "params.node.id"}, 'rowDrag': True}] + \
        [{"field" : i, "id" : i,"cellRenderer": "markdown", "resizable": True, "linkTarget":"_blank"} for i in link_columns] + \
        [{"field" : i, "id" : i, "editable": True, "resizable": True} for i in object_columns] + \
        [{"field" : i, "id" : i, "type": "rightAligned", "editable": True, "resizable": True} for i in numeric_columns]

    # create default column definitions
    defaultColDef = {"resizable": True, "sortable": True, "filter": True, "editable": True}
    


    # create grid
    grid = dag.AgGrid(
        id="grid-01",
        rowData=df.to_dict("records"),
        columnDefs=columnDefs,
        defaultColDef=defaultColDef,
        columnSize="autoSizeAll",
        dashGridOptions={"rowDragManaged": True,
                         "columnHoverHighlight": True,
                         "rowMultiSelectWithClick": True,
                         "enableCellTextSelection": True,
                         "ensureDomOrder": True,
                         "undoRedoCellEditing": True,
                         "undoRedoCellEditingLimit": 20,
                         "editType": "fullRow",
                         "pagination": True,
                         "paginationPageSize": 5,
                         },
        className="ag-theme-alpine", # ag-theme-balham, ag-theme-alpine-dark, ag-theme-material , ag-bootstrap
        csvExportParams={
            "fileName": "download.csv",
        },
    )
    
    return grid

grid = get_agrid(df)

# step-03
app.layout = html.Div(
    [
        grid,
    ],
 )

# step-04
if __name__ == "__main__":
    app.run_server(debug=True)