Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError on render_pdf() #29

Closed
tsjahangiri opened this issue Jan 18, 2022 · 4 comments
Closed

AssertionError on render_pdf() #29

tsjahangiri opened this issue Jan 18, 2022 · 4 comments

Comments

@tsjahangiri
Copy link

Hi, I got the assertion error when I called flask_weasyprint render_pdf method

My Code:

html = render_template('report.html', stress_data=#####, steps_data=#####, user_data=#####,
stress_img=#####, steps_img=#####)
pdf = render_pdf(HTML(string=html))

Error:

File "/usr/local/lib/python3.9/dist-packages/weasyprint/layout/block.py", line 299, in _linebox_layout
for i, (line, resume_at) in enumerate(lines_iterator):
File "/usr/local/lib/python3.9/dist-packages/weasyprint/layout/inline.py", line 43, in iter_line_boxes
line, resume_at = get_next_linebox(
File "/usr/local/lib/python3.9/dist-packages/weasyprint/layout/inline.py", line 114, in get_next_linebox
offset_x = text_align(
File "/usr/local/lib/python3.9/dist-packages/weasyprint/layout/inline.py", line 1134, in text_align
assert align == 'end'

Can you please fix that. Thanks

@grewn0uille
Copy link
Member

Hello,
It’s a bug in WeasyPrint v54.0, which has been fixed in 54.x branch.

@tsjahangiri
Copy link
Author

Thanks for reply. But how then I can use the 54.x branch while using flask_weasyprint library? like flask_weasyprint recent version is 0.6 in which this bug exists.

@grewn0uille
Copy link
Member

WeasyPrint is a dependency of Flask-WeasyPrint, which means that when you install Flask-WeasyPrint, the more recent version of WeasyPrint is installed.

If you want to use the 54.x branch, you can use this command: pip install git+https://github.com/Kozea/WeasyPrint.git@54.x.
Else, you can also downgrade your WeasyPrint with pip install WeasyPrint=="53.4".

@tsjahangiri
Copy link
Author

Ok thanks for the answer it worked out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants