2014-04-01 75 views
1

我需要在终端上使用wkhtmltopdf工具将HTML URL转换为pdf格式。用户名和密码在wkhtmltopdf应用程序中不起作用

$ wkhtmltopdf --username 'arya_normal2' --password '1' http://localhost:8000/employee/arya_normal2-no-emp-code/certificates/53/show/ localhost.pdf 

它没有得到验证/登录时,击中网址。它提供简单的登录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" >&nbsp; <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> 

回答

0

为--post参数的正确语法是--post用户名user_name_value --post密码password_value

在你的登录表单

,尝试改变ID =“用户名”而不是ID =“电子邮件”

用户名和密码是ID名称形式

希望它可以帮助输入字段两个!

参见:Generate PDF Behind Authentication Wall

相关问题