zhaoterryy / mkdocs-pdf-export-plugin

An MkDocs plugin to export content pages as PDF files
MIT License
318 stars 42 forks source link

change download icon #40

Closed sander76 closed 5 years ago

sander76 commented 5 years ago

Great plugin !

I'd like to see the option to change the download icon. (Which I experience is not always clear to users, who are looking for the "pdf download" button)

For example, have the option to change it to: https://fontawesome.com/icons/file-pdf?style=solid

Or just have it change to text: "download pdf"

zhaoterryy commented 5 years ago

You can modify your download link/icon/button using a theme_handler. For example:

def modify_html(html: str, href: str) -> str:
    soup = BeautifulSoup(html, 'html.parser')

    sm_wrapper = soup.new_tag('small')

    a = soup.new_tag('a', href=href, title='PDF Export', download=None)
    a['class'] = 'pdf-download'
    a.string = 'Download PDF'

    sm_wrapper.append(a)
    soup.body.footer.insert(0, sm_wrapper)

    return str(soup)
sander76 commented 5 years ago

Alright. Wasn't aware of that.. Thanks !