Skip to content

Feature - accept content to render pdf by url - #5

Open
usingtechnology wants to merge 3 commits into
bcgov:mainfrom
usingtechnology:feature/weasyprint-by-url-arg
Open

usingtechnology wants to merge 3 commits into
bcgov:mainfrom
usingtechnology:feature/weasyprint-by-url-arg

Conversation

@usingtechnology

Copy link
Copy Markdown

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.

@WadeBarnes WadeBarnes left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

image

@WadeBarnes WadeBarnes left a comment

Copy link
Copy Markdown
Member

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]

Comment thread 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
Copy Markdown
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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

2 participants