-
-
Notifications
You must be signed in to change notification settings - Fork 710
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
weasyprint/tools removed #1422
Comments
Hello! You’re right, there’s nothing in the release notes about this, that’s an error, sorry! But removing the tools wasn’t an error: as WeasyPrint doesn’t render PNG files anymore, the two tools are now obsolete. Did you use them? |
Hello. |
Wow, that’s always interesting to see how tools written to "play" are used seriously with interesting use cases 😄. That was actually a good way to get PNG files out of WeasyPrint without writing a single line of Python. Unfortunately, as WeasyPrint can’t generate PNG files anymore, that’s not possible now without writing extra code. Would you be interested in a code sample showing how to do this? |
We were not rendering PNG files, we rendered PDF files, just connecting to weasyprint as a local network service. |
Sorry, I didn’t remember that "navigator" was also able to generate PDF files. This code was really included to play, and even if it was useful we won’t maintain it seriously. But you can use this script instead: from wsgiref.simple_server import make_server
from weasyprint import HTML
from weasyprint.urls import url_is_absolute
def app(environ, start_response):
url, query_string = environ['PATH_INFO'], environ.get('QUERY_STRING')
url = url.lstrip('/')
if query_string:
url += f'?{query_string}'
if not url_is_absolute(url):
url = f'http://{url}'
body = HTML(url=url).write_pdf()
filename = url.rstrip('/').rsplit('/', 1)[-1] or 'out'
start_response('200 OK', [
('Content-Type', 'application/pdf'),
('Content-Length', str(len(body))),
('Content-Disposition', f'attachment; filename={filename}.pdf')
])
return [body]
make_server('localhost', 5000, app).serve_forever() Of course, this code is just a snippet that can be adapted to your needs, even if it is quite close to what "navigator" was. Here are the main changes: the URL doesn’t have the leading Even if this code may work well for you, it’s not exactly ready for production. Just as "navigator", it uses |
With commit 431c11e, weasyprint/tools was removed from the repo. However, there wasn't any associated explanation, and it wasn't noted in the release notes. Additionally, the subject line appears to be entirely unrelated to dropping all tools.
Was weasyprint/tools removed in error?
The text was updated successfully, but these errors were encountered: