Skip to content

Commit

Permalink
update: README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
vvanglro committed Nov 9, 2022
1 parent 6b243d2 commit 0f632e7
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,20 @@ from pwhtmltopdf import HtmlToPdf


async def this_from_url():
htp = HtmlToPdf()
await htp.from_url("https://playwright.dev/", "from_url.pdf")
await htp.close()
async with HtmlToPdf() as htp:
await htp.from_url("https://playwright.dev/", "from_url.pdf")


async def this_from_file():
htp = HtmlToPdf()
# Make sure the current directory has a test.html file
await htp.from_file("test.html", "from_file.pdf")
await htp.close()
async with HtmlToPdf() as htp:
# Make sure the current directory has a test.html file
await htp.from_file("test.html", "from_file.pdf")


async def this_from_string():
htp = HtmlToPdf()
content = pathlib.Path("test.html").read_text()
await htp.from_string(content, "from_string.pdf")
await htp.close()
async with HtmlToPdf() as htp:
content = pathlib.Path("test.html").read_text()
await htp.from_string(content, "from_string.pdf")


if __name__ == '__main__':
Expand All @@ -61,7 +58,8 @@ from pwhtmltopdf import HtmlToPdf

async def this_render_from_url():
file_path = pathlib.Path("tests/images.html").absolute()
async with HtmlToPdf(static_root="tests/static", wait_until="load", print_background=True) as htp:
async with HtmlToPdf(static_root="tests/static",
wait_until="load", print_background=True) as htp:
await htp.from_url(
f"file://{file_path}",
"tests/effect/from_url/local_url_render.pdf",
Expand All @@ -73,15 +71,17 @@ async def this_render_from_url():
async def this_render_from_file():
htp = HtmlToPdf(static_root="tests/static")
await htp.from_file(
"tests/images.html", "tests/effect/from_file/images_render.pdf", local_render=True, char_code=123
"tests/images.html", "tests/effect/from_file/images_render.pdf",
local_render=True, char_code=123
)
await htp.close()


async def this_render_from_string():
content = pathlib.Path("tests/images.html").read_text()
htp = HtmlToPdf(static_root="tests/static")
await htp.from_string(content, "tests/effect/from_string/images_render.pdf", local_render=True, char_code=123)
await htp.from_string(content, "tests/effect/from_string/images_render.pdf",
local_render=True, char_code=123)
await htp.close()


Expand Down

0 comments on commit 0f632e7

Please sign in to comment.