Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

How to display a pdf file from a href link in a pop-up window or new tab instead of download it

I am creating a graph with each xaxis is a href link to their respecitive pdf file. I wish to display it at a popup window (or in jquery term, modal window), after numerous attempt it remain unsuccessful. I decided to make it display the pdf file at new tab, but even with target=’_blank’ Chrome browser choose to download it instead. Hope someone can help me.

    x_var = [f"<a href='https://xxx/xxx/{rule}.pdf' class='show-pdf' target='_blank'>{rule}</a>" for rule in df_temp.index]
    data.append(go.Bar(x=x_var, y=df_temp.values, name=cat, marker={'color':'#d0384d'}, visible = visible))

If you are using href, try using the plots as a html file, this even retains the interactive elements like drop downs and hover elements.

fig = go.Figure(data=data,layout=layout)
pyo.plot(fig, filename='xyz.html')

Refer to ‘xyz.html’ through href.
Hope this helped!