【问题标题】:username and password not working in wkhtmltopdf application用户名和密码在 wkhtmltopdf 应用程序中不起作用
【发布时间】:2014-05-11 18:08:48
【问题描述】:

我需要使用终端上的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页面。

我已经检查了我的 google 帐户,它以 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>

【问题讨论】:

    标签: django-forms wkhtmltopdf html-to-pdf


    【解决方案1】:

    --post 参数的正确语法是--post username user_name_value --post password password_value

    在您的登录表单中,尝试更改为 id="username" 而不是 id="email"

    用户名和密码都是表单上输入字段的idname

    希望对你有帮助!

    见:Generate PDF Behind Authentication Wall

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-06
      • 2012-03-08
      • 1970-01-01
      • 2013-06-24
      • 1970-01-01
      • 2016-05-04
      • 1970-01-01
      相关资源
      最近更新 更多