从Google Maps API在服务器上生成PDF? [英] Generate PDF on the server from Google Maps API?

查看:161
本文介绍了从Google Maps API在服务器上生成PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个托管的网络应用程序,它将Google Maps API用于各种类型的地理报告,并使用用于添加标记和形状的JavaScript API,以及用于其他图层的KML叠加。



客户有一些需求将这些需求转化为可下载&可打印的PDF地图。我不知道该从哪开始。有任何想法吗?正如Mark Storer指出的那样,您可以使用 / wkhtmltopdf /rel =nofollow> wkhtmltopdf



如果您的地图中有折线或其他东西,您可能需要wkhtmltopdf等待所有在生成PDF之前,这些部分要到位。
这可以通过最新版本0.10.0_rc2和 - window-status 参数来完成(一旦所有事情都准备就绪,目标页面中的JavaScript必须更新window.status变量)。



查看手册 here



一个示例用法如下所示:

  wkhtmltopdf.exe --page-size A4 --dpi 600 --window-status ready --print-media-type http://www.yoursite.com/target.html target.pdf 

缺点:整个过程在资源方面有点矫枉过正,所以如果您的webapp获得大量点击你可能要密切关注这方面。


We have a hosted web app that uses the Google Maps API for various types of geographical reports, using a combination of the javascript API for adding markers and shapes, plus KML overlays for other layers.

There's some demand from customers for turning these into nice downloadable & printable PDF maps. I'm not sure where to begin with that. Any ideas?

解决方案

As Mark Storer pointed out, you can use wkhtmltopdf.

If you have polylines or other stuff in your map you will likely need wkhtmltopdf to wait for all the pieces to be in place before generating the PDF. This can be done with the latest version 0.10.0_rc2 and with the --window-status parameter (javascript in your target page will have to update the window.status variable once everything is ready).

Check out the manual here

An example usage goes like this:

wkhtmltopdf.exe --page-size A4 --dpi 600 --window-status ready --print-media-type http://www.yoursite.com/target.html target.pdf

Cons: the whole process is a bit overkill in terms of resources, so if your webapp gets plenty of hits you may want to pay close attention to this aspect.

这篇关于从Google Maps API在服务器上生成PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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