Skip to content

Commit

Permalink
fix: Check if header/footer html exists before trying to extract
Browse files Browse the repository at this point in the history
- issue: AttributeError: 'NoneType' object has no attribute 'extract', when no letterhead html was present
  • Loading branch information
marination committed Jan 31, 2024
1 parent 2d11989 commit c1dc4b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frappe/utils/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def prepare_header_footer(soup: BeautifulSoup):

# extract header and footer
for html_id in ("header-html", "footer-html"):
if content := soup.find(id=html_id).extract():
if content := soup.find(id=html_id):
content = content.extract()
# `header/footer-html` are extracted, rendered as html
# and passed in wkhtmltopdf options (as '--header/footer-html')
# Remove instances of them from main content for render_template
Expand Down

0 comments on commit c1dc4b9

Please sign in to comment.