尝试rasterize Django提供的页面。似乎只有Django模板引擎返回的基本html由rasterize脚本呈现。
请求期间的http流量:
[19/Dec/2013 12:44:15] "GET /application HTTP/1.1" 301 0
[19/Dec/2013 12:44:15] "GET /application/ HTTP/1.1" 302 0
[19/Dec/2013 12:44:15] "GET /application/login/?next=/application/ HTTP/1.1" 200 4159
[19/Dec/2013 12:44:15] "GET /application/static/css/footer.css HTTP/1.1" 200 841
[19/Dec/2013 12:44:15] "GET /application/static/css/style.css HTTP/1.1" 200 506
[19/Dec/2013 12:44:15] "GET /application/static/js/stupidtable.js HTTP/1.1" 200 5402
[19/Dec/2013 12:44:15] "GET /application/static/css/style.css HTTP/1.1" 200 11923
[19/Dec/2013 12:44:15] "GET /application/static/js/g.raphael.js HTTP/1.1" 200 27680
[19/Dec/2013 12:44:15] "GET /application/static/img/logo.png HTTP/1.1" 200 3117
[19/Dec/2013 12:44:16] "GET /application/static/js/chart.raphael.js HTTP/1.1" 200 39384
[19/Dec/2013 12:44:16] "GET /application/static/js/bootstrap.js HTTP/1.1" 200 61752
[19/Dec/2013 12:44:16] "GET /application/static/js/raphael.js HTTP/1.1" 200 226951
[19/Dec/2013 12:44:16] "GET /application/static/css/bootstrap.css HTTP/1.1" 200 127407
[19/Dec/2013 12:44:16] "GET /application/static/js/jquery1.9.js HTTP/1.1" 200 342486
[19/Dec/2013 12:44:16] "GET /application/static/img/favicon.ico HTTP/1.1" 200 15012
Phantomjs执行为:
phantomjs ~/rasterize.js 'http://localhost:8000/application' g.pdf
生成的pdf包含unstyle HTML。
更新:当我指定* pdf以外的文件扩展名时,html会正确呈现。
phantomjs ~/rasterize.js 'http://localhost:8000/application' g.png
返回正确的渲染。