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

Feature - accept content to render pdf by url #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

usingtechnology
Copy link

Add ability to pass in the url argument to weasyprint.
Can set some of the additional url arguments, see class weasyprint.HTML(input, **kwargs)

Add ability to pass in the url argument to weasyprint.
Copy link
Member

@WadeBarnes WadeBarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the documentation to identify and describe the new functionality. It would be nice if you could add an additional working example like the existing one.

@WadeBarnes
Copy link
Member

@parc-jason, The API docs should be updated too;

image

Copy link
Member

@WadeBarnes WadeBarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running curl -v -X POST -H 'Content-Type: text/plain' -d 'https://www.google.ca/?client=safari&channel=iphone_bm' -JLO http://127.0.0.1:5001/pdf?filename=result_from_url.pdf&type=url after building and starting the new image results in a PDF with just the URL printed:

image

Logs:

[2020-05-22 14:09:06,876] INFO in app: POST  /pdf?filename=result_from_url.pdf&type=url
2020-05-22 14:09:06,876 INFO: POST  /pdf?filename=result_from_url.pdf&type=url [in /app/app.py:51]
[2020-05-22 14:09:07,698] INFO in app:  ==> POST  /pdf?filename=result_from_url.pdf  ok
2020-05-22 14:09:07,698 INFO:  ==> POST  /pdf?filename=result_from_url.pdf  ok [in /app/app.py:64]

README.md Outdated
`POST` to `/pdf` can be used to generate a PDF from a URL. Use the `type=url` query parameter and a url in a text/plain body, call:

```
curl -v -X POST -H 'Content-Type: text/plain' -d 'https://www.google.ca/?client=safari&channel=iphone_bm'-JLO http://127.0.0.1:5001/pdf?filename=result_from_url.pdf&type=url
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
curl -v -X POST -H 'Content-Type: text/plain' -d 'https://www.google.ca/?client=safari&channel=iphone_bm'-JLO http://127.0.0.1:5001/pdf?filename=result_from_url.pdf&type=url
curl -v -X POST -H 'Content-Type: text/plain' -d 'https://www.google.ca/?client=safari&channel=iphone_bm' -JLO http://127.0.0.1:5001/pdf?filename=result_from_url.pdf&type=url

@WadeBarnes
Copy link
Member

Did the following to build and run locally;

Wade@Epoch MINGW64 /c/docker-weasyprint (feature/weasyprint-by-url-arg)
$ docker build -t bcgovimages/weasyprint .
...

Wade@Epoch MINGW64 /c/docker-weasyprint (feature/weasyprint-by-url-arg)
$ docker run -p 5001:5001 bcgovimages/weasyprint

Correct the curl command.
Add command to the help response.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants