How to print leaflet map in pdf using django-wkhtmltopdf?

I have a django app I am trying to print a leaflet map in pdf using django-wkhtmltopdf, but the map is not rendering correctly. I even try to give more time to the 'javascript-delay' parameter but is giving me the same result. Here is the image of the map: Image of the map

from wkhtmltopdf.views import PDFTemplateResponse

class MyPDFView(View):
    template='agrimensuras/project_pdf.html' # the template 
    def get(self, request, pk):

        project = get_object_or_404(Project, id = int(pk))

        data  = {"project": project} 
        response = PDFTemplateResponse(request=request,
                                       context= data,
                                       cmd_options={'margin-top': 10,
                                       "viewport-size" :"1366 x 513",
                                       'footer-center' :'[page]/[topage]',
        return response

In the template (I am just showing the relevant pieces of code):

<!--Importing leaflet-->
        <link rel="stylesheet" href=""
        <script src=""
     <!--Defining the div-->
      <div id="map" ></div>
    <!--Defining the map-->
    <script type="text/javascript">
         var map ='map').setView([51.505, -0.09], 13);
         L.tileLayer('{z}/{x}/{y}.png', {
              minZoom: 5,
              maxZoom: 19,
              attribution: '&copy; <a href="">OpenStreetMap</a>'
         var marker = L.marker([51.5, -0.09]).addTo(map);
         var circle =[51.508, -0.11], {
            color: 'red',
            fillColor: '#f03',
            fillOpacity: 0.5,
            radius: 500

        var polygon = L.polygon([
        [51.509, -0.08],
        [51.503, -0.06],
        [51.51, -0.047]
Back to Top