wkhtmltopdf 和基于表单的身份验证 [英] wkhtmltopdf and forms based authentication

查看:78
本文介绍了wkhtmltopdf 和基于表单的身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用基于表单的身份验证的应用程序.我正在尝试复制应用程序中的页面并使用 wkhtmltopdf 将其保存为 PDF.

I have an application that uses forms based authentication. I'm trying to take a copy of a page within the application and save it to PDF using wkhtmltopdf.

wkhtmltopdf 已安装并且工作正常.我可以在应用程序中成功调用它以生成另一个网站的 PDF,无需身份验证(即 bbc.co.uk).

wkhtmltopdf is installed and works fine. I can call it successfully from within the application to generate a PDF of another website without authentication (i.e. bbc.co.uk).

我无法将用户名/密码传递给应用程序以生成所需页面的副本.相反,我得到了登录屏幕的 PDF.

I cannot get it to pass username/password to the application in order to generate a copy of the desired page. Instead I get a PDF of the signon screen.

客户端和服务器都是 Windows(分别是 7 和 2008).我正在使用命令:

Both client and server are Windows (7 and 2008 respectively). I'm using the command:

wkhtmltopdf.exe --post userid=xxx --post pwd=yyy --ignore-load-errors http://url.com/blah/blah/ test.pdf

wkhtmltopdf.exe --post userid=xxx --post pwd=yyy --ignore-load-errors http://url.com/blah/blah/ test.pdf

xxx 是我的用户名,yyy 是我的密码.我已经浏览了登录页面的源代码,并且表单字段的 ID 是 userid 和 pwd,所以我相信我在命令行中的 post 参数是正确的.

Where xxx is my username and yyy is my password. I've been through the source of the logon page and the ids of the form fields are userid and pwd so I believe I have the post parameters in command line correct.

彻底谷歌搜索后,我可以看到提到 --cookie-jar 参数,但还没有设法弄清楚它的用法,或者即使它会有所帮助.

After thoroughly googling I can see mentions to a --cookie-jar parameter, but haven't managed to work out its usage, or even if it'll help.

谢谢

邓肯

推荐答案

此问题现已解决.我使用的是 0.9.9 版,但无法正常工作.一旦我转移到 0.10.0 rc2 版本,它就运行良好.

This issue is now resolved. I was using version 0.9.9 and couldn't get it to work. As soon as I moved to version 0.10.0 rc2 it worked fine.

如果其他人正在尝试同样的事情,我使用的代码行如上,我不需要 --cookie-jar 参数.

If anyone else is trying the same thing, the line of code I used was as above, I didn't need the --cookie-jar parameter.

这篇关于wkhtmltopdf 和基于表单的身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆