vendredi 22 janvier 2016

using wiked_pdf how to add the page number to the footer of each page in ruby on rails

how can i add the page number at the footer of each page without using JavaScript.But in controller i given like this

format.pdf do
    f = SentSurvey.generate_pdf_report(sent_survey_skope.pluck(:id), report_type)
    send_file f, type: :pdf, filename: report_filename, :footer => { :right => '[1] of [topage]' }
end

like this i added but its not giving the page number

or

<script>
  function number_pages() {
    var vars={};
    var x=document.location.search.substring(1).split('&');
    for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = decodeURIComponent(z[1]);}
    var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
    for(var i in x) {
      var y = document.getElementsByClassName(x[i]);
      for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
    }
  }
</script>

<body onload="number_pages()">
Page <span class="page"></span> of <span class="topage"></span>
</body>

This is also not helping to me..

Aucun commentaire:

Enregistrer un commentaire