{"id":24915627,"url":"https://github.com/bachp/wkhtmltopdf-py","last_synced_at":"2025-03-28T06:29:12.734Z","repository":{"id":986604,"uuid":"791377","full_name":"bachp/wkhtmltopdf-py","owner":"bachp","description":"A wrapper library around the wkhtmltopdf binary","archived":false,"fork":false,"pushed_at":"2010-07-26T14:44:16.000Z","size":22832,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T07:18:44.677Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bachp.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-07-22T16:34:25.000Z","updated_at":"2014-12-11T19:56:53.000Z","dependencies_parsed_at":"2022-07-05T22:32:22.684Z","dependency_job_id":null,"html_url":"https://github.com/bachp/wkhtmltopdf-py","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bachp%2Fwkhtmltopdf-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bachp%2Fwkhtmltopdf-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bachp%2Fwkhtmltopdf-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bachp%2Fwkhtmltopdf-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bachp","download_url":"https://codeload.github.com/bachp/wkhtmltopdf-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245983567,"owners_count":20704767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-02T07:18:44.433Z","updated_at":"2025-03-28T06:29:12.711Z","avatar_url":"https://github.com/bachp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"wkhtmltopdf-py\n==============\n\nThis is a wrapper library around the wkhtmltopdf binary.\nFor more information about wkhtmltopdf please visit http://code.google.com/p/wkhtmltopdf/.\n\nBasic usage\n===========\n\n\u003e\u003e\u003e from wkhtmltopdfpy import WebkitHTML\n\nCreate a WebkitHTML element\n\n\u003e\u003e\u003e wk = WebkitHTML()\n\nThis will use the bundled static version of wkhtmltopdf.\nPlease note that this only works on Linux, Windows and Mac OS X (intel)\n\nIf you are using another system, or if you want to use another binary,\nyou can specify your own.\n\n\u003e\u003e\u003e wk = WebkitHTML('/usr/bin/wkhtmltopdf')\n\nYou can then specify either a text as ``content`\n\u003e\u003e\u003e content = []\n\u003e\u003e\u003e content.append(u\"This is my first page\")\n\nor you can specify an existing path\n\u003e\u003e\u003e content.append(\"./README\")\n\na third way is to specify a url\n\u003e\u003e\u003e content.append(\"http://google.com\")\n\nIn a similar way you can provide sources for ``header`` and ``footer``\nwith the difference that they don't take a list, but only a singe element\neach.\n\n\u003e\u003e\u003e header = \"header.html\"\n\u003e\u003e\u003e footer = u\"This is my Footer\"\n\nYou can specify special configuration parameters for wkthmltopdf using\nthe ``args`` argument. Lets specify the margin of the page.\n\n\u003e\u003e\u003e args = [\"--margin-bottom\", \"2.5cm\", \"--margin-top\", \"2.5cm\"]\n\nNow we can now render to a file called example.pdf.\n\n\u003e\u003e\u003e wk.render(\"example.pdf\", content=content, header=header, footer=header, args=args)\n\nAlternatively you can get the PDF content as the return value by providing ``None`` as\n``output_file``\n\n\u003e\u003e\u003e pdf = wk.render(None, content=content, header=header, footer=header, args=args)\n\nYou can then send it over network or write it to a file yourself.\n\n\u003e\u003e\u003e f = open('myexample.pdf', 'wb')\n\u003e\u003e\u003e f.write(pdf)\n\u003e\u003e\u003e f.close()\n\nNote: If you want to write the PDF directly to a file, the first version is preferable\nas it doesn't involve temporary files and storing the whole PDF in memory.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbachp%2Fwkhtmltopdf-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbachp%2Fwkhtmltopdf-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbachp%2Fwkhtmltopdf-py/lists"}