我需要使用 终端上的wkhtmltopdf工具将 HTML URL 转换为 pdf 格式。
$ wkhtmltopdf --username 'arya_normal2' --password '1' http://localhost:8000/employee/arya_normal2-no-emp-code/certificates/53/show/ localhost.pdf
在点击 url 时,它没有获得身份验证/登录。它提供了简单的登录pdf页面。
我已经检查了我的谷歌帐户,它以 pdf 格式显示登录页面。
有人在 wkhtmltopdf 中使用过用户名和密码吗?如果我给出了错误的命令行参数,请帮助我。
编辑:
修改后的命令行参数:
wkhtmltopdf --cookie 'csrftoken' 'JuQUFr9KLUdZLMAjLn3d8yakd6HOshTN' --cookie 'sessionid' 'xy3yacbe3nq1sbbtstkxfp34ah3imcmg' --post username 'arya_normal2' --post password '1' http://localhost:8000/employee/arya_normal2-no-emp-code/certificates/all/ sample2.pdf
现在出现以下错误:
Internal Server Error: /employee/arya_normal2-no-emp-code/certificates/all/
Traceback (most recent call last):
File "/home/nirmal/venvs/nuvologistics/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 107, in get_response
response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/home/nirmal/venvs/nuvologistics/local/lib/python2.7/site-packages/django/middleware/csrf.py", line 170, in process_view
request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')
File "/home/nirmal/venvs/nuvologistics/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 146, in _get_post
self._load_post_and_files()
File "/home/nirmal/venvs/nuvologistics/local/lib/python2.7/site-packages/django/http/request.py", line 219, in _load_post_and_files
self._post, self._files = self.parse_file_upload(self.META, data)
File "/home/nirmal/venvs/nuvologistics/local/lib/python2.7/site-packages/django/http/request.py", line 183, in parse_file_upload
parser = MultiPartParser(META, post_data, self.upload_handlers, self.encoding)
File "/home/nirmal/venvs/nuvologistics/local/lib/python2.7/site-packages/django/http/multipartparser.py", line 70, in __init__
raise MultiPartParserError('Invalid boundary in multipart: %s' % boundary)
MultiPartParserError: Invalid boundary in multipart: None
登录表单 :
<form action="" method="post" enctype="multipart/form-data" boundary=0xKhTmLbOuNdArY>
{% csrf_token %}
<input name="username" type="text" placeholder="Email-address" id="email"><br>
<input name="password" type="password" placeholder="Password" id="password"><br>
<input type="checkbox" id="remember" value="Remember Me" > <span>Remember Me</span>
<a id="forget">Forgot your Password?</a><br>
{% if error %}
<i class="icon-warning"></i><span class="error">The username or password you entered is incorrect.</span>
{% endif %}
<input type="submit" value="LOGIN" id="login">
</form>