wkhtmltopdf和传单等待地图 [英] wkhtmltopdf and leaflet wait for map
问题描述
我正在使用wkhtmltopdf来打印我的html代码,此代码具有传单地图,我的问题是pdf文件无法正确打印地图,似乎它没有等待地图,所以我包括了一个窗口-状态条件不成功:
I'm using wkhtmltopdf for print my html code, this code has leaflet maps, my problem is pdf file doesnt't print the map properly, it seems it doesn't wait for the map, so I included a window-status condition without success:
在我的html中:
var myMap = L.map('myMap',{attributionControl: false, zoomControl:false })
.on('load', function(){window.status = 'maploaded'});
我的wkhtmltopdf选项:
My options for wkhtmltopdf:
options = {
'dpi': 300,
'image-dpi': 400,
'zoom': 0.7,
'window-status': 'maploaded'
}
我检查了事件是否被触发,并在触发后生成了pdf,但我未显示地图.
I check that the event is fired and the pdf is generated after it's fired, but I the map is not shown.
我该怎么办?
推荐答案
我终于解决了这个问题.
I finally solved this issue.
问题不是我等待地图渲染的时间,而是大小.
The problem wasn't the time I was waiting for the map rendering but the size.
一个普通的"javascript延迟"就足够了.问题:
An usual "javascript-delay" is enought for this. The problem:
<div id="map" class="my-map">
//leaflet code
</div>
.my-map{
//not working
//width: 80%;
//height:80%;
//working
width: 800px;
height: 400px;
}
这篇关于wkhtmltopdf和传单等待地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!